DEV Community

Cover image for Purify code with data integrity. Part 1: defaults and not-nulls

Purify code with data integrity. Part 1: defaults and not-nulls

Dmitry Salahutdinov on November 19, 2018

Working with the data is the crucial point of any application. ActiveRecord makes this process easier for Rails developer. It allows managing the d...
Collapse
 
neznauy profile image
Alexandr Shlyakov

Thanks for ur article.
I think, it's not good practice to place changing data rake tasks in migration, cause of u can change model name, column name, etc. in future, and this migration will fail and make suffer developers who deploy project locally.
Although it's ok to make one-time used rake for production, but in development or test env u should actualize data from seed or dump.
It's only my opinion =)

Collapse
 
bibendi profile image
Misha Merkushin

Cool article! Data migrations under high load are hard. 💪

adding a column with default to the existing table is more complicated, because it will enforce setting the default value for all the rows.

Adding not-null column to existing table

It would be great if you could point out that Postgres 11 has no more these problems.

Collapse
 
dsalahutdinov profile image
Dmitry Salahutdinov • Edited

Michael, thanks for providing the the details, fixed!