db-migration icon indicating copy to clipboard operation
db-migration copied to clipboard

Add change() method to migrations

Open samdark opened this issue 10 years ago • 10 comments

The idea is to implement the same code as in up() and determine how to roll back migration based on it. Migration in this case should be like a query and a builder that has two modes: up and down.

It already exists in some third party libs such as https://phinx.org/

samdark avatar Mar 31 '15 13:03 samdark

reference of ruby on rails :

http://edgeguides.rubyonrails.org/active_record_migrations.html#using-the-change-method

pana1990 avatar Mar 31 '15 16:03 pana1990

cool! like it!

v0lume avatar Aug 06 '15 08:08 v0lume

:+1:

SonicGD avatar Aug 07 '15 04:08 SonicGD

:+1: :)

ghost avatar Aug 07 '15 05:08 ghost

:+1:

RedCatGirl avatar Aug 24 '15 12:08 RedCatGirl

#593

samdark avatar Sep 10 '15 14:09 samdark

:+1: This idea is to reduce the cost of migration in 2 or more times. I know it by own experience. My implementation of this idea in yii2 extension: https://github.com/execut/yii2-migration

execut avatar Feb 13 '17 13:02 execut

Phinx docs about that: http://docs.phinx.org/en/latest/migrations.html

samdark avatar Jul 20 '17 06:07 samdark

I'd like to make it real later. ;)

sergeymakinen avatar Jul 22 '17 22:07 sergeymakinen

I'm not a fan of creating reversible migrations that contain createTable or addColumn. They might be reversible from a structure perspective, but they lose data. Of course, if we implemented automated backups of those tables then i'm all for it!

SamMousa avatar Sep 11 '17 14:09 SamMousa