Added MySQL migration for applying column level collation (#1297)
This commit is contained in:
parent
9c94bbb19a
commit
950a88be5e
3 changed files with 83 additions and 2 deletions
|
@ -205,7 +205,7 @@ func _000010_blocks_created_by_up_sql() ([]byte, error) {
|
|||
)
|
||||
}
|
||||
|
||||
var __000011_match_collation_down_sql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x04\xc0\xb1\x0d\x85\x30\x0c\x04\xd0\x3e\x53\xdc\x02\x5e\xe5\x57\x7f\x81\x44\x1c\x89\x85\x75\x46\xc4\x0d\xdb\xf3\xcc\xf0\xcb\x5a\xae\x89\x4a\x0c\xe2\x48\x11\x8b\x0f\x9b\x19\xfe\xcb\x37\xee\x3e\x09\xdf\x70\x15\x55\x9e\xea\x11\x2f\x82\x67\x61\x44\xd7\xd5\xbe\x00\x00\x00\xff\xff\xeb\x41\x32\x0f\x44\x00\x00\x00")
|
||||
var __000011_match_collation_down_sql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x04\xc0\x31\x0e\x85\x20\x0c\x06\xe0\x9d\x53\xfc\x17\xe8\xf0\xe6\x37\x1a\x36\xe3\x22\x17\x80\x58\xa1\xb1\x69\x8d\x74\xf1\xf6\x7e\x44\xd8\x3c\x86\x58\x47\x38\x1a\xe3\x70\x63\x0c\x7e\x38\x11\xa1\x0c\x99\xb8\x6b\x67\xc8\x84\x58\xb0\x85\xb8\x55\xd5\x17\xca\x67\xa0\x69\xb5\x2b\xed\x79\xcd\x4b\xc1\xef\x9f\xbe\x00\x00\x00\xff\xff\x54\x6c\x45\x67\x4e\x00\x00\x00")
|
||||
|
||||
func _000011_match_collation_down_sql() ([]byte, error) {
|
||||
return bindata_read(
|
||||
|
@ -214,7 +214,7 @@ func _000011_match_collation_down_sql() ([]byte, error) {
|
|||
)
|
||||
}
|
||||
|
||||
var __000011_match_collation_up_sql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xcc\x95\x4d\x6b\xdc\x30\x10\x86\xef\xfb\x2b\xe6\xe6\x5d\x68\x0c\x3d\x87\x85\x2a\x5a\x95\x1e\xdc\x38\xf5\xaa\xb4\x37\xa3\x78\xe5\xb5\x88\x3e\x5c\x8d\x4c\x6b\x8c\xff\x7b\xa9\x3f\xe2\x50\xf6\xe6\x42\x7d\x1d\xbd\xf3\xbc\x7a\xd0\x41\x5d\xa7\x4a\x10\xf6\x02\xb1\x69\xf1\x87\x86\xb8\xd6\xcd\x55\xd9\xbe\xdf\x01\x00\xdc\xdd\x41\xe1\xb4\x16\x41\x39\x0b\xae\x04\x23\x42\x90\xde\x38\x0c\x11\x02\xad\x84\xb5\x52\x23\x04\xf1\xac\xe5\x90\x3f\x33\x0e\x1f\x96\x10\x7d\xdd\x3d\xc2\xfe\xcc\x12\x46\xf9\x18\xce\x17\x6a\xe9\x9d\x01\x65\x4b\xe7\xcd\x30\xc8\xb1\xa8\xa4\x11\xf1\x90\x43\xf8\xf6\x89\x65\x6c\x5a\xb2\xc2\x48\x38\x42\x34\x17\x47\x40\x1e\x4f\xd3\xd9\xb8\xf5\xa6\xe7\x44\x38\x79\x20\x67\xb6\x3f\x1c\x0e\xf7\xbb\xd9\xe6\x59\xbb\xe2\x05\x97\xbb\x36\xf5\x45\x04\xf9\x7a\xcf\x2f\x8d\xf4\x2d\x1c\x81\xa6\x8f\x94\xf0\x7d\x44\x12\xce\x32\xe0\xe4\x21\x61\xd0\x75\x71\xed\x65\xa9\x7e\xf5\xfd\x48\x01\x9a\x26\x09\xe1\x0c\xa2\x77\x37\xa5\x0f\xf7\x43\xcf\x53\xc6\x9e\x48\xc6\x00\x83\x09\xf0\x31\x4b\x3f\xdf\x6e\x1d\xc3\xec\x3b\xa3\x5f\xf9\x18\x1e\x27\x27\x46\x92\x24\xa5\x7f\x7a\xde\x92\xfe\x56\x82\x4a\x61\x70\xbe\xfd\x37\x6a\xf9\x44\xdb\x88\x22\x4a\x44\xe5\xec\xea\x77\x9b\x39\x5b\xd1\xaa\x84\x57\xf6\xba\xda\x6a\xc4\x6c\x45\xaa\xc5\x20\x0d\xa0\x0c\x41\xd9\xeb\xfa\x27\x1b\x70\xf9\x8c\xdb\x88\x64\x83\xd2\xaf\x56\x1b\x20\x1b\x11\xfa\xe9\xfc\x0b\xd6\xa2\x90\xab\xad\x16\xd2\x7f\x56\xeb\x3a\xa9\x51\x4e\x1f\xd9\xf4\x29\xbc\x1f\xc6\xf6\xd2\xf7\xbb\xdf\x01\x00\x00\xff\xff\xf8\xa0\x61\xa4\xf9\x06\x00\x00")
|
||||
var __000011_match_collation_up_sql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xcc\x95\xcd\x6e\xda\x40\x14\x85\xf7\x3c\xc5\x51\x36\x80\xd4\x58\xea\x3a\x42\xaa\x63\xa6\xea\xc2\x0d\x29\xb8\x4a\x77\x68\x62\xae\xf1\x28\xf3\x43\xe6\x8e\x45\x91\xe5\x77\xaf\x3a\xc6\x01\x55\xd9\x51\x29\x6c\xed\x73\xbe\x3b\xdf\xcc\xe2\xb6\xad\xaa\x20\xed\x06\x89\x39\xf0\xab\x46\xb2\xd3\xcd\x56\xd9\xae\x1b\x01\xc0\xed\x2d\x4a\xa7\xb5\x0c\xca\x59\xb8\x0a\x46\x86\x40\xde\x38\x0e\x63\x46\x56\x4b\x6b\x49\x33\x82\x7c\xd6\x14\xf3\x2b\x51\xe0\xcb\x29\x94\xbd\x75\x67\x98\xac\x44\x2e\xb2\xa2\x0f\xaf\x4f\xd4\xca\x3b\x03\x65\x2b\xe7\x4d\xfc\xb0\xe6\xb2\x26\x23\x93\x98\x63\x3c\x7d\x13\x4b\x71\x2c\x59\x69\x08\x33\x8c\x87\xc1\x63\xa4\x0f\xf3\xe3\xbf\xbe\x75\x36\x67\x9e\x16\xe9\x7d\xba\x12\x93\xe9\x74\x7a\x37\x1a\x6c\x9e\xb5\x2b\x5f\xf8\x74\xd6\x66\xb7\x91\x81\xde\xce\xf9\xa3\x21\x7f\xc0\x0c\xd9\xe2\x21\x4b\x8b\xc9\x38\xcd\x0b\xb1\x44\x91\xde\xe7\x02\x6d\x9b\xec\x3c\x55\xea\x77\xd7\xf5\x14\x64\x8b\x3c\x4f\x0b\x81\xf1\xa7\x77\xa5\xa7\x77\x71\xce\xe3\x52\x3c\xa6\x4b\x01\x0e\x26\xe0\xeb\x72\xf1\xfd\xfd\xa9\x7d\x58\xfc\x12\xd9\xcf\xa2\x0f\xf7\x5f\xe6\x22\xcd\xf3\x45\xf6\x77\xce\x39\xe9\x5f\x25\xd4\x8a\x83\xf3\x87\xff\xa3\xb6\x3e\xd2\xae\x44\x91\x89\x59\x39\x7b\xf1\xbb\x0d\x9c\x6b\xd1\xaa\xa5\x57\x76\x7b\xb1\x55\x8f\xb9\x16\xa9\x03\x07\x32\x60\x0a\x41\xd9\xed\xe5\x4f\x16\x71\xeb\x01\x77\x25\x92\x0d\x93\xbf\x58\x2d\x42\xae\x44\x68\xef\xfc\x0b\xef\x64\x49\x17\x5b\x9d\x48\x1f\xac\xd6\xb6\xa4\x99\x4e\x8b\xec\x89\x60\x89\x36\x90\x78\x8d\x26\x35\x79\x82\x0b\x35\xf9\xbd\x62\x42\xa8\x09\x46\x6d\x7d\xbf\x95\xf6\x4a\x6b\x78\xe2\x46\x87\xa1\xaf\x2c\xa4\x05\x99\x5d\x38\x1c\x09\xfb\x9a\x6c\xec\xa9\x0a\xa5\xb3\x1b\x15\xab\x8a\x51\x49\xcd\x94\x0c\x45\x71\x56\x29\x65\xc3\xc4\x90\xb8\xe9\xaf\x73\x2f\xb9\x47\xde\x80\xbc\x77\x3e\x39\x5e\x7f\x5c\x61\x9f\xa3\x84\xdd\x74\xdd\xe8\x4f\x00\x00\x00\xff\xff\xed\x3f\x00\x0b\xa7\x07\x00\x00")
|
||||
|
||||
func _000011_match_collation_up_sql() ([]byte, error) {
|
||||
return bindata_read(
|
||||
|
@ -223,6 +223,24 @@ func _000011_match_collation_up_sql() ([]byte, error) {
|
|||
)
|
||||
}
|
||||
|
||||
var __000012_match_column_collation_down_sql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x04\xc0\x31\x0e\x85\x20\x0c\x06\xe0\x9d\x53\xfc\x17\xe8\xf0\xe6\x37\x1a\x36\xe3\x22\x17\x80\x58\xa1\xb1\x69\x8d\x74\xf1\xf6\x7e\x44\xd8\x3c\x86\x58\x47\x38\x1a\xe3\x70\x63\x0c\x7e\x38\x11\xa1\x0c\x99\xb8\x6b\x67\xc8\x84\x58\xb0\x85\xb8\x55\xd5\x17\xca\x67\xa0\x69\xb5\x2b\xed\x79\xcd\x4b\xc1\xef\x9f\xbe\x00\x00\x00\xff\xff\x54\x6c\x45\x67\x4e\x00\x00\x00")
|
||||
|
||||
func _000012_match_column_collation_down_sql() ([]byte, error) {
|
||||
return bindata_read(
|
||||
__000012_match_column_collation_down_sql,
|
||||
"000012_match_column_collation.down.sql",
|
||||
)
|
||||
}
|
||||
|
||||
var __000012_match_column_collation_up_sql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xd4\x96\x4f\x4f\xe3\x3c\x10\xc6\xef\x7c\x8a\x11\x97\x50\x09\x2a\xbd\x67\x54\xe9\x35\xc1\x2b\x0e\xa1\x65\x53\xb3\xec\xad\x32\xe9\xa4\xb1\xf0\x9f\xe2\x71\xd4\xad\xaa\x7c\xf7\x15\x4e\x42\x2a\xd4\x3d\x95\x4b\xae\xc9\xf3\x3c\x33\xf3\x1b\x1f\xe6\x70\x50\x25\x48\xbb\x86\xa9\xd9\xd3\xbb\x86\xe9\x56\xd7\x1b\x65\x9b\xe6\x02\x00\xe0\xe6\x06\x0a\xa7\xb5\x0c\xca\x59\x70\x25\x18\x19\x02\x7a\xe3\x28\x24\x04\x69\x25\xad\x45\x4d\x10\xe4\xab\xc6\xa8\x5f\x72\x01\xff\x0f\xa2\xf4\xd3\x3b\x83\xab\x25\xcf\x78\x2a\x5a\xf1\x6a\x48\x2d\xbd\x33\xa0\x6c\xe9\xbc\x89\x1f\x56\x54\x54\x68\xe4\x34\xea\x08\x5e\x1e\x78\xce\x3b\x93\x95\x06\x61\x06\x49\x5f\x38\x01\x36\xbf\xef\xfe\xb5\xae\xa3\x3a\xf7\x4c\xb0\x3b\xb6\xe4\x57\x93\xc9\xe4\xf6\x64\x73\x95\xf4\x84\xe1\xc8\x92\x3e\xb0\x9c\xa5\x82\xe7\xab\x25\x17\xab\x39\x7b\xe4\xff\xec\xae\x70\xba\x36\xf6\x7b\xda\x8b\xb2\x74\x91\x3d\x3f\xce\xdb\xa2\x33\x48\xe6\xd2\x60\x32\xb9\xbd\xe8\xb7\xf0\xaa\x5d\xf1\x46\xc3\x18\xf5\x76\x2d\x03\x7e\xf2\xfd\x59\xa3\xdf\xc3\x0c\xd2\xc5\x3c\x65\xe2\x2a\x61\x99\xe0\x39\x08\x76\x97\x71\x38\x1c\xa6\x5b\x8f\xa5\xfa\xd3\x34\x6d\xca\x87\xea\x17\xcf\x05\x88\xc5\x30\x72\x8c\x4d\xae\x4f\x00\xba\x86\xe4\xa3\xbb\x8c\x09\xfe\x55\xd0\x97\xef\x00\x3f\xe5\xfc\x89\xe5\x1c\x28\x98\x00\x3f\xf2\xc5\xe3\xe9\x3e\x5b\x31\xff\xcd\xd3\x67\xd1\x8a\xdb\x2f\xf7\x9c\x65\xd9\x22\xfd\xa8\x73\x9c\xf4\x15\x02\x54\x8a\x82\xf3\xfb\xef\x81\xb1\xea\xd2\x46\x0b\x85\x90\x48\x39\x7b\xf6\xdb\xe8\x73\xc6\x0b\xa2\x92\x5e\xd9\xcd\xd9\x1c\xda\x98\xf1\x62\xd8\x53\x40\x03\x84\x21\x28\xbb\x39\xff\x59\xc4\xb8\x55\x1f\x37\x5a\x2c\x35\xa1\x3f\x1b\x46\x0c\x19\x2d\x82\x9d\xf3\x6f\xb4\x95\x05\x9e\xcd\x61\x48\x1a\x1d\x8c\xc3\x01\x35\xe1\x70\xde\xbc\x20\x58\xc4\x35\x48\x78\x8f\xb3\x57\xe8\x11\x5c\xa8\xd0\xef\x14\x21\x84\x0a\xc1\xa8\x8d\x6f\x6f\x95\x9d\xd2\x1a\x3c\x52\xad\x43\xef\x57\x16\xa4\x05\x34\xdb\xb0\xef\x12\x76\x15\xda\xe8\x53\x25\x14\xce\xae\x55\xb4\x2a\x82\x52\x6a\xc2\x69\x6f\xe4\x47\x96\x42\xd6\x84\x04\x12\x2e\xdb\x05\xec\x24\xb5\x91\x97\x80\xde\x3b\x3f\xed\x16\x16\x2f\x87\xff\xe2\x10\x76\xdd\x34\x17\x7f\x03\x00\x00\xff\xff\x15\xde\x90\xeb\xbd\x09\x00\x00")
|
||||
|
||||
func _000012_match_column_collation_up_sql() ([]byte, error) {
|
||||
return bindata_read(
|
||||
__000012_match_column_collation_up_sql,
|
||||
"000012_match_column_collation.up.sql",
|
||||
)
|
||||
}
|
||||
|
||||
// Asset loads and returns the asset for the given name.
|
||||
// It returns an error if the asset could not be found or
|
||||
// could not be loaded.
|
||||
|
@ -267,6 +285,8 @@ var _bindata = map[string]func() ([]byte, error){
|
|||
"000010_blocks_created_by.up.sql": _000010_blocks_created_by_up_sql,
|
||||
"000011_match_collation.down.sql": _000011_match_collation_down_sql,
|
||||
"000011_match_collation.up.sql": _000011_match_collation_up_sql,
|
||||
"000012_match_column_collation.down.sql": _000012_match_column_collation_down_sql,
|
||||
"000012_match_column_collation.up.sql": _000012_match_column_collation_up_sql,
|
||||
}
|
||||
// AssetDir returns the file names below a certain
|
||||
// directory embedded in the file by go-bindata.
|
||||
|
@ -352,4 +372,8 @@ var _bintree = &_bintree_t{nil, map[string]*_bintree_t{
|
|||
}},
|
||||
"000011_match_collation.up.sql": &_bintree_t{_000011_match_collation_up_sql, map[string]*_bintree_t{
|
||||
}},
|
||||
"000012_match_column_collation.down.sql": &_bintree_t{_000012_match_column_collation_down_sql, map[string]*_bintree_t{
|
||||
}},
|
||||
"000012_match_column_collation.up.sql": &_bintree_t{_000012_match_column_collation_up_sql, map[string]*_bintree_t{
|
||||
}},
|
||||
}}
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
-- Nothing to be done here
|
||||
-- This page is intentionally left blank
|
||||
SELECT 1;
|
|
@ -0,0 +1,54 @@
|
|||
{{if and .mysql .plugin}}
|
||||
-- this migration applies collation on column level.
|
||||
-- collation of mattermost's Channels table
|
||||
SET @mattermostCollation = (SELECT table_collation from information_schema.tables WHERE table_name = 'Channels' AND table_schema = (SELECT DATABASE()));
|
||||
-- charset of mattermost's CHannels table's Name column
|
||||
SET @mattermostCharset = (SELECT CHARACTER_SET_NAME from information_schema.columns WHERE table_name = 'Channels' AND table_schema = (SELECT DATABASE()) AND COLUMN_NAME = 'Name');
|
||||
|
||||
-- blocks
|
||||
SET @updateCollationQuery = CONCAT('ALTER TABLE {{.prefix}}blocks CONVERT TO CHARACTER SET ', @mattermostCharset, ' COLLATE ', @mattermostCollation);
|
||||
PREPARE stmt FROM @updateCollationQuery;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- blocks history
|
||||
SET @updateCollationQuery = CONCAT('ALTER TABLE {{.prefix}}blocks_history CONVERT TO CHARACTER SET ', @mattermostCharset, ' COLLATE ', @mattermostCollation);
|
||||
PREPARE stmt FROM @updateCollationQuery;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- sessions
|
||||
SET @updateCollationQuery = CONCAT('ALTER TABLE {{.prefix}}sessions CONVERT TO CHARACTER SET ', @mattermostCharset, ' COLLATE ', @mattermostCollation);
|
||||
PREPARE stmt FROM @updateCollationQuery;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- sharing
|
||||
SET @updateCollationQuery = CONCAT('ALTER TABLE {{.prefix}}sharing CONVERT TO CHARACTER SET ', @mattermostCharset, ' COLLATE ', @mattermostCollation);
|
||||
PREPARE stmt FROM @updateCollationQuery;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- system settings
|
||||
SET @updateCollationQuery = CONCAT('ALTER TABLE {{.prefix}}system_settings CONVERT TO CHARACTER SET ', @mattermostCharset, ' COLLATE ', @mattermostCollation);
|
||||
PREPARE stmt FROM @updateCollationQuery;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- users
|
||||
SET @updateCollationQuery = CONCAT('ALTER TABLE {{.prefix}}users CONVERT TO CHARACTER SET ', @mattermostCharset, ' COLLATE ', @mattermostCollation);
|
||||
PREPARE stmt FROM @updateCollationQuery;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- workspaces
|
||||
SET @updateCollationQuery = CONCAT('ALTER TABLE {{.prefix}}workspaces CONVERT TO CHARACTER SET ', @mattermostCharset, ' COLLATE ', @mattermostCollation);
|
||||
PREPARE stmt FROM @updateCollationQuery;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
{{else}}
|
||||
-- We need a query here otherwise the migration will result
|
||||
-- in an empty query when the if condition is false.
|
||||
-- Empty query causes a "Query was empty" error.
|
||||
SELECT 1;
|
||||
{{end}}
|
Loading…
Reference in a new issue