From 3dde409f729067ba21fcb1b8a10ce03a35484623 Mon Sep 17 00:00:00 2001 From: oxteam Date: Tue, 10 Jul 2018 15:51:42 +0200 Subject: [PATCH] Change ea_consents table creation and management for backward compatibility (#518] This change allows the creation and migration scripts to run on MySQL/MariaDB 5.5.x versions (still the default version for Linux RHEL/CentOS 7.x versions). --- src/application/migrations/012_legal_contents.php | 4 ++-- src/application/models/Consents_model.php | 1 + src/assets/sql/structure.sql | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/application/migrations/012_legal_contents.php b/src/application/migrations/012_legal_contents.php index 59ccfacf..0bae57bf 100644 --- a/src/application/migrations/012_legal_contents.php +++ b/src/application/migrations/012_legal_contents.php @@ -25,9 +25,9 @@ class Migration_Legal_contents extends CI_Migration { $this->db->query(' CREATE TABLE IF NOT EXISTS `ea_consents` ( `id` INT(11) NOT NULL AUTO_INCREMENT, - `created` DATETIME DEFAULT CURRENT_TIMESTAMP, - `modified` DATETIME DEFAULT CURRENT_TIMESTAMP + `modified` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `created` TIMESTAMP, `first_name` VARCHAR(256), `last_name` VARCHAR(256), `email` VARCHAR(512), diff --git a/src/application/models/Consents_model.php b/src/application/models/Consents_model.php index 399706a2..a9bca67a 100644 --- a/src/application/models/Consents_model.php +++ b/src/application/models/Consents_model.php @@ -74,6 +74,7 @@ class Consents_model extends CI_Model { */ protected function _insert($consent) { + $this->db->set('created', 'NOW()', FALSE); if ( ! $this->db->insert('ea_consents', $consent)) { throw new Exception('Could not insert consent to the database.'); diff --git a/src/assets/sql/structure.sql b/src/assets/sql/structure.sql index 01a73465..618dbc87 100644 --- a/src/assets/sql/structure.sql +++ b/src/assets/sql/structure.sql @@ -23,9 +23,9 @@ CREATE TABLE IF NOT EXISTS `ea_appointments` ( CREATE TABLE IF NOT EXISTS `ea_consents` ( `id` INT(11) NOT NULL AUTO_INCREMENT, - `created` DATETIME DEFAULT CURRENT_TIMESTAMP, - `modified` DATETIME DEFAULT CURRENT_TIMESTAMP + `modified` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `created` TIMESTAMP, `first_name` VARCHAR(256), `last_name` VARCHAR(256), `email` VARCHAR(512),