mirror of
https://github.com/elyby/accounts.git
synced 2024-12-25 22:59:53 +05:30
Переход на кодировку utf8md4_unicode_ci
This commit is contained in:
parent
43b69aed0b
commit
d2f3a05b31
@ -9,7 +9,7 @@ variables:
|
|||||||
test:backend:
|
test:backend:
|
||||||
image: docker:latest
|
image: docker:latest
|
||||||
services:
|
services:
|
||||||
- mariadb:10.0
|
- mariadb:10.2.11
|
||||||
- redis:3.0-alpine
|
- redis:3.0-alpine
|
||||||
variables:
|
variables:
|
||||||
# mariadb config
|
# mariadb config
|
||||||
|
@ -11,7 +11,7 @@ class Migration extends YiiMigration {
|
|||||||
public function getTableOptions($engine = 'InnoDB') {
|
public function getTableOptions($engine = 'InnoDB') {
|
||||||
$tableOptions = null;
|
$tableOptions = null;
|
||||||
if ($this->db->driverName === 'mysql') {
|
if ($this->db->driverName === 'mysql') {
|
||||||
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=' . $engine;
|
$tableOptions = 'CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE=' . $engine;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $tableOptions;
|
return $tableOptions;
|
||||||
|
@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use console\db\Migration;
|
||||||
|
|
||||||
|
class m171222_200114_migrate_to_utf8md4_unicode_ci extends Migration {
|
||||||
|
|
||||||
|
public function safeUp() {
|
||||||
|
$this->execute('SET FOREIGN_KEY_CHECKS=0');
|
||||||
|
|
||||||
|
$dbName = $this->db->createCommand('SELECT DATABASE()')->queryScalar();
|
||||||
|
$this->execute("ALTER DATABASE {{%$dbName}} CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci");
|
||||||
|
$tables = $this->db->createCommand('SHOW TABLES')->queryColumn();
|
||||||
|
foreach ($tables as $table) {
|
||||||
|
$this->execute("ALTER TABLE {{%$table}} CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci");
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->execute('ALTER TABLE {{%usernames_history}} MODIFY username VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL');
|
||||||
|
|
||||||
|
$this->execute('SET FOREIGN_KEY_CHECKS=1');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function safeDown() {
|
||||||
|
$this->execute('SET FOREIGN_KEY_CHECKS=0');
|
||||||
|
|
||||||
|
$dbName = $this->db->createCommand('SELECT DATABASE()')->queryScalar();
|
||||||
|
$this->execute("ALTER DATABASE {{%$dbName}} CHARACTER SET = utf8 COLLATE = utf8_general_ci");
|
||||||
|
$tables = $this->db->createCommand('SHOW TABLES')->queryColumn();
|
||||||
|
foreach ($tables as $table) {
|
||||||
|
$this->execute("ALTER TABLE {{%$table}} CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci");
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->execute('ALTER TABLE {{%usernames_history}} MODIFY username VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL');
|
||||||
|
|
||||||
|
$this->execute('SET FOREIGN_KEY_CHECKS=1');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
FROM mariadb:10.0
|
FROM mariadb:10.2.11
|
||||||
|
|
||||||
COPY custom.cnf /etc/mysql/conf.d/
|
COPY custom.cnf /etc/mysql/conf.d/
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
[mysql]
|
[mysql]
|
||||||
default-character-set = utf8
|
default-character-set = utf8mb4
|
||||||
|
|
||||||
[mysqld]
|
[mysqld]
|
||||||
character-set-server = utf8
|
character-set-server = utf8mb4
|
||||||
collation-server = utf8_general_ci
|
collation-server = utf8mb4_unicode_ci
|
||||||
|
|
||||||
[client]
|
[client]
|
||||||
default-character-set = utf8
|
default-character-set = utf8mb4
|
||||||
|
Loading…
Reference in New Issue
Block a user