active_record_migrations | ActiveRecord Stand-alone Migrations | Data Migration library
kandi X-RAY | active_record_migrations Summary
kandi X-RAY | active_record_migrations Summary
ActiveRecord Stand-alone Migrations (for non-Rails projects)
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of active_record_migrations
active_record_migrations Key Features
active_record_migrations Examples and Code Snippets
Community Discussions
Trending Discussions on active_record_migrations
QUESTION
I am reading https://edgeguides.rubyonrails.org/active_record_migrations.html and ask myself what the advantages of having an "up" and a "down" method in a migration file over doing a migration via a "change" method.
I could imagine that that way via a "down" method arbitrary migrations become rollback'able. On the other hand, there may still be other migrations that depend on the migration which aren't handled even if you have a "down" method.
So is it correct, that having "up" and "down" methods instead of a "change" method does NOT enable you to rollback arbitrary migration files ?
Second: The rails guide speaks of
...ANSWER
Answered 2020-Aug-27 at 13:22As I understand this, change method knows how to reverse itself automatically. Up does not so you have to specify reverse functionality by yourself in down method.
Automatical reversing comes with downsides as it does not know how to reverse all the available migration calls. Source for this and full list of auto reverse methods is available in the official docs here.
To more clearly answer your question - advatage of "up" and "down" over "change" is being able to have fine control over the way migration gets executed and reverted. Bare in mind this does not mean you can't do all your migrations with up/down or that it's deprecated but you lose out on the conveniece provided by "change". For summary:
- Change - For majority of migrations
- Change + reversible - For some complexity not supported by "change" method"
- up/down - For fine control. Very nieche, custom or complex migrations.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install active_record_migrations
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page