-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema-template.sql
35 lines (24 loc) · 1.1 KB
/
schema-template.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
CREATE DATABASE IF NOT EXISTS <MYSQL_DATABASE> ;
-- Write the queries needed to create to the schema
-- Create users
CREATE USER IF NOT EXISTS '<MYSQL_USER>' @'%' IDENTIFIED BY '<MYSQL_PASSWORD>';
GRANT SELECT, INSERT, UPDATE, DELETE ON collab.* TO '<MYSQL_USER>'@'%';
-- Create Tables
CREATE TABLE users (
roomId VARCHAR(255) NOT NULL,
secret VARCHAR(255) NOT NULL,
username VARCHAR(255) NOT NULL,
PRIMARY KEY (roomId, username)
);
-- Create health check tables
-- Create the 'health_check' table
CREATE TABLE IF NOT EXISTS <MYSQL_DATABASE>.<MYSQL_HEALTH_TABLE> (
id INT AUTO_INCREMENT PRIMARY KEY,
value INT
);
-- Generate 5 rows of random data
INSERT INTO <MYSQL_DATABASE>.<MYSQL_HEALTH_TABLE> (value) VALUES (FLOOR(RAND() * 100));
INSERT INTO <MYSQL_DATABASE>.<MYSQL_HEALTH_TABLE> (value) VALUES (FLOOR(RAND() * 100));
INSERT INTO <MYSQL_DATABASE>.<MYSQL_HEALTH_TABLE> (value) VALUES (FLOOR(RAND() * 100));
INSERT INTO <MYSQL_DATABASE>.<MYSQL_HEALTH_TABLE> (value) VALUES (FLOOR(RAND() * 100));
INSERT INTO <MYSQL_DATABASE>.<MYSQL_HEALTH_TABLE> (value) VALUES (FLOOR(RAND() * 100));