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

Add pre migrations to allow more control of when data migrations can … #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

exosyphon-earthvectors
Copy link

…be run

I love using your gem but need a little more control of when to run data migrations. Sometimes I need to run data migrations after a rails migration to update the structure of the database. Sometimes I need to run data migrations before a rails migration because I am dropping a table and need to delete extra records and cleanup. I am introducing the concept of a Pre Migration that can be controlled separately if desired but will also execute in the normal flow just like a normal data migration. My thought was to update my deployment pipeline to execute this flow and then I should be able to create either a normal or pre data migration to satisfy all cases.

rails data:migrate:pre
rails db:migrate
rails data:migrate

I am open to other names for that other type of migration (Pre Migration) but wanted to facilitate a way to run data migrations a different way based on file name so that my pipeline does not have to change.

I ran the tests using rspec but was not able to get the tests to run using appraisal install && appraisal rake

@serggl
Copy link
Member

serggl commented Jul 26, 2019

@exosyphon-earthvectors I don't think I can support this, this whole concept is looks confusing to me. These 'pre' migrations add indirect dependencies to schema and data migrations which are hard to follow. Also in my understanding, if schema migration depends on data changes - these should be accomplished in the schema migration itself.

Open to hear other people's opinions here

@exosyphon-earthvectors
Copy link
Author

@serggl I definitely agree that this adds complexity but I do think this use case is valid. I don't want to mix structural changes to the database with managing data in the database. Which is one of the main reasons of even using rails-data-migrations for me. I am open to other ways of implementing this so that you can run certain migrations before the rails migrations run. Let me know your thoughts.

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

Successfully merging this pull request may close these issues.

2 participants