From 139d355bcb72deff67e192020b69e6ca6e4ab969 Mon Sep 17 00:00:00 2001 From: BigTicklez Date: Fri, 7 Dec 2018 08:27:34 -0500 Subject: [PATCH] Fix Migration CMS attempted to update 'created' field in 'prefix_posts' to CURRENT_TIMESTAMP, then add 'updated' field with same default value - illegal move for MySQL. 'created' will now be default "0000-00-00 00:00:00", since the route for add already creates the input for 'created' as the current date/time. --- anchor/migrations/213_add_updated_fields_to_tables.php | 6 +++--- anchor/migrations/21_alter_comments_date.php | 2 +- anchor/migrations/61_alter_posts_created.php | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/anchor/migrations/213_add_updated_fields_to_tables.php b/anchor/migrations/213_add_updated_fields_to_tables.php index 70e0d0e84..cef6469d2 100644 --- a/anchor/migrations/213_add_updated_fields_to_tables.php +++ b/anchor/migrations/213_add_updated_fields_to_tables.php @@ -9,7 +9,7 @@ public function up() if ($this->has_table($posts)) { if (!$this->has_table_column($posts, 'updated')) { $sql = 'ALTER TABLE `' . $posts . '` '; - $sql .= 'ADD COLUMN `updated` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP AFTER `created`'; + $sql .= 'ADD COLUMN `updated` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP AFTER `created`'; DB::ask($sql); } } @@ -19,7 +19,7 @@ public function up() if ($this->has_table($pages)) { if (!$this->has_table_column($pages, 'updated')) { $sql = 'ALTER TABLE `' . $pages . '` '; - $sql .= 'ADD COLUMN `updated` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'; + $sql .= 'ADD COLUMN `updated` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'; DB::ask($sql); } } @@ -29,7 +29,7 @@ public function up() if ($this->has_table($users)) { if (!$this->has_table_column($users, 'updated')) { $sql = 'ALTER TABLE `' . $users . '` '; - $sql .= 'ADD COLUMN `updated` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'; + $sql .= 'ADD COLUMN `updated` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'; DB::ask($sql); } } diff --git a/anchor/migrations/21_alter_comments_date.php b/anchor/migrations/21_alter_comments_date.php index fc1edac33..69a81adf9 100755 --- a/anchor/migrations/21_alter_comments_date.php +++ b/anchor/migrations/21_alter_comments_date.php @@ -8,7 +8,7 @@ public function up() $table = Base::table('comments'); if ($this->has_table($table)) { - $sql = 'ALTER TABLE `' . $table . '` CHANGE `date` `date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP AFTER `status`'; + $sql = 'ALTER TABLE `' . $table . '` CHANGE `date` `date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP AFTER `status`'; DB::ask($sql); } } diff --git a/anchor/migrations/61_alter_posts_created.php b/anchor/migrations/61_alter_posts_created.php index 0e977798d..fdfdd17cb 100755 --- a/anchor/migrations/61_alter_posts_created.php +++ b/anchor/migrations/61_alter_posts_created.php @@ -8,7 +8,7 @@ public function up() $table = Base::table('posts'); if ($this->has_table_column($table, 'created')) { - $sql = 'ALTER TABLE `' . $table . '` CHANGE `created` `created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP AFTER `js`'; + $sql = 'ALTER TABLE `' . $table . '` CHANGE `created` `created` DATETIME NOT NULL DEFAULT "0000-00-00 00:00:00" AFTER `js`'; DB::ask($sql); } }