Database migration fixes (from 1.2.1 to 1.3.x) (#495).

(cherry picked from commit 40e13cb7d8f5e6f8c481c253b04f1e0fb02197ef)
This commit is contained in:
alext 2018-06-03 15:42:29 +02:00
parent 955b2bdc55
commit 7508790f31
2 changed files with 24 additions and 21 deletions

View File

@ -218,6 +218,9 @@ class Migration_Change_column_types extends CI_Migration {
$this->db->query('ALTER TABLE `ea_user_settings` $this->db->query('ALTER TABLE `ea_user_settings`
ADD CONSTRAINT `ea_user_settings_ibfk_1` FOREIGN KEY (`id_users`) REFERENCES `ea_users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE'); ADD CONSTRAINT `ea_user_settings_ibfk_1` FOREIGN KEY (`id_users`) REFERENCES `ea_users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE');
// Change charset of ea_secretaries_providers table for databases created with EA! 1.2.1 version
$this->db->query('ALTER TABLE ea_secretaries_providers CONVERT TO CHARACTER SET utf8');
} }
public function down() public function down()

View File

@ -2,16 +2,16 @@ SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00"; SET time_zone = "+00:00";
CREATE TABLE IF NOT EXISTS `ea_appointments` ( CREATE TABLE IF NOT EXISTS `ea_appointments` (
`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, `id` INT(11) NOT NULL AUTO_INCREMENT,
`book_datetime` DATETIME, `book_datetime` DATETIME,
`start_datetime` DATETIME, `start_datetime` DATETIME,
`end_datetime` DATETIME, `end_datetime` DATETIME,
`notes` TEXT, `notes` TEXT,
`hash` TEXT, `hash` TEXT,
`is_unavailable` TINYINT(4) DEFAULT '0', `is_unavailable` TINYINT(4) DEFAULT '0',
`id_users_provider` BIGINT(20) UNSIGNED, `id_users_provider` INT(11)
`id_users_customer` BIGINT(20) UNSIGNED, `id_users_customer` INT(11)
`id_services` BIGINT(20) UNSIGNED, `id_services` INT(11)
`id_google_calendar` TEXT, `id_google_calendar` TEXT,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `id_users_customer` (`id_users_customer`), KEY `id_users_customer` (`id_users_customer`),
@ -29,15 +29,15 @@ CREATE TABLE `ea_migrations` (
DEFAULT CHARSET = utf8; DEFAULT CHARSET = utf8;
CREATE TABLE IF NOT EXISTS `ea_roles` ( CREATE TABLE IF NOT EXISTS `ea_roles` (
`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, `id` INT(11) NOT NULL AUTO_INCREMENT,
`name` VARCHAR(256), `name` VARCHAR(256),
`slug` VARCHAR(256), `slug` VARCHAR(256),
`is_admin` TINYINT(4), `is_admin` TINYINT(4),
`appointments` INT(4), `appointments` INT(11),
`customers` INT(4), `customers` INT(11),
`services` INT(4), `services` INT(11),
`users` INT(4), `users` INT(11),
`system_settings` INT(4), `system_settings` INT(11),
`user_settings` INT(11), `user_settings` INT(11),
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) )
@ -46,8 +46,8 @@ CREATE TABLE IF NOT EXISTS `ea_roles` (
CREATE TABLE IF NOT EXISTS `ea_secretaries_providers` ( CREATE TABLE IF NOT EXISTS `ea_secretaries_providers` (
`id_users_secretary` BIGINT(20) UNSIGNED NOT NULL, `id_users_secretary` INT(11) NOT NULL,
`id_users_provider` BIGINT(20) UNSIGNED NOT NULL, `id_users_provider` INT(11) NOT NULL,
PRIMARY KEY (`id_users_secretary`, `id_users_provider`), PRIMARY KEY (`id_users_secretary`, `id_users_provider`),
KEY `id_users_secretary` (`id_users_secretary`), KEY `id_users_secretary` (`id_users_secretary`),
KEY `id_users_provider` (`id_users_provider`) KEY `id_users_provider` (`id_users_provider`)
@ -57,7 +57,7 @@ CREATE TABLE IF NOT EXISTS `ea_secretaries_providers` (
CREATE TABLE IF NOT EXISTS `ea_services` ( CREATE TABLE IF NOT EXISTS `ea_services` (
`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, `id` INT(11) NOT NULL AUTO_INCREMENT,
`name` VARCHAR(256), `name` VARCHAR(256),
`duration` INT(11), `duration` INT(11),
`price` DECIMAL(10, 2), `price` DECIMAL(10, 2),
@ -65,7 +65,7 @@ CREATE TABLE IF NOT EXISTS `ea_services` (
`description` TEXT, `description` TEXT,
`availabilities_type` VARCHAR(32) DEFAULT 'flexible', `availabilities_type` VARCHAR(32) DEFAULT 'flexible',
`attendants_number` INT(11) DEFAULT '1', `attendants_number` INT(11) DEFAULT '1',
`id_service_categories` BIGINT(20) UNSIGNED, `id_service_categories` INT(11)
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `id_service_categories` (`id_service_categories`) KEY `id_service_categories` (`id_service_categories`)
) )
@ -74,8 +74,8 @@ CREATE TABLE IF NOT EXISTS `ea_services` (
CREATE TABLE IF NOT EXISTS `ea_services_providers` ( CREATE TABLE IF NOT EXISTS `ea_services_providers` (
`id_users` BIGINT(20) UNSIGNED NOT NULL, `id_users` INT(11) NOT NULL,
`id_services` BIGINT(20) UNSIGNED NOT NULL, `id_services` INT(11) NOT NULL,
PRIMARY KEY (`id_users`, `id_services`), PRIMARY KEY (`id_users`, `id_services`),
KEY `id_services` (`id_services`) KEY `id_services` (`id_services`)
) )
@ -84,7 +84,7 @@ CREATE TABLE IF NOT EXISTS `ea_services_providers` (
CREATE TABLE IF NOT EXISTS `ea_service_categories` ( CREATE TABLE IF NOT EXISTS `ea_service_categories` (
`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, `id` INT(11) NOT NULL AUTO_INCREMENT,
`name` VARCHAR(256), `name` VARCHAR(256),
`description` TEXT, `description` TEXT,
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
@ -94,7 +94,7 @@ CREATE TABLE IF NOT EXISTS `ea_service_categories` (
CREATE TABLE IF NOT EXISTS `ea_settings` ( CREATE TABLE IF NOT EXISTS `ea_settings` (
`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, `id` INT(11) NOT NULL AUTO_INCREMENT,
`name` VARCHAR(512), `name` VARCHAR(512),
`value` LONGTEXT, `value` LONGTEXT,
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
@ -104,7 +104,7 @@ CREATE TABLE IF NOT EXISTS `ea_settings` (
CREATE TABLE IF NOT EXISTS `ea_users` ( CREATE TABLE IF NOT EXISTS `ea_users` (
`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, `id` INT(11) NOT NULL AUTO_INCREMENT,
`first_name` VARCHAR(256), `first_name` VARCHAR(256),
`last_name` VARCHAR(512), `last_name` VARCHAR(512),
`email` VARCHAR(512), `email` VARCHAR(512),
@ -115,7 +115,7 @@ CREATE TABLE IF NOT EXISTS `ea_users` (
`state` VARCHAR(128), `state` VARCHAR(128),
`zip_code` VARCHAR(64), `zip_code` VARCHAR(64),
`notes` TEXT, `notes` TEXT,
`id_roles` BIGINT(20) UNSIGNED NOT NULL, `id_roles` INT(11) NOT NULL,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `id_roles` (`id_roles`) KEY `id_roles` (`id_roles`)
) )
@ -124,7 +124,7 @@ CREATE TABLE IF NOT EXISTS `ea_users` (
CREATE TABLE IF NOT EXISTS `ea_user_settings` ( CREATE TABLE IF NOT EXISTS `ea_user_settings` (
`id_users` BIGINT(20) UNSIGNED NOT NULL, `id_users` INT(11) NOT NULL,
`username` VARCHAR(256), `username` VARCHAR(256),
`password` VARCHAR(512), `password` VARCHAR(512),
`salt` VARCHAR(512), `salt` VARCHAR(512),