Skip to content

Commit 87ba522

Browse files
committed
switch collation
1 parent 34590f8 commit 87ba522

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

backend/utils/db-init.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ async function initializeTables(connection) {
2222
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
2323
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
2424
UNIQUE KEY unique_provider_name (name)
25-
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
25+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2626
`);
2727

2828
// Create workshops table (OpenStack projects)
@@ -41,7 +41,7 @@ async function initializeTables(connection) {
4141
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
4242
UNIQUE KEY unique_workshop_name (name),
4343
FOREIGN KEY (provider_id) REFERENCES providers(id) ON DELETE CASCADE
44-
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
44+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4545
`);
4646

4747
// Ensure lockout window columns exist for existing deployments (MySQL variant without IF NOT EXISTS)
@@ -82,7 +82,7 @@ async function initializeTables(connection) {
8282
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
8383
UNIQUE KEY unique_team_workshop (workshop_id, team_number),
8484
FOREIGN KEY (workshop_id) REFERENCES workshops(id) ON DELETE CASCADE
85-
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
85+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
8686
`);
8787

8888
// Create users table
@@ -104,7 +104,7 @@ async function initializeTables(connection) {
104104
UNIQUE KEY unique_username (username),
105105
UNIQUE KEY unique_email (email),
106106
UNIQUE KEY unique_openid_sub (openid_sub)
107-
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
107+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
108108
`);
109109

110110
// Create user_teams table (many-to-many relationship)
@@ -117,7 +117,7 @@ async function initializeTables(connection) {
117117
UNIQUE KEY unique_user_team (user_id, team_id),
118118
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
119119
FOREIGN KEY (team_id) REFERENCES teams(id) ON DELETE CASCADE
120-
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
120+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
121121
`);
122122

123123
// Create temp_user_team table for storing team assignments for non-existent users
@@ -129,7 +129,7 @@ async function initializeTables(connection) {
129129
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
130130
UNIQUE KEY unique_email_team (email, team_id),
131131
FOREIGN KEY (team_id) REFERENCES teams(id) ON DELETE CASCADE
132-
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
132+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
133133
`);
134134

135135
// Create instances table (VMs)
@@ -153,7 +153,7 @@ async function initializeTables(connection) {
153153
FOREIGN KEY (workshop_id) REFERENCES workshops(id) ON DELETE CASCADE,
154154
FOREIGN KEY (team_id) REFERENCES teams(id) ON DELETE SET NULL,
155155
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE SET NULL
156-
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
156+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
157157
`);
158158

159159
// Create sessions table for VNC connections
@@ -168,7 +168,7 @@ async function initializeTables(connection) {
168168
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
169169
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
170170
FOREIGN KEY (instance_id) REFERENCES instances(id) ON DELETE CASCADE
171-
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
171+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
172172
`);
173173

174174

@@ -184,7 +184,7 @@ async function initializeTables(connection) {
184184
ip_address VARCHAR(45),
185185
timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
186186
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE SET NULL
187-
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
187+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
188188
`);
189189

190190
// Create service_accounts table
@@ -197,7 +197,7 @@ async function initializeTables(connection) {
197197
last_used TIMESTAMP NULL,
198198
enabled BOOLEAN DEFAULT true,
199199
UNIQUE KEY unique_api_key (api_key)
200-
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
200+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
201201
`);
202202

203203
console.log('✓ Database tables created successfully');

0 commit comments

Comments
 (0)