|
| 1 | +-- |
| 2 | +-- update the character set for existing installations. |
| 3 | + |
| 4 | +-- mysql will refuse to change the character set of tables with foreign key relationships, |
| 5 | +-- so we disable foreign key checks (we could also first drop FKs and after changes insert FKs again). |
| 6 | +-- but then, to ensure data integrity, we should block other access to these tables. hence, the lock tables. |
| 7 | +-- |
| 8 | +-- and also we cannot touch book keeping table "schema_version" of flyway, |
| 9 | +-- since it will be in use during the migration. |
| 10 | +-- |
| 11 | +-- https://dev.mysql.com/doc/refman/5.5/en/charset-unicode-utf8mb4.html |
| 12 | +-- http://stackoverflow.com/a/766996 |
| 13 | +-- |
| 14 | + |
| 15 | +LOCK TABLES |
| 16 | + address WRITE, |
| 17 | + charge_box WRITE, |
| 18 | + connector WRITE, |
| 19 | + connector_meter_value WRITE, |
| 20 | + connector_status WRITE, |
| 21 | + ocpp_tag WRITE, |
| 22 | + reservation WRITE, |
| 23 | + settings WRITE, |
| 24 | + `transaction` WRITE, |
| 25 | + `user` WRITE; |
| 26 | + |
| 27 | +SET FOREIGN_KEY_CHECKS = 0; |
| 28 | + |
| 29 | +ALTER TABLE address CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; |
| 30 | +ALTER TABLE charge_box CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; |
| 31 | +ALTER TABLE connector CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; |
| 32 | +ALTER TABLE connector_meter_value CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; |
| 33 | +ALTER TABLE connector_status CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; |
| 34 | +ALTER TABLE ocpp_tag CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; |
| 35 | +ALTER TABLE reservation CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; |
| 36 | +ALTER TABLE settings CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; |
| 37 | +ALTER TABLE `transaction` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; |
| 38 | +ALTER TABLE `user` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; |
| 39 | + |
| 40 | +SET FOREIGN_KEY_CHECKS = 1; |
| 41 | + |
| 42 | +UNLOCK TABLES; |
0 commit comments