Open opensas opened 5 years ago
Creating a database is something I always felt that it shouldn't have a place in sql-migrate: it'll make your application unportable because you're hardcoding connection details (in this case the database name).
Always provision a database upfront and pass the connection details as parameters to your application.
Great, it makes sense, I should handle that with a previous script or something like that. I've just found you answered something similar here great utility BTW, I'm putting it to the test in a medium sized application with a sql db to see how it goes. Marvellous job indeed!
I guess it's not possible because the db every other migration should be run doesn't exist yet, but I'd like to know if there's some workaround or something
ideally,
sql-migrate up
would create the db and then run the rest of the migrations, andsql-migrate down -limit=0
would end up dropping the whole db.Is it possible? Or is there a better way to do it? Or maybe it's just a bad idea?
I did a test, and sql-migrate ended up creating the migrations table on the master db (I'm using msssql), and the following migration failed because it couldn't find the migrations table