summaryrefslogtreecommitdiff
path: root/app/Schema
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-03-09 21:37:10 -0400
committerFrederic Guillot <fred@kanboard.net>2015-03-09 21:37:10 -0400
commitc870508923f62e90a81fe39d923d7776dd1e9634 (patch)
treef0c8966fe226b5c48730c29d3eaefb51a9010b8b /app/Schema
parent732899564517c6efd9ef965f3f843309a222ce50 (diff)
Add user timetables
Diffstat (limited to 'app/Schema')
-rw-r--r--app/Schema/Mysql.php48
-rw-r--r--app/Schema/Postgres.php46
-rw-r--r--app/Schema/Sqlite.php44
3 files changed, 134 insertions, 4 deletions
diff --git a/app/Schema/Mysql.php b/app/Schema/Mysql.php
index a4b8c25a..44ca7fd4 100644
--- a/app/Schema/Mysql.php
+++ b/app/Schema/Mysql.php
@@ -6,7 +6,53 @@ use PDO;
use Core\Security;
use Model\Link;
-const VERSION = 50;
+const VERSION = 51;
+
+function version_51($pdo)
+{
+ $pdo->exec('CREATE TABLE timetable_day (
+ id INT NOT NULL AUTO_INCREMENT,
+ user_id INT NOT NULL,
+ start VARCHAR(5) NOT NULL,
+ end VARCHAR(5) NOT NULL,
+ FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE,
+ PRIMARY KEY(id)
+ ) ENGINE=InnoDB CHARSET=utf8');
+
+ $pdo->exec('CREATE TABLE timetable_week (
+ id INT NOT NULL AUTO_INCREMENT,
+ user_id INTEGER NOT NULL,
+ day INT NOT NULL,
+ start VARCHAR(5) NOT NULL,
+ end VARCHAR(5) NOT NULL,
+ FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE,
+ PRIMARY KEY(id)
+ ) ENGINE=InnoDB CHARSET=utf8');
+
+ $pdo->exec('CREATE TABLE timetable_off (
+ id INT NOT NULL AUTO_INCREMENT,
+ user_id INT NOT NULL,
+ date VARCHAR(10) NOT NULL,
+ all_day TINYINT(1) DEFAULT 0,
+ start VARCHAR(5) DEFAULT 0,
+ end VARCHAR(5) DEFAULT 0,
+ comment TEXT,
+ FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE,
+ PRIMARY KEY(id)
+ ) ENGINE=InnoDB CHARSET=utf8');
+
+ $pdo->exec('CREATE TABLE timetable_extra (
+ id INT NOT NULL AUTO_INCREMENT,
+ user_id INT NOT NULL,
+ date VARCHAR(10) NOT NULL,
+ all_day TINYINT(1) DEFAULT 0,
+ start VARCHAR(5) DEFAULT 0,
+ end VARCHAR(5) DEFAULT 0,
+ comment TEXT,
+ FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE,
+ PRIMARY KEY(id)
+ ) ENGINE=InnoDB CHARSET=utf8');
+}
function version_50($pdo)
{
diff --git a/app/Schema/Postgres.php b/app/Schema/Postgres.php
index 7054bca2..fe01b1e9 100644
--- a/app/Schema/Postgres.php
+++ b/app/Schema/Postgres.php
@@ -6,12 +6,54 @@ use PDO;
use Core\Security;
use Model\Link;
-const VERSION = 31;
+const VERSION = 32;
+
+function version_32($pdo)
+{
+ $pdo->exec('CREATE TABLE timetable_day (
+ "id" SERIAL PRIMARY KEY,
+ "user_id" INTEGER NOT NULL,
+ "start" VARCHAR(5) NOT NULL,
+ "end" VARCHAR(5) NOT NULL,
+ FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE
+ )');
+
+ $pdo->exec('CREATE TABLE timetable_week (
+ "id" SERIAL PRIMARY KEY,
+ "user_id" INTEGER NOT NULL,
+ "day" INTEGER NOT NULL,
+ "start" VARCHAR(5) NOT NULL,
+ "end" VARCHAR(5) NOT NULL,
+ FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE
+ )');
+
+ $pdo->exec('CREATE TABLE timetable_off (
+ "id" SERIAL PRIMARY KEY,
+ "user_id" INTEGER NOT NULL,
+ "date" VARCHAR(10) NOT NULL,
+ "all_day" BOOLEAN DEFAULT \'0\',
+ "start" VARCHAR(5) DEFAULT 0,
+ "end" VARCHAR(5) DEFAULT 0,
+ "comment" TEXT,
+ FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE
+ )');
+
+ $pdo->exec('CREATE TABLE timetable_extra (
+ "id" SERIAL PRIMARY KEY,
+ "user_id" INTEGER NOT NULL,
+ "date" VARCHAR(10) NOT NULL,
+ "all_day" BOOLEAN DEFAULT \'0\',
+ "start" VARCHAR(5) DEFAULT 0,
+ "end" VARCHAR(5) DEFAULT 0,
+ "comment" TEXT,
+ FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE
+ )');
+}
function version_31($pdo)
{
$pdo->exec("CREATE TABLE hourly_rates (
- id SERIAL,
+ id SERIAL PRIMARY KEY,
user_id INTEGER NOT NULL,
rate REAL DEFAULT 0,
date_effective INTEGER NOT NULL,
diff --git a/app/Schema/Sqlite.php b/app/Schema/Sqlite.php
index a389fc17..eaa5c734 100644
--- a/app/Schema/Sqlite.php
+++ b/app/Schema/Sqlite.php
@@ -6,7 +6,49 @@ use Core\Security;
use PDO;
use Model\Link;
-const VERSION = 49;
+const VERSION = 50;
+
+function version_50($pdo)
+{
+ $pdo->exec('CREATE TABLE timetable_day (
+ "id" INTEGER PRIMARY KEY,
+ "user_id" INTEGER NOT NULL,
+ "start" TEXT NOT NULL,
+ "end" TEXT NOT NULL,
+ FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE
+ )');
+
+ $pdo->exec('CREATE TABLE timetable_week (
+ "id" INTEGER PRIMARY KEY,
+ "user_id" INTEGER NOT NULL,
+ "day" INTEGER NOT NULL,
+ "start" TEXT NOT NULL,
+ "end" TEXT NOT NULL,
+ FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE
+ )');
+
+ $pdo->exec('CREATE TABLE timetable_off (
+ "id" INTEGER PRIMARY KEY,
+ "user_id" INTEGER NOT NULL,
+ "date" TEXT NOT NULL,
+ "all_day" INTEGER DEFAULT 0,
+ "start" TEXT DEFAULT 0,
+ "end" TEXT DEFAULT 0,
+ "comment" TEXT,
+ FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE
+ )');
+
+ $pdo->exec('CREATE TABLE timetable_extra (
+ "id" INTEGER PRIMARY KEY,
+ "user_id" INTEGER NOT NULL,
+ "date" TEXT NOT NULL,
+ "all_day" INTEGER DEFAULT 0,
+ "start" TEXT DEFAULT 0,
+ "end" TEXT DEFAULT 0,
+ "comment" TEXT,
+ FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE
+ )');
+}
function version_49($pdo)
{