diff options
Diffstat (limited to 'app/Schema')
-rw-r--r-- | app/Schema/Mysql.php | 17 | ||||
-rw-r--r-- | app/Schema/Postgres.php | 17 | ||||
-rw-r--r-- | app/Schema/Sqlite.php | 17 |
3 files changed, 48 insertions, 3 deletions
diff --git a/app/Schema/Mysql.php b/app/Schema/Mysql.php index 46fc6d43..8f3ae5a1 100644 --- a/app/Schema/Mysql.php +++ b/app/Schema/Mysql.php @@ -4,7 +4,22 @@ namespace Schema; use Core\Security; -const VERSION = 22; +const VERSION = 23; + +function version_23($pdo) +{ + $pdo->exec("ALTER TABLE users ADD COLUMN notifications_enabled TINYINT(1) DEFAULT '0'"); + + $pdo->exec(" + CREATE TABLE user_has_notifications ( + user_id INT, + project_id INT, + FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE, + FOREIGN KEY(project_id) REFERENCES projects(id) ON DELETE CASCADE, + UNIQUE(project_id, user_id) + ); + "); +} function version_22($pdo) { diff --git a/app/Schema/Postgres.php b/app/Schema/Postgres.php index a9eea531..ce77a4ed 100644 --- a/app/Schema/Postgres.php +++ b/app/Schema/Postgres.php @@ -4,7 +4,22 @@ namespace Schema; use Core\Security; -const VERSION = 3; +const VERSION = 4; + +function version_4($pdo) +{ + $pdo->exec("ALTER TABLE users ADD COLUMN notifications_enabled BOOLEAN DEFAULT '0'"); + + $pdo->exec(" + CREATE TABLE user_has_notifications ( + user_id INTEGER, + project_id INTEGER, + FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE, + FOREIGN KEY(project_id) REFERENCES projects(id) ON DELETE CASCADE, + UNIQUE(project_id, user_id) + ); + "); +} function version_3($pdo) { diff --git a/app/Schema/Sqlite.php b/app/Schema/Sqlite.php index 4660251f..c3a3f10e 100644 --- a/app/Schema/Sqlite.php +++ b/app/Schema/Sqlite.php @@ -4,7 +4,22 @@ namespace Schema; use Core\Security; -const VERSION = 22; +const VERSION = 23; + +function version_23($pdo) +{ + $pdo->exec("ALTER TABLE users ADD COLUMN notifications_enabled INTEGER DEFAULT '0'"); + + $pdo->exec(" + CREATE TABLE user_has_notifications ( + user_id INTEGER, + project_id INTEGER, + FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE, + FOREIGN KEY(project_id) REFERENCES projects(id) ON DELETE CASCADE, + UNIQUE(project_id, user_id) + ); + "); +} function version_22($pdo) { |