Repository navigation
Add Command: Drop Database - #4657
laskoviymishka wants to merge 11 commits into
Conversation
|
@bricelam your thoughts on this? |
|
Perfect. We just need to review the command name and come up with a PowerShell counterpart. |
|
Should we have confirmation message to avoid deleting the database by mistake? |
|
@smitpatel confirmation would be good 👍 there is no fun to drop your production database accidentally 😄 |
|
Or we could allow this command only for dev enviroment. May be even remove options for changing enviroment 😄 |
|
+1 for adding a confirmation message, but only if we add a |
|
Agreed, confirmation and |
If force (-f or --force) option presented skip confirm check.
|
Add confirm message. If force ( |
| Reporter.Output.WriteLine(" Cancel droping database. Use -f|--force to skip."); | ||
| return 1; | ||
| }, | ||
| () => force.HasValue()); |
There was a problem hiding this comment.
I would rather see all of this confirmation code inline in the Execute method for now. If we need it more generally later, we can always extract it.
There was a problem hiding this comment.
Sure, i think it would be nice to see such feature in DNX repo (Microsoft.Extensions.CommandLineUtils namespace) i'll create issue for them 😄
Refactor confirm implementation - move away from extensions to delete command itself. Refactor operation executor - move drop database implementation to context operations.
| using (var context = CreateContext(contextName)) | ||
| { | ||
| if (confirmCheck( | ||
| $"Are you sure you want to drop the database '{context.Database.GetDbConnection().Database}' on server '{context.Database.GetDbConnection().DataSource}'? (y/N)")) |
There was a problem hiding this comment.
I think this message needs to be generated by the caller (it will be different for PowerShell). Make confirmCheck take the two pieces of information instead of the message, and format them into a message in DatabaseDeleteCommand.Execute.
There was a problem hiding this comment.
Great, I'll fix it.
|
Do you also want to take a stab at implementing the PowerShell command? (If not, I'll do it as part of merging you PR.) |
|
I could do this, where I could find power shell commands? :) |
|
They're in src/Microsoft.EntityFrameworkCore.Commands/tools/EntityFramework.psm1 and they cross over into C# at src/Microsoft.EntityFrameworkCore.Commands/Design/OperationExecutor.cs |
|
@bricelam sorry for late response, but my knowledge of ✊ 🐚 (power shell) is not good enough to add this commands, could you please assist with these 😸 |
|
lol, no problem; I'd be happy to add it. Is this PR ready to merge then? |
|
@bricelam i think so, everything beside ✊ 🐚 is ready |
|
Will be merged with #4907. @laskoviymishka would you mind rebase-and-squashing on top of |
|
@bricelam OK, but i do not know how to do it 😄 |
|
From command line: git checkout dev
git pull https://github.com/aspnet/EntityFramework.git dev
git checkout dropDatabaseCommand
git rebase -i dev # change all but the first PICK to SQUASH
git push origin dropDatabaseCommand:dropDatabaseCommand --forceOr you can do it with TrotoiseGit: |
Add [CanBeNull] attribute to fix api consistency test. Change database property usage instead of creating new database facade object. Fix: Script-Migrations throws when no migrations. Undo mistake commit for different issue. Add confirm message for dropping database. If force (-f or --force) option presented skip confirm check. Enhance confirm message - now it show database name and data source. Refactor confirm implementation - move away from extensions to delete command itself. Refactor operation executor - move drop database implementation to context operations. Add missed virtal modifier for dropdatabase method in db context operations. Fix incorrect message for force db delete option.
|
@bricelam done, but i not sure that everything is OK 😅 |
|
Merged as bd6d4f7 |

Add new Commands: Drop Database (issue #2476)
dnx ef database delete