· 9 years ago · Jul 12, 2017, 07:36 PM
1#STEPS TO MIGRATE TO VENTURA TRAVEL DATABASE
2
3ALTER TABLE client DROP INDEX email_is_deleted_unique_idx;
4
5TRUNCATE `cost_and_price`;
6TRUNCATE `cost_and_price_period`;
7TRUNCATE `cost_and_price_period_trip_relation`;
8TRUNCATE `add_on_cost_and_price_period_relation`;
9
10#PAUSE ALL SYSTEMS
11#CREATE NEW DATABASES
12DROP DATABASE IF EXISTS `ventura_laravel`;
13DROP DATABASE IF EXISTS `pura_ventura_laravel`;
14DROP DATABASE IF EXISTS `euro_ventura_laravel`;
15
16CREATE DATABASE ventura_laravel CHARACTER SET utf8 COLLATE utf8_general_ci;
17CREATE DATABASE pura_ventura_laravel CHARACTER SET utf8 COLLATE utf8_general_ci;
18CREATE DATABASE euro_ventura_laravel CHARACTER SET utf8 COLLATE utf8_general_ci;
19
20MAKE DUMPS FROM PRODUCTION DATABASES
21mysqldump --user=root --password=CCoITEOfCoP2016 vi_laravel | mysql --user=root --password=CCoITEOfCoP2016 ventura_laravel
22mysqldump --user=root --password=CCoITEOfCoP2016 pura_laravel | mysql --user=root --password=CCoITEOfCoP2016 pura_ventura_laravel
23mysqldump --user=root --password=CCoITEOfCoP2016 euro_laravel | mysql --user=root --password=CCoITEOfCoP2016 euro_ventura_laravel
24
25#RUN NEW MIGRATIONS
26FOR EACH DATABASE WE NEED TO MAKE THE FOLLOWING STEPS ADAPTING in /sites/viventura/ventura-database/config/databases.yml
27
28./symfony.sh doctrine:migrate --env=staging
29
30#UPDATE SLUGGABLE INDEXS IN VENTURA DATABASE
31
32ALTER TABLE `go_user_project_relation` CHANGE COLUMN `id` `id` INT(11) NOT NULL, DROP PRIMARY KEY;
33
34ALTER TABLE `go_user_project_relation` DROP id;
35ALTER TABLE `go_user_project_relation`
36 ADD PRIMARY KEY(
37 `go_user_id`,
38 `project_id`);
39
40INSERT INTO go_user_project_relation(project_id, go_user_id)
41 SELECT '1', gu.id
42 FROM go_user gu
43
44ALTER TABLE `add_on` DROP INDEX `add_on_sluggable_idx`, ADD UNIQUE `add_on_sluggable_idx` (`name_slug`, `locale_id`, `name`, `project_id`) USING BTREE;
45ALTER TABLE `departure_footnote` DROP INDEX `departure_footnote_sluggable_idx`, ADD UNIQUE `departure_footnote_sluggable_idx` (`name_slug`, `locale_id`, `name`, `project_id`) USING BTREE;
46
47
48ALTER TABLE `quiz` DROP INDEX `url_safe_name`, ADD UNIQUE `url_safe_name` (`url_safe_name`, `project_id`) USING BTREE;
49
50ALTER TABLE `attraction_translation` ADD `project_id` SMALLINT(6) NOT NULL;
51
52ALTER TABLE replaceable_text DROP INDEX unique_key;
53
54ALTER TABLE incoming_replaceable_text DROP INDEX unique_key;
55
56ALTER TABLE locale_specific_value DROP INDEX unique_key;
57
58ALTER TABLE promotion_header DROP INDEX locale_id_url_unique_idx;
59
60ALTER TABLE `localized_i18n_entity` DROP INDEX `locale_id_i18n_entity_id_unique_idx`, ADD UNIQUE `locale_id_i18n_entity_id_unique_idx` (`locale_id`, `i18n_entity_id`, `project_id`) USING BTREE;
61
62ALTER TABLE meta_tag DROP INDEX local_id_url_unique_idx;
63
64ALTER TABLE `i18n_entity_entry` DROP INDEX `localized_i18n_entity_id_entity_entry_id_unique_idx`, ADD UNIQUE `localized_i18n_entity_id_entity_entry_id_unique_idx` (`localized_i18n_entity_id`, `entity_entry_id`, `project_id`) USING BTREE;
65
66ALTER TABLE `attraction_translation`
67 ADD KEY `attraction_translation_project_id_idx` (`project_id`);
68
69ALTER TABLE `attraction_translation` DROP INDEX `attraction_translation_sluggable_idx`, ADD UNIQUE `attraction_translation_sluggable_idx` (`name_slug`, `lang`, `name`, `project_id`) USING BTREE;
70
71ALTER TABLE `country_translation` ADD `project_id` SMALLINT(6) NOT NULL;
72
73ALTER TABLE `country_translation`
74 ADD KEY `country_translation_project_id_idx` (`project_id`);
75
76ALTER TABLE `country_translation` DROP INDEX `country_translation_sluggable_idx`, ADD UNIQUE `country_translation_sluggable_idx` (`name_slug`, `lang`, `name`, `project_id`) USING BTREE;
77
78ALTER TABLE `trip_tag_translation` ADD `project_id` SMALLINT(6) NOT NULL;
79
80ALTER TABLE `trip_tag_translation`
81 ADD KEY `trip_tag_translation_project_id_idx` (`project_id`);
82
83ALTER TABLE `trip_tag_translation` DROP INDEX `trip_tag_translation_sluggable_idx`, ADD UNIQUE `trip_tag_translation_sluggable_idx` (`name_slug`, `lang`, `name`, `project_id`) USING BTREE;
84
85ALTER TABLE `trip_type_translation` ADD `project_id` SMALLINT(6) NOT NULL;
86
87ALTER TABLE `trip_type_translation`
88 ADD KEY `trip_type_translation_project_id_idx` (`project_id`);
89
90ALTER TABLE `trip_type_translation` DROP INDEX `trip_type_translation_sluggable_idx`, ADD UNIQUE `trip_type_translation_sluggable_idx` (`name_slug`, `lang`, `name`, `project_id`) USING BTREE;
91
92#RUN TASK TO GENERATE SQL FILE TO MIGRATE
93./symfony.sh viventura:migrateVenturaDatabase --env=staging
94
95mysql --host=172.31.27.61 --user=root --password=CCoITEOfCoP2016 --default-character-set=utf8 ventura_laravel < /usr/share/nginx/html/sites/db_backups/complete-migration-0-2.sql