Search code examples
composer-phppropel

Update Propel Generated classes after modifying database


I wanted to update propel generated classes that are present in the model folder as I have modified my database schema (i.e., I have added one column in a table). What are the steps to update the model classes?


Solution

  • Please follow below steps to update propel model classes:

    1. Remove all the files inside the /vendor folder of your application

    2. execute the below command from the folder where composer.json exists

      $ composer update
      
    3. set the path variable to /path/to/vendor/bin folder

    4. Run the propel reverse task to generate schema.xml specifying your database credentials

       $ propel reverse "mysql:host=localhost;dbname=db;user=root;password=pwd"
      

      Output of above command will be schema.xml file

    5. Replace your schema.xml file in the project with this new one

    6. From the command prompt go to the folder where you copied schema.xml file and execute below commands.

      $ propel sql:build
      $ propel model:build
      

    Thats it. Propel model classes should get updated.