database: make it work with utf8mb4

Going forward, BOINC databases should use char encoding utf8mb4
and collation utf8mb4-unicode-ci.
Each char can then be up to 4 bytes.
MariaDB/InnoDB has a limit of 767 bytes on index keys.
That means a limit of 191 chars on indexed fields.
Change the size of such fields from 255 to 191
(in some cases less, where indices involve other fields too).

create_project: use utf8mb4.

This change does not affect existing projects.
This commit is contained in:
David Anderson 2024-08-08 22:25:36 -07:00 committed by Vitalii Koshura
parent f440acd522
commit 90392c3882
No known key found for this signature in database
GPG Key ID: CE0DB1726070A5A3
2 changed files with 15 additions and 15 deletions

View File

@ -46,7 +46,7 @@
create table platform ( create table platform (
id integer not null auto_increment, id integer not null auto_increment,
create_time integer not null, create_time integer not null,
name varchar(254) not null, name varchar(191) not null,
user_friendly_name varchar(254) not null, user_friendly_name varchar(254) not null,
deprecated tinyint not null default 0, deprecated tinyint not null default 0,
primary key (id) primary key (id)
@ -55,7 +55,7 @@ create table platform (
create table app ( create table app (
id integer not null auto_increment, id integer not null auto_increment,
create_time integer not null, create_time integer not null,
name varchar(254) not null, name varchar(191) not null,
min_version integer not null default 0, min_version integer not null default 0,
deprecated smallint not null default 0, deprecated smallint not null default 0,
user_friendly_name varchar(254) not null, user_friendly_name varchar(254) not null,
@ -83,7 +83,7 @@ create table app_version (
min_core_version integer not null default 0, min_core_version integer not null default 0,
max_core_version integer not null default 0, max_core_version integer not null default 0,
deprecated tinyint not null default 0, deprecated tinyint not null default 0,
plan_class varchar(254) not null default '', plan_class varchar(128) not null default '',
pfc_n double not null default 0, pfc_n double not null default 0,
pfc_avg double not null default 0, pfc_avg double not null default 0,
pfc_scale double not null default 0, pfc_scale double not null default 0,
@ -96,9 +96,9 @@ create table app_version (
create table user ( create table user (
id integer not null auto_increment, id integer not null auto_increment,
create_time integer not null, create_time integer not null,
email_addr varchar(254) not null, email_addr varchar(191) not null,
name varchar(254), name varchar(191),
authenticator varchar(254), authenticator varchar(191),
country varchar(254), country varchar(254),
postal_code varchar(254), postal_code varchar(254),
total_credit double not null, total_credit double not null,
@ -139,7 +139,7 @@ create table team (
id integer not null auto_increment, id integer not null auto_increment,
create_time integer not null, create_time integer not null,
userid integer not null, userid integer not null,
name varchar(254) not null, name varchar(191) not null,
name_lc varchar(254), name_lc varchar(254),
url varchar(254), url varchar(254),
type integer not null, type integer not null,
@ -249,7 +249,7 @@ create table workunit (
id integer not null auto_increment, id integer not null auto_increment,
create_time integer not null, create_time integer not null,
appid integer not null, appid integer not null,
name varchar(254) not null, name varchar(191) not null,
xml_doc blob, xml_doc blob,
batch integer not null, batch integer not null,
rsc_fpops_est double not null, rsc_fpops_est double not null,
@ -296,7 +296,7 @@ create table result (
report_deadline integer not null, report_deadline integer not null,
sent_time integer not null, sent_time integer not null,
received_time integer not null, received_time integer not null,
name varchar(254) not null, name varchar(191) not null,
cpu_time double not null, cpu_time double not null,
xml_doc_in blob, xml_doc_in blob,
xml_doc_out blob, xml_doc_out blob,
@ -381,7 +381,7 @@ create table user_submit_app (
-- --
create table job_file ( create table job_file (
id integer not null auto_increment, id integer not null auto_increment,
name varchar(255) not null, name varchar(191) not null,
create_time double not null, create_time double not null,
delete_time double not null, delete_time double not null,
primary key (id) primary key (id)
@ -456,7 +456,7 @@ create table category (
-- order in which to display -- order in which to display
lang integer not null, lang integer not null,
-- not used -- not used
name varchar(254) binary, name varchar(180) not null,
is_helpdesk smallint not null, is_helpdesk smallint not null,
primary key (id) primary key (id)
) engine=InnoDB; ) engine=InnoDB;
@ -469,7 +469,7 @@ create table forum (
-- ID of entity to which this forum is attached. -- ID of entity to which this forum is attached.
-- The type (table) of the entity is determined by parent_type -- The type (table) of the entity is determined by parent_type
orderID integer not null, orderID integer not null,
title varchar(254) not null, title varchar(175) not null,
description varchar(254) not null, description varchar(254) not null,
timestamp integer not null default 0, timestamp integer not null default 0,
-- time of last new or modified thread or post -- time of last new or modified thread or post
@ -786,7 +786,7 @@ create table credit_team (
) engine=InnoDB; ) engine=InnoDB;
create table token ( create table token (
token varchar(255) not null, token varchar(64) not null,
userid integer not null, userid integer not null,
type char not null, type char not null,
create_time integer not null, create_time integer not null,
@ -821,7 +821,7 @@ create table consent (
create table consent_type ( create table consent_type (
id integer not null auto_increment, id integer not null auto_increment,
shortname varchar(255) not null, shortname varchar(191) not null,
description varchar(255) not null, description varchar(255) not null,
enabled integer not null, enabled integer not null,
project_specific integer not null, project_specific integer not null,

View File

@ -285,7 +285,7 @@ def create_database(srcdir, config = None, drop_first = False):
cursor = dbcon.cursor() cursor = dbcon.cursor()
if drop_first: if drop_first:
cursor.execute("drop database if exists %s"%config.db_name) cursor.execute("drop database if exists %s"%config.db_name)
cursor.execute("create database %s"%config.db_name) cursor.execute("create database %s character set utf8mb4 collate utf8mb4_unicode_ci"%config.db_name)
cursor.execute("use %s"%config.db_name) cursor.execute("use %s"%config.db_name)
for file in ['schema.sql', 'constraints.sql', 'content.sql']: for file in ['schema.sql', 'constraints.sql', 'content.sql']:
_execute_sql_script(cursor, os.path.join(srcdir, 'db', file)) _execute_sql_script(cursor, os.path.join(srcdir, 'db', file))