propelorm / Propel2

Propel2 is an open-source high-performance Object-Relational Mapping (ORM) for modern PHP
http://propelorm.org/
MIT License
1.26k stars 398 forks source link

Swap getUpSQL and getDownSQL #1877

Open melnikaite opened 2 years ago

melnikaite commented 2 years ago

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)

ikeyan commented 2 years ago

@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

ghost commented 1 year ago

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.

SourceCode commented 1 year ago

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.