Xibo
Jump to navigation
Jump to search
Debugging upgrade error from version 1.8.x to 2.1.2
Upon upgrading from a 1.8.x version of Xibo to 2.1.2, you may encounter the following two errors when running phinx migrate -c phinx.php command:
== 20180131122645 OneRegionPerPlaylistMigration: migrating [PDOException] SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'regionId’
== 20180131122645 OneRegionPerPlaylistMigration: migrating
[PDOException]
SQLSTATE[42000]: Syntax error or access violation: 1067 Invalid default value for 'createdDt'
Inside the db/migrations directory, there is a file named 20180131122645_one_region_per_playlist_migration.php. Open that file and modify lines 13 - 20 as follows:
13 $playlist = $this->table('playlist');
14 $playlist
15 /*->addColumn('regionId', 'integer', ['null' => true])*/
16 ->addColumn('createdDt', 'datetime', ['default' => '2019-12-01 00:00:00'])
17 ->addColumn('modifiedDt', 'datetime', ['default' => '2019-12-01 00:00:00'])
18 ->addColumn('duration', 'integer', ['default' => 0])
19 ->addColumn('requiresDurationUpdate', 'integer', ['default' => 0, 'limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY])
20 ->save();
In short:
- Comment out the addColumn call for the regionId, since it already exists
- Set default values for the createdDt and modifiedDt columns (you can set any value, but the empty value 0000-00-00 00:00:00 is not valid, which is why I chose the first of December for this year as a dummy value.).
Now run phinx migrate -c phinx.php again and the upgrade should succeed.
I also posted this answer in response to the question posed on the Xibo forums.