SchemaBuilder: Drop Table If Exists

Topics: Writing modules
Apr 10, 2012 at 2:39 PM

Would it be feasible to have the SchemaBuilder.DropTable method delete the table only if it exists?  I assume the tricky bit is getting the various syntax supported for object existence checks between SQL Server, SQL CE as well as the other supported databases but I would think this feature would be handy for development scenarios.

Apr 10, 2012 at 2:51 PM

It's not really necessary because the migration methods run only once. You might want to approach the problem from a workflow perspective rather than adding a DropTable method. Here's who I do it: 

Create a rehydrate.bat that:

- Drops and recreates my db

- Runs Orchard setup via command line (this creates the orchard db)

- Runs my custom recipes to enable specific modules, import static/initial data 

When I make major changes I run rehydrate.bat and I get a fresh site that is built from scratch. I have never needed a DropTable (if exists) method.