Search code examples
schemaversioningpropelextend

How do I properly extend an existing schema for Propel without corrupting version tables?


I wanted to add a column (IS_ACTIVE) to an existing table (Book). So I have extended the schema file (schema.xml) accordingly. I went through the following commands as described in the docs.

propel-gen om
propel-gen convert-conf
propel-gen sql

I've stripped all the unnecessary parts from the schema.sql file such that only the affected table would be dropped and recreated. Then I executed:

propel-gen insert-sql

Unfortunately the version table has not been updated in the process, yielding insert errors such as this one

Unable to execute SELECT statement [SELECT book_version.ID, book_version.TITLE,
 book_version.URL, book_version.COMMENTS, book_version.IS_ACTIVE,
 book_version.VERSION FROM `book_version` WHERE book_version.ID=:p1 ORDER BY 
 book_version.VERSION DESC LIMIT 1] [wrapped: SQLSTATE[42S22]: Column not found:
 1054 Unknown column 'book_version.IS_ACTIVE' in 'field list']

when calling

$book->save();

How do I properly extend an existing schema.xml without running into this?


Solution

  • first make a buildtime-conf.xml file as same location on runtime-conf.xml and content have also same like runtime-conf.xml.

    then run below command one by one .

    1. propel-gen diff

    2. propel-gen migrate

    3. prople-gen om

    4. propel-gen convert-conf

      i think this will help you .

    Thanks.