dotnet / efcore

EF Core is a modern object-database mapper for .NET. It supports LINQ queries, change tracking, updates, and schema migrations.
https://docs.microsoft.com/ef/
MIT License
13.65k stars 3.15k forks source link

Specific Rollback command line tool #16378

Open dombarnes opened 5 years ago

dombarnes commented 5 years ago

Describe what is not working as expected. If I attempt to run a dotnet ef database update -migration NameOfMigration and it would result in dataloss (i.e it wants to perform a Down action), action should be cancelled to prevent possible accidental dataloss. Suggestion:
Instead introduce a dotnet ef database rollback command specifically for rolling back migrations.
This is how some other db management tools work, like ActiveRecord in rails. This is especially useful as there appears to be no CLI tool to check the current DB migration version, based on the _Migrations table that is updated by EF. Checking the current DB version at the moment requires I open a new code window, set syntax to SQL, connect to the DB and issue the select command to the appropriately named table

Further technical details

EF Core version: Entity Framework Core .NET Command-line Tools, 2.2.4-servicing-10062 Database Provider: Microsoft.EntityFrameworkCore.SqlServer Operating system: macOS 10.14.5 IDE: Code + Terminal

ajcvickers commented 5 years ago

Triage: this is a reasonable idea, although it might be that we do it as a flag on database update rather than a new command. Backlogging for now.