-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable create database #243
Enable create database #243
Conversation
Generally I see 1 in migration tools. However these are also tools following a pattern where the tool itself is intended to run in production and implicitly creating the database might not be wanted. Hopefully, someone using SQLx in production is accessing the database using a user that doesn't have the ability to randomly make databases. Of course if we treat Now when we get to the point where we like what |
Hoping to not derail this PR too badly (I also like option 4). I'm excited that a |
It might be better to just move the create db part to it's own command. Then a user could get a warning that the database is missing and either use the tool to create it or set it up themselves. Less magic :) |
Great minds and all that .. haha. |
Was cheating a bit as I were answering that issue when I wrote that ^^ |
I moved the db creation to a command as in we talked about in #170 |
So I did some clean up and integrated anyhow for cleaner error messages.
I also included a function that uses the connection string to create a database if there is none with the correct name in the database. Would like some feedback on wether that is a good idea or not.
As is you can't actually create the database in a normal migration because the connection will fail because there is no database...
This could be worked around in a number of ways.
create_db.sql
)I can see pros and cons with all of these methods. This PR implements nr 4.
ps. Also fixed so you can create two tables in the same migration.