Skip to content
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

Refuse to start server if there are diesel migrations that haven't been run? #638

Open
carols10cents opened this issue Mar 18, 2017 · 1 comment
Labels
C-internal 🔧 Category: Nonessential work that would make the codebase more consistent or clear

Comments

@carols10cents
Copy link
Member

I'm used to the behavior in rails whereupon if you try to start your server and there are migrations that haven't been made to the database yet, the server will bail right away and tell you to go run them.

Right now, if I forget to run migrations, I may or may not get an error immediately, depending on if I happen to make a request that expects the database to be different or not. I've also been bitten by this enough that now I know "oh hey i probably just need to run migrations", but in the past (especially with rails' reloading where you don't have to restart the server when you get new code) I and other people have gone on wild goose chases when getting weird database errors that were caused by outstanding migrations.

In production, the procfile runs migrations just before starting the server every time, and the tests automatically run outstanding migrations, so this is mostly for development.

Is this possible/easy with diesel, @sgrif ?

@sgrif
Copy link
Contributor

sgrif commented Mar 18, 2017

There's nothing in Diesel that just tells you if there's pending migrations or not, no. There is http://docs.diesel.rs/diesel/migrations/fn.run_pending_migrations.html if you'd rather just automatically run them. I can definitely add a "are there any pending migrations" function to 0.13 though. Long term I actually want to add an "assert that the schema matches what Diesel was compiled against/thinks it is" type function, but I haven't implemented it yet.

@carols10cents carols10cents added the C-enhancement ✨ Category: Adding new behavior or a change to the way an existing feature works label Aug 2, 2017
@Turbo87 Turbo87 added C-internal 🔧 Category: Nonessential work that would make the codebase more consistent or clear and removed A-internal C-enhancement ✨ Category: Adding new behavior or a change to the way an existing feature works labels Feb 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-internal 🔧 Category: Nonessential work that would make the codebase more consistent or clear
Projects
None yet
Development

No branches or pull requests

3 participants