Propel2 icon indicating copy to clipboard operation
Propel2 copied to clipboard

Swap getUpSQL and getDownSQL

Open melnikaite opened this issue 2 years ago • 3 comments

I have an existing db, generated schema.xml, then added new column to the db and run propel diff In a generated migration I see getUpSQL dropping the field and getDownSQL adding new field I think getUpSQL and getDownSQL should be swapped here https://github.com/propelorm/Propel2/blob/431b8d059b660fc5afc674cb90c15b5e23af3089/src/Propel/Generator/Command/MigrationDiffCommand.php#L218-L219 Or I just use Propel in a wrong way)

melnikaite avatar May 03 '22 07:05 melnikaite

@melnikaite you should modify schema.xml and run propel diff. if you can modify your DB, you already have the right DDL so no need for propel diff. http://propelorm.org/documentation/09-migrations.html#migration-workflow

ikeyan avatar May 09 '22 04:05 ikeyan

The workflow we have (same issue) is that we first modify DB in our dev system directly, and then want to roll it out to our various production environments.

The advantage of this approach is that it is quite simple: We use GUI tools like phpmyadmin to edit the DB structure, and then make sure the application runs with the new structure. In this approach, there is no need to learn the Propel-specific XML format for DB structures.

ghost avatar Feb 27 '23 21:02 ghost

That's not an advantage, it's sloppy. Use the schema and diff set to manage the changes in your database. Review how ORMs work and why you should manage chnagesets and not modify your database directly. This is an ORM toolset.

SourceCode avatar Feb 28 '23 06:02 SourceCode