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

Sticky situation when you ignore a non-null column #197

Open
lake-effect opened this issue Aug 31, 2022 · 2 comments
Open

Sticky situation when you ignore a non-null column #197

lake-effect opened this issue Aug 31, 2022 · 2 comments

Comments

@lake-effect
Copy link

This isn't a bug in the code per se, but it's something that I think the documentation or detection logic could help with.

When you drop a column with a not-null constraint, strong_migrations tells you that you must first ignore the column in a separate deploy to ensure the database cache is cleaned out. No problem. This is also a nice soft way to be sure your application isn't depending on that column anymore.

However, if you have factories or fixtures and such set up in this situation, the DB will complain if they try to insert a record without that column. If you put the value back into the fixtures or factories, ActiveRecord will get mad at you for trying to set a value that is ignored. So if you have CI that should pass before you get this deploy done, you lose signal.

I'm not sure what should be done here. The simplest thing I can see is to have strong_migrations advise you to drop the NOT NULL constraint at the same time the column is ignored, but something about that seems messy.

@ankane
Copy link
Owner

ankane commented Sep 1, 2022

Hey @lake-effect, thanks for sharing. If there's no default value, I think allowing null for fixtures and factories makes sense. I'm on the fence about whether Strong Migrations should mention it (either in the readme and/or error message) - will leave this open for a bit to think about.

@niudage
Copy link

niudage commented Feb 21, 2023

good thankyou

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants