-
Notifications
You must be signed in to change notification settings - Fork 32
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
mg reset fails due to constraints #42
Comments
Sorry for the late response! Yes. That is a known issue of If the database you use happen to have some easy ways to reset your database, you can implement that in the Dropping tables in reverse order sounds an interesting idea! But I'm not sure how does this work with migrations that alter tables and adds foreign keys to later created tables? Tracking table update time will not work, because I don't know any easy ways to check whether altering table changes the foreign key constraints... |
Been thinking more about the reset issue. I wonder if the solution might be to add the concepts of reverse migrations. This is a common mechanism in rails, django, where it's called up/down or undomigrations in flywheel. I see that the |
I don't know of any elegant general solution, but for Postgres I tend to drop "public" and then recreate it, that way you don't have to think about the relations UP / DOWN would be the "right" way to do it, for simple cases DOWN could be inferable (maybe a feature for slick-migration-api?) |
From working with rails, I'm a little sceptical of the operational value of 'down' migrations - as soon as you've got a database of any size, even hypothetically reversible ones can take a lot of care to apply correctly, so it's best to stick to going forward. A 'clean' down has some value at development time, however, when you're iterating on the migration itself. Since the only conceivable use of |
I have a number of tables with foreign key constraints. When I try to run
mg reset
it fails because the drop needs to either happen in reverse order of create or specifyCASCADE
. I'd say the former is better, sinceCASCADE
would mean later drops might encounter missing tables that were already removed.Of course, right now there is no tracking of creation order, unless each table was created as a separate migration, so not sure how this should be handled
The text was updated successfully, but these errors were encountered: