46 lines
1.3 KiB
PHP
46 lines
1.3 KiB
PHP
<?php
|
|
|
|
include "config.php";
|
|
|
|
$queries = array(
|
|
"CREATE TABLE IF NOT EXISTS users (
|
|
id VARCHAR(64) PRIMARY KEY,
|
|
username VARCHAR(64) UNIQUE NOT NULL,
|
|
password_hash VARCHAR(256) NOT NULL,
|
|
enable_colors BOOLEAN NOT NULL,
|
|
yellow_threshold INT NOT NULL,
|
|
gray_threshold INT NOT NULL
|
|
);",
|
|
"CREATE TABLE IF NOT EXISTS section (
|
|
id VARCHAR(64) PRIMARY KEY,
|
|
users VARCHAR(64) NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
|
name VARCHAR(128),
|
|
show_subtitle BOOLEAN NOT NULL -- whether or not to separately show the name of the first item
|
|
);",
|
|
"CREATE TABLE IF NOT EXISTS row (
|
|
id VARCHAR(64) PRIMARY KEY,
|
|
section VARCHAR(64) NOT NULL REFERENCES section(id) ON DELETE CASCADE,
|
|
name VARCHAR(128), -- ignored if first item and show_subtitle is enabled
|
|
display_format VARCHAR(128) NOT NULL -- %t - date, %d - description, %C - start color, %c - end color
|
|
);",
|
|
"CREATE TABLE IF NOT EXISTS item (
|
|
id VARCHAR(64) PRIMARY KEY,
|
|
row VARCHAR(64) NOT NULL REFERENCES row(id) ON DELETE CASCADE,
|
|
description VARCHAR(256) NOT NULL,
|
|
date DATE NOT NULL
|
|
);",
|
|
"CREATE TABLE IF NOT EXISTS invites (
|
|
id VARCHAR(64) PRIMARY KEY
|
|
);"
|
|
);
|
|
|
|
foreach($queries as $q) {
|
|
if (!pg_query($db, $q)) {
|
|
echo "uh oh" . pg_last_error($db);
|
|
exit();
|
|
}
|
|
}
|
|
|
|
echo "ok :verygood:";
|
|
|
|
?>
|