Difference between revisions of "Xibo"

From Libopedia
Jump to navigation Jump to search
(Created page with "== 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 <code>...")
 
 
Line 12: Line 12:
 
                                                                                                
 
                                                                                                
 
[PDOException]                                                                                 
 
[PDOException]                                                                                 
SQLSTATE[42000]: Syntax error or access violation: 1067 Invalid default value for 'createdDt'                                                                                              
+
SQLSTATE[42000]: Syntax error or access violation: 1067 Invalid default value for 'createdDt'</nowiki>
</nowiki>
 
  
 
Inside the db/migrations directory, there is a file named <code>20180131122645_one_region_per_playlist_migration.php</code>. Open that file and modify lines 13 - 20 as follows:
 
Inside the db/migrations directory, there is a file named <code>20180131122645_one_region_per_playlist_migration.php</code>. Open that file and modify lines 13 - 20 as follows:

Latest revision as of 08:25, 4 December 2019

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:

  1. Comment out the addColumn call for the regionId, since it already exists
  2. 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.