db: change the encoding and collation

by mistake many fields are encoded at utf8 which is an alias of utf8mb3

fixes #836
This commit is contained in:
Girish Ramakrishnan
2025-06-18 20:55:14 +02:00
parent 0c0610c6c5
commit b23699f0c1
3 changed files with 43 additions and 8 deletions

View File

@@ -2,7 +2,7 @@
#### This file is not used by any code and is here to document the latest schema
#### General ideas
#### Default char set is utf8 and DEFAULT COLLATE is utf8_bin. Collate affects comparisons in WHERE and ORDER
#### Default char set is utf8mb4 and DEFAULT COLLATE is utf8mb4_bin. Collate affects comparisons in WHERE and ORDER
#### Strict mode is enabled
#### VARCHAR - stored as part of table row (use for strings)
#### TEXT - stored offline from table row (use for strings)
@@ -193,10 +193,7 @@ CREATE TABLE IF NOT EXISTS domains(
fallbackCertificateJson MEDIUMTEXT,
PRIMARY KEY (domain))
/* the default db collation is utf8mb4_unicode_ci but for the app table domain constraint we have to use the old one */
CHARACTER SET utf8 COLLATE utf8_bin;
PRIMARY KEY (domain));
CREATE TABLE IF NOT EXISTS mail(
domain VARCHAR(128) NOT NULL UNIQUE,
@@ -211,9 +208,7 @@ CREATE TABLE IF NOT EXISTS mail(
dkimSelector VARCHAR(128) NOT NULL DEFAULT "cloudron",
FOREIGN KEY(domain) REFERENCES domains(domain),
PRIMARY KEY(domain))
CHARACTER SET utf8 COLLATE utf8_bin;
PRIMARY KEY(domain));
/* NOTE: this table contains only real mailboxes. And has unique constraint to handle
conflict with aliases and mailbox names