Hey guys, I'm trying to do CI (continuous integration) on web2py application.
I really need automatic database migration and web2py is really good with it, but using MySQL I notice that we have some
caveats:
I can live without more than one alter table on migrations, but I can't without this other caveat that is not specified by web2py but is on
mysql manual:
Setting foreign_key_checks to 0 can also be useful for ignoring foreign key constraints during LOAD DATA and ALTER TABLE operations. However, even if foreign_key_checks = 0, MySQL does not permit the creation of a foreign key constraint where a column references a nonmatching column type. Also, if a table has foreign key constraints, ALTER TABLE cannot be used to alter the table to use another storage engine. To change the storage engine, you must drop any foreign key constraints first.
So, I can't drop a column without dropping it's foreign key constraints first, and I always get error 150 if I try.
Now I'm migrating my database to Postgres, because web2py REALLY support migrations on it. Just look this citation inside
postgres manual:
This form drops a column from a table. Indexes and table constraints involving the column will be automatically dropped as well. You will need to say CASCADE if anything outside the table depends on the column, for example, foreign key references or views. If IF EXISTS is specified and the column does not exist, no error is thrown. In this case a notice is issued instead.
What should we do to solve this issue with MySQL? A
Stackoverflow question said that we should create a table replica, apply migrations on it and than migrate data.
Is there another way to do that with MySQL?
Regards