summaryrefslogtreecommitdiff
path: root/app/Schema
diff options
context:
space:
mode:
authorGerardo Zamudio <gerardozamudio@users.noreply.github.com>2016-02-24 23:48:50 -0600
committerGerardo Zamudio <gerardozamudio@users.noreply.github.com>2016-02-24 23:48:50 -0600
commite4de6b3898b64b26d29aff31f21df5fda8055686 (patch)
tree575f8a65440f291d70a070d168eafca8c82a6459 /app/Schema
parentd9ffbea174ea6524d0a22f8375ca8b3aa04a3c96 (diff)
parenta6540bc604c837d92c9368540c145606723e97f7 (diff)
Merge pull request #1 from fguillot/master
Update from upstream
Diffstat (limited to 'app/Schema')
-rw-r--r--app/Schema/Mysql.php212
-rw-r--r--app/Schema/Postgres.php206
-rw-r--r--app/Schema/Sql/mysql.sql101
-rw-r--r--app/Schema/Sql/postgres.sql283
-rw-r--r--app/Schema/Sqlite.php186
5 files changed, 893 insertions, 95 deletions
diff --git a/app/Schema/Mysql.php b/app/Schema/Mysql.php
index a021c1cc..9a551e99 100644
--- a/app/Schema/Mysql.php
+++ b/app/Schema/Mysql.php
@@ -3,9 +3,209 @@
namespace Schema;
use PDO;
-use Kanboard\Core\Security;
+use Kanboard\Core\Security\Token;
+use Kanboard\Core\Security\Role;
-const VERSION = 93;
+const VERSION = 107;
+
+function version_107(PDO $pdo)
+{
+ $pdo->exec("UPDATE project_activities SET event_name='task.file.create' WHERE event_name='file.create'");
+}
+
+function version_106(PDO $pdo)
+{
+ $pdo->exec('RENAME TABLE files TO task_has_files');
+
+ $pdo->exec("
+ CREATE TABLE project_has_files (
+ `id` INT NOT NULL AUTO_INCREMENT,
+ `project_id` INT NOT NULL,
+ `name` VARCHAR(255) NOT NULL,
+ `path` VARCHAR(255) NOT NULL,
+ `is_image` TINYINT(1) DEFAULT 0,
+ `size` INT DEFAULT 0 NOT NULL,
+ `user_id` INT DEFAULT 0 NOT NULL,
+ `date` INT DEFAULT 0 NOT NULL,
+ FOREIGN KEY(project_id) REFERENCES projects(id) ON DELETE CASCADE,
+ PRIMARY KEY(id)
+ ) ENGINE=InnoDB CHARSET=utf8"
+ );
+}
+
+function version_105(PDO $pdo)
+{
+ $pdo->exec("ALTER TABLE users ADD COLUMN is_active TINYINT(1) DEFAULT 1");
+}
+
+function version_104(PDO $pdo)
+{
+ $pdo->exec("
+ CREATE TABLE task_has_external_links (
+ id INT NOT NULL AUTO_INCREMENT,
+ link_type VARCHAR(100) NOT NULL,
+ dependency VARCHAR(100) NOT NULL,
+ title VARCHAR(255) NOT NULL,
+ url VARCHAR(255) NOT NULL,
+ date_creation INT NOT NULL,
+ date_modification INT NOT NULL,
+ task_id INT NOT NULL,
+ creator_id INT DEFAULT 0,
+ FOREIGN KEY(task_id) REFERENCES tasks(id) ON DELETE CASCADE,
+ PRIMARY KEY(id)
+ ) ENGINE=InnoDB CHARSET=utf8
+ ");
+}
+
+function version_103(PDO $pdo)
+{
+ $pdo->exec("ALTER TABLE projects ADD COLUMN priority_default INT DEFAULT 0");
+ $pdo->exec("ALTER TABLE projects ADD COLUMN priority_start INT DEFAULT 0");
+ $pdo->exec("ALTER TABLE projects ADD COLUMN priority_end INT DEFAULT 3");
+ $pdo->exec("ALTER TABLE tasks ADD COLUMN priority INT DEFAULT 0");
+}
+
+function version_102(PDO $pdo)
+{
+ $pdo->exec("ALTER TABLE projects ADD COLUMN owner_id INT DEFAULT 0");
+}
+
+function version_101(PDO $pdo)
+{
+ $pdo->exec("
+ CREATE TABLE password_reset (
+ token VARCHAR(80) PRIMARY KEY,
+ user_id INT NOT NULL,
+ date_expiration INT NOT NULL,
+ date_creation INT NOT NULL,
+ ip VARCHAR(45) NOT NULL,
+ user_agent VARCHAR(255) NOT NULL,
+ is_active TINYINT(1) NOT NULL,
+ FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE
+ ) ENGINE=InnoDB CHARSET=utf8
+ ");
+
+ $pdo->exec("INSERT INTO settings VALUES ('password_reset', '1')");
+}
+
+function version_100(PDO $pdo)
+{
+ $pdo->exec('ALTER TABLE `actions` MODIFY `action_name` VARCHAR(255)');
+}
+
+function version_99(PDO $pdo)
+{
+ $rq = $pdo->prepare('SELECT * FROM actions');
+ $rq->execute();
+ $rows = $rq->fetchAll(PDO::FETCH_ASSOC) ?: array();
+
+ $rq = $pdo->prepare('UPDATE actions SET action_name=? WHERE id=?');
+
+ foreach ($rows as $row) {
+ if ($row['action_name'] === 'TaskAssignCurrentUser' && $row['event_name'] === 'task.move.column') {
+ $row['action_name'] = '\Kanboard\Action\TaskAssignCurrentUserColumn';
+ } elseif ($row['action_name'] === 'TaskClose' && $row['event_name'] === 'task.move.column') {
+ $row['action_name'] = '\Kanboard\Action\TaskCloseColumn';
+ } elseif ($row['action_name'] === 'TaskLogMoveAnotherColumn') {
+ $row['action_name'] = '\Kanboard\Action\CommentCreationMoveTaskColumn';
+ } elseif ($row['action_name']{0} !== '\\') {
+ $row['action_name'] = '\Kanboard\Action\\'.$row['action_name'];
+ }
+
+ $rq->execute(array($row['action_name'], $row['id']));
+ }
+}
+
+function version_98(PDO $pdo)
+{
+ $pdo->exec('ALTER TABLE `users` MODIFY `language` VARCHAR(5)');
+}
+
+function version_97(PDO $pdo)
+{
+ $pdo->exec("ALTER TABLE `users` ADD COLUMN `role` VARCHAR(25) NOT NULL DEFAULT '".Role::APP_USER."'");
+
+ $rq = $pdo->prepare('SELECT * FROM `users`');
+ $rq->execute();
+ $rows = $rq->fetchAll(PDO::FETCH_ASSOC) ?: array();
+
+ $rq = $pdo->prepare('UPDATE `users` SET `role`=? WHERE `id`=?');
+
+ foreach ($rows as $row) {
+ $role = Role::APP_USER;
+
+ if ($row['is_admin'] == 1) {
+ $role = Role::APP_ADMIN;
+ } else if ($row['is_project_admin']) {
+ $role = Role::APP_MANAGER;
+ }
+
+ $rq->execute(array($role, $row['id']));
+ }
+
+ $pdo->exec('ALTER TABLE `users` DROP COLUMN `is_admin`');
+ $pdo->exec('ALTER TABLE `users` DROP COLUMN `is_project_admin`');
+}
+
+function version_96(PDO $pdo)
+{
+ $pdo->exec("
+ CREATE TABLE project_has_groups (
+ `group_id` INT NOT NULL,
+ `project_id` INT NOT NULL,
+ `role` VARCHAR(25) NOT NULL,
+ FOREIGN KEY(group_id) REFERENCES groups(id) ON DELETE CASCADE,
+ FOREIGN KEY(project_id) REFERENCES projects(id) ON DELETE CASCADE,
+ UNIQUE(group_id, project_id)
+ ) ENGINE=InnoDB CHARSET=utf8
+ ");
+
+ $pdo->exec("ALTER TABLE `project_has_users` ADD COLUMN `role` VARCHAR(25) NOT NULL DEFAULT '".Role::PROJECT_VIEWER."'");
+
+ $rq = $pdo->prepare('SELECT * FROM project_has_users');
+ $rq->execute();
+ $rows = $rq->fetchAll(PDO::FETCH_ASSOC) ?: array();
+
+ $rq = $pdo->prepare('UPDATE `project_has_users` SET `role`=? WHERE `id`=?');
+
+ foreach ($rows as $row) {
+ $rq->execute(array(
+ $row['is_owner'] == 1 ? Role::PROJECT_MANAGER : Role::PROJECT_MEMBER,
+ $row['id'],
+ ));
+ }
+
+ $pdo->exec('ALTER TABLE `project_has_users` DROP COLUMN `is_owner`');
+ $pdo->exec('ALTER TABLE `project_has_users` DROP COLUMN `id`');
+}
+
+function version_95(PDO $pdo)
+{
+ $pdo->exec("
+ CREATE TABLE groups (
+ id INT NOT NULL AUTO_INCREMENT,
+ external_id VARCHAR(255) DEFAULT '',
+ name VARCHAR(100) NOT NULL UNIQUE,
+ PRIMARY KEY(id)
+ ) ENGINE=InnoDB CHARSET=utf8
+ ");
+
+ $pdo->exec("
+ CREATE TABLE group_has_users (
+ group_id INT NOT NULL,
+ user_id INT NOT NULL,
+ FOREIGN KEY(group_id) REFERENCES groups(id) ON DELETE CASCADE,
+ FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE,
+ UNIQUE(group_id, user_id)
+ ) ENGINE=InnoDB CHARSET=utf8
+ ");
+}
+
+function version_94(PDO $pdo)
+{
+ $pdo->exec('ALTER TABLE `projects` DROP INDEX `name`');
+ $pdo->exec('ALTER TABLE `projects` DROP INDEX `name_2`');
+}
function version_93(PDO $pdo)
{
@@ -869,7 +1069,7 @@ function version_20(PDO $pdo)
function version_19(PDO $pdo)
{
$pdo->exec("ALTER TABLE config ADD COLUMN api_token VARCHAR(255) DEFAULT ''");
- $pdo->exec("UPDATE config SET api_token='".Security::generateToken()."'");
+ $pdo->exec("UPDATE config SET api_token='".Token::getToken()."'");
}
function version_18(PDO $pdo)
@@ -943,7 +1143,7 @@ function version_12(PDO $pdo)
CREATE TABLE remember_me (
id INT NOT NULL AUTO_INCREMENT,
user_id INT,
- ip VARCHAR(40),
+ ip VARCHAR(45),
user_agent VARCHAR(255),
token VARCHAR(255),
sequence VARCHAR(255),
@@ -959,7 +1159,7 @@ function version_12(PDO $pdo)
id INT NOT NULL AUTO_INCREMENT,
auth_type VARCHAR(25),
user_id INT,
- ip VARCHAR(40),
+ ip VARCHAR(45),
user_agent VARCHAR(255),
date_creation INT,
FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE,
@@ -1091,6 +1291,6 @@ function version_1(PDO $pdo)
$pdo->exec("
INSERT INTO config
(webhooks_token)
- VALUES ('".Security::generateToken()."')
+ VALUES ('".Token::getToken()."')
");
}
diff --git a/app/Schema/Postgres.php b/app/Schema/Postgres.php
index a3fb6d49..6aed1491 100644
--- a/app/Schema/Postgres.php
+++ b/app/Schema/Postgres.php
@@ -3,9 +3,205 @@
namespace Schema;
use PDO;
-use Kanboard\Core\Security;
+use Kanboard\Core\Security\Token;
+use Kanboard\Core\Security\Role;
-const VERSION = 73;
+const VERSION = 87;
+
+function version_87(PDO $pdo)
+{
+ $pdo->exec("UPDATE project_activities SET event_name='task.file.create' WHERE event_name='file.create'");
+}
+
+function version_86(PDO $pdo)
+{
+ $pdo->exec('ALTER TABLE files RENAME TO task_has_files');
+
+ $pdo->exec("
+ CREATE TABLE project_has_files (
+ id SERIAL PRIMARY KEY,
+ project_id INTEGER NOT NULL,
+ name VARCHAR(255) NOT NULL,
+ path VARCHAR(255) NOT NULL,
+ is_image BOOLEAN DEFAULT '0',
+ size INTEGER DEFAULT 0 NOT NULL,
+ user_id INTEGER DEFAULT 0 NOT NULL,
+ date INTEGER DEFAULT 0 NOT NULL,
+ FOREIGN KEY(project_id) REFERENCES projects(id) ON DELETE CASCADE
+ )"
+ );
+}
+
+function version_85(PDO $pdo)
+{
+ $pdo->exec("ALTER TABLE users ADD COLUMN is_active BOOLEAN DEFAULT '1'");
+}
+
+function version_84(PDO $pdo)
+{
+ $pdo->exec("
+ CREATE TABLE task_has_external_links (
+ id SERIAL PRIMARY KEY,
+ link_type VARCHAR(100) NOT NULL,
+ dependency VARCHAR(100) NOT NULL,
+ title VARCHAR(255) NOT NULL,
+ url VARCHAR(255) NOT NULL,
+ date_creation INT NOT NULL,
+ date_modification INT NOT NULL,
+ task_id INT NOT NULL,
+ creator_id INT DEFAULT 0,
+ FOREIGN KEY(task_id) REFERENCES tasks(id) ON DELETE CASCADE
+ )
+ ");
+}
+
+function version_83(PDO $pdo)
+{
+ $pdo->exec("ALTER TABLE projects ADD COLUMN priority_default INTEGER DEFAULT 0");
+ $pdo->exec("ALTER TABLE projects ADD COLUMN priority_start INTEGER DEFAULT 0");
+ $pdo->exec("ALTER TABLE projects ADD COLUMN priority_end INTEGER DEFAULT 3");
+ $pdo->exec("ALTER TABLE tasks ADD COLUMN priority INTEGER DEFAULT 0");
+}
+
+function version_82(PDO $pdo)
+{
+ $pdo->exec("ALTER TABLE projects ADD COLUMN owner_id INTEGER DEFAULT 0");
+}
+
+function version_81(PDO $pdo)
+{
+ $pdo->exec("
+ CREATE TABLE password_reset (
+ token VARCHAR(80) PRIMARY KEY,
+ user_id INTEGER NOT NULL,
+ date_expiration INTEGER NOT NULL,
+ date_creation INTEGER NOT NULL,
+ ip VARCHAR(45) NOT NULL,
+ user_agent VARCHAR(255) NOT NULL,
+ is_active BOOLEAN NOT NULL,
+ FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE
+ )
+ ");
+
+ $pdo->exec("INSERT INTO settings VALUES ('password_reset', '1')");
+}
+
+function version_80(PDO $pdo)
+{
+ $pdo->exec('ALTER TABLE "actions" ALTER COLUMN "action_name" TYPE VARCHAR(255)');
+}
+
+function version_79(PDO $pdo)
+{
+ $rq = $pdo->prepare('SELECT * FROM actions');
+ $rq->execute();
+ $rows = $rq->fetchAll(PDO::FETCH_ASSOC) ?: array();
+
+ $rq = $pdo->prepare('UPDATE actions SET action_name=? WHERE id=?');
+
+ foreach ($rows as $row) {
+ if ($row['action_name'] === 'TaskAssignCurrentUser' && $row['event_name'] === 'task.move.column') {
+ $row['action_name'] = '\Kanboard\Action\TaskAssignCurrentUserColumn';
+ } elseif ($row['action_name'] === 'TaskClose' && $row['event_name'] === 'task.move.column') {
+ $row['action_name'] = '\Kanboard\Action\TaskCloseColumn';
+ } elseif ($row['action_name'] === 'TaskLogMoveAnotherColumn') {
+ $row['action_name'] = '\Kanboard\Action\CommentCreationMoveTaskColumn';
+ } elseif ($row['action_name']{0} !== '\\') {
+ $row['action_name'] = '\Kanboard\Action\\'.$row['action_name'];
+ }
+
+ $rq->execute(array($row['action_name'], $row['id']));
+ }
+}
+
+function version_78(PDO $pdo)
+{
+ $pdo->exec('ALTER TABLE "users" ALTER COLUMN "language" TYPE VARCHAR(5)');
+}
+
+function version_77(PDO $pdo)
+{
+ $pdo->exec('ALTER TABLE "users" ADD COLUMN "role" VARCHAR(25) NOT NULL DEFAULT \''.Role::APP_USER.'\'');
+
+ $rq = $pdo->prepare('SELECT * FROM "users"');
+ $rq->execute();
+ $rows = $rq->fetchAll(PDO::FETCH_ASSOC) ?: array();
+
+ $rq = $pdo->prepare('UPDATE "users" SET "role"=? WHERE "id"=?');
+
+ foreach ($rows as $row) {
+ $role = Role::APP_USER;
+
+ if ($row['is_admin'] == 1) {
+ $role = Role::APP_ADMIN;
+ } else if ($row['is_project_admin']) {
+ $role = Role::APP_MANAGER;
+ }
+
+ $rq->execute(array($role, $row['id']));
+ }
+
+ $pdo->exec('ALTER TABLE users DROP COLUMN "is_admin"');
+ $pdo->exec('ALTER TABLE users DROP COLUMN "is_project_admin"');
+}
+
+function version_76(PDO $pdo)
+{
+ $pdo->exec("
+ CREATE TABLE project_has_groups (
+ group_id INTEGER NOT NULL,
+ project_id INTEGER NOT NULL,
+ role VARCHAR(25) NOT NULL,
+ FOREIGN KEY(group_id) REFERENCES groups(id) ON DELETE CASCADE,
+ FOREIGN KEY(project_id) REFERENCES projects(id) ON DELETE CASCADE,
+ UNIQUE(group_id, project_id)
+ )
+ ");
+
+ $pdo->exec("ALTER TABLE project_has_users ADD COLUMN role VARCHAR(25) NOT NULL DEFAULT '".Role::PROJECT_VIEWER."'");
+
+ $rq = $pdo->prepare('SELECT * FROM project_has_users');
+ $rq->execute();
+ $rows = $rq->fetchAll(PDO::FETCH_ASSOC) ?: array();
+
+ $rq = $pdo->prepare('UPDATE project_has_users SET "role"=? WHERE "id"=?');
+
+ foreach ($rows as $row) {
+ $rq->execute(array(
+ $row['is_owner'] == 1 ? Role::PROJECT_MANAGER : Role::PROJECT_MEMBER,
+ $row['id'],
+ ));
+ }
+
+ $pdo->exec('ALTER TABLE project_has_users DROP COLUMN "is_owner"');
+ $pdo->exec('ALTER TABLE project_has_users DROP COLUMN "id"');
+}
+
+function version_75(PDO $pdo)
+{
+ $pdo->exec("
+ CREATE TABLE groups (
+ id SERIAL PRIMARY KEY,
+ external_id VARCHAR(255) DEFAULT '',
+ name VARCHAR(100) NOT NULL UNIQUE
+ )
+ ");
+
+ $pdo->exec("
+ CREATE TABLE group_has_users (
+ group_id INTEGER NOT NULL,
+ user_id INTEGER NOT NULL,
+ FOREIGN KEY(group_id) REFERENCES groups(id) ON DELETE CASCADE,
+ FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE,
+ UNIQUE(group_id, user_id)
+ )
+ ");
+}
+
+function version_74(PDO $pdo)
+{
+ $pdo->exec('ALTER TABLE projects DROP CONSTRAINT IF EXISTS projects_name_key');
+}
function version_73(PDO $pdo)
{
@@ -865,7 +1061,7 @@ function version_1(PDO $pdo)
CREATE TABLE remember_me (
id SERIAL PRIMARY KEY,
user_id INTEGER,
- ip VARCHAR(40),
+ ip VARCHAR(45),
user_agent VARCHAR(255),
token VARCHAR(255),
sequence VARCHAR(255),
@@ -878,7 +1074,7 @@ function version_1(PDO $pdo)
id SERIAL PRIMARY KEY,
auth_type VARCHAR(25),
user_id INTEGER,
- ip VARCHAR(40),
+ ip VARCHAR(45),
user_agent VARCHAR(255),
date_creation INTEGER,
FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE
@@ -994,6 +1190,6 @@ function version_1(PDO $pdo)
$pdo->exec("
INSERT INTO config
(webhooks_token, api_token)
- VALUES ('".Security::generateToken()."', '".Security::generateToken()."')
+ VALUES ('".Token::getToken()."', '".Token::getToken()."')
");
}
diff --git a/app/Schema/Sql/mysql.sql b/app/Schema/Sql/mysql.sql
index bb87a6ca..ef219490 100644
--- a/app/Schema/Sql/mysql.sql
+++ b/app/Schema/Sql/mysql.sql
@@ -29,7 +29,7 @@ CREATE TABLE `actions` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`project_id` int(11) NOT NULL,
`event_name` varchar(50) NOT NULL,
- `action_name` varchar(50) NOT NULL,
+ `action_name` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `project_id` (`project_id`),
CONSTRAINT `actions_ibfk_1` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE CASCADE
@@ -112,6 +112,29 @@ CREATE TABLE `files` (
CONSTRAINT `files_ibfk_1` FOREIGN KEY (`task_id`) REFERENCES `tasks` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
+DROP TABLE IF EXISTS `group_has_users`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `group_has_users` (
+ `group_id` int(11) NOT NULL,
+ `user_id` int(11) NOT NULL,
+ UNIQUE KEY `group_id` (`group_id`,`user_id`),
+ KEY `user_id` (`user_id`),
+ CONSTRAINT `group_has_users_ibfk_1` FOREIGN KEY (`group_id`) REFERENCES `groups` (`id`) ON DELETE CASCADE,
+ CONSTRAINT `group_has_users_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+/*!40101 SET character_set_client = @saved_cs_client */;
+DROP TABLE IF EXISTS `groups`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `groups` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `external_id` varchar(255) DEFAULT '',
+ `name` varchar(100) NOT NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `name` (`name`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `last_logins`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
@@ -119,7 +142,7 @@ CREATE TABLE `last_logins` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`auth_type` varchar(25) DEFAULT NULL,
`user_id` int(11) DEFAULT NULL,
- `ip` varchar(40) DEFAULT NULL,
+ `ip` varchar(45) DEFAULT NULL,
`user_agent` varchar(255) DEFAULT NULL,
`date_creation` bigint(20) DEFAULT NULL,
PRIMARY KEY (`id`),
@@ -138,6 +161,22 @@ CREATE TABLE `links` (
UNIQUE KEY `label` (`label`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
+DROP TABLE IF EXISTS `password_reset`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `password_reset` (
+ `token` varchar(80) NOT NULL,
+ `user_id` int(11) NOT NULL,
+ `date_expiration` int(11) NOT NULL,
+ `date_creation` int(11) NOT NULL,
+ `ip` varchar(45) NOT NULL,
+ `user_agent` varchar(255) NOT NULL,
+ `is_active` tinyint(1) NOT NULL,
+ PRIMARY KEY (`token`),
+ KEY `user_id` (`user_id`),
+ CONSTRAINT `password_reset_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `plugin_schema_versions`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
@@ -214,6 +253,19 @@ CREATE TABLE `project_has_categories` (
CONSTRAINT `project_has_categories_ibfk_1` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
+DROP TABLE IF EXISTS `project_has_groups`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `project_has_groups` (
+ `group_id` int(11) NOT NULL,
+ `project_id` int(11) NOT NULL,
+ `role` varchar(25) NOT NULL,
+ UNIQUE KEY `group_id` (`group_id`,`project_id`),
+ KEY `project_id` (`project_id`),
+ CONSTRAINT `project_has_groups_ibfk_1` FOREIGN KEY (`group_id`) REFERENCES `groups` (`id`) ON DELETE CASCADE,
+ CONSTRAINT `project_has_groups_ibfk_2` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `project_has_metadata`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
@@ -241,11 +293,9 @@ DROP TABLE IF EXISTS `project_has_users`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `project_has_users` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
`project_id` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
- `is_owner` tinyint(1) DEFAULT '0',
- PRIMARY KEY (`id`),
+ `role` varchar(25) NOT NULL DEFAULT 'project-viewer',
UNIQUE KEY `idx_project_user` (`project_id`,`user_id`),
KEY `user_id` (`user_id`),
CONSTRAINT `project_has_users_ibfk_1` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE CASCADE,
@@ -270,9 +320,11 @@ CREATE TABLE `projects` (
`identifier` varchar(50) DEFAULT '',
`start_date` varchar(10) DEFAULT '',
`end_date` varchar(10) DEFAULT '',
- PRIMARY KEY (`id`),
- UNIQUE KEY `name` (`name`),
- UNIQUE KEY `name_2` (`name`)
+ `owner_id` int(11) DEFAULT '0',
+ `priority_default` int(11) DEFAULT '0',
+ `priority_start` int(11) DEFAULT '0',
+ `priority_end` int(11) DEFAULT '3',
+ PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `remember_me`;
@@ -281,7 +333,7 @@ DROP TABLE IF EXISTS `remember_me`;
CREATE TABLE `remember_me` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) DEFAULT NULL,
- `ip` varchar(40) DEFAULT NULL,
+ `ip` varchar(45) DEFAULT NULL,
`user_agent` varchar(255) DEFAULT NULL,
`token` varchar(255) DEFAULT NULL,
`sequence` varchar(255) DEFAULT NULL,
@@ -358,6 +410,24 @@ CREATE TABLE `swimlanes` (
CONSTRAINT `swimlanes_ibfk_1` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
+DROP TABLE IF EXISTS `task_has_external_links`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `task_has_external_links` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `link_type` varchar(100) NOT NULL,
+ `dependency` varchar(100) NOT NULL,
+ `title` varchar(255) NOT NULL,
+ `url` varchar(255) NOT NULL,
+ `date_creation` int(11) NOT NULL,
+ `date_modification` int(11) NOT NULL,
+ `task_id` int(11) NOT NULL,
+ `creator_id` int(11) DEFAULT '0',
+ PRIMARY KEY (`id`),
+ KEY `task_id` (`task_id`),
+ CONSTRAINT `task_has_external_links_ibfk_1` FOREIGN KEY (`task_id`) REFERENCES `tasks` (`id`) ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `task_has_links`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
@@ -419,6 +489,7 @@ CREATE TABLE `tasks` (
`recurrence_basedate` int(11) NOT NULL DEFAULT '0',
`recurrence_parent` int(11) DEFAULT NULL,
`recurrence_child` int(11) DEFAULT NULL,
+ `priority` int(11) DEFAULT '0',
PRIMARY KEY (`id`),
KEY `idx_task_active` (`is_active`),
KEY `column_id` (`column_id`),
@@ -509,7 +580,6 @@ CREATE TABLE `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(50) NOT NULL,
`password` varchar(255) DEFAULT NULL,
- `is_admin` tinyint(4) DEFAULT '0',
`is_ldap_user` tinyint(1) DEFAULT '0',
`name` varchar(255) DEFAULT NULL,
`email` varchar(255) DEFAULT NULL,
@@ -517,7 +587,7 @@ CREATE TABLE `users` (
`github_id` varchar(30) DEFAULT NULL,
`notifications_enabled` tinyint(1) DEFAULT '0',
`timezone` varchar(50) DEFAULT NULL,
- `language` char(5) DEFAULT NULL,
+ `language` varchar(5) DEFAULT NULL,
`disable_login_form` tinyint(1) DEFAULT '0',
`twofactor_activated` tinyint(1) DEFAULT '0',
`twofactor_secret` char(16) DEFAULT NULL,
@@ -525,11 +595,10 @@ CREATE TABLE `users` (
`notifications_filter` int(11) DEFAULT '4',
`nb_failed_login` int(11) DEFAULT '0',
`lock_expiration_date` bigint(20) DEFAULT NULL,
- `is_project_admin` int(11) DEFAULT '0',
`gitlab_id` int(11) DEFAULT NULL,
+ `role` varchar(25) NOT NULL DEFAULT 'app-user',
PRIMARY KEY (`id`),
- UNIQUE KEY `users_username_idx` (`username`),
- KEY `users_admin_idx` (`is_admin`)
+ UNIQUE KEY `users_username_idx` (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
@@ -551,7 +620,7 @@ CREATE TABLE `users` (
LOCK TABLES `settings` WRITE;
/*!40000 ALTER TABLE `settings` DISABLE KEYS */;
-INSERT INTO `settings` VALUES ('api_token','ccff8d37146322410479c8c6707cdaddde840af28ccbd6fbb5a7d7908844'),('application_currency','USD'),('application_date_format','m/d/Y'),('application_language','en_US'),('application_stylesheet',''),('application_timezone','UTC'),('application_url',''),('board_columns',''),('board_highlight_period','172800'),('board_private_refresh_interval','10'),('board_public_refresh_interval','60'),('calendar_project_tasks','date_started'),('calendar_user_subtasks_time_tracking','0'),('calendar_user_tasks','date_started'),('cfd_include_closed_tasks','1'),('default_color','yellow'),('integration_gravatar','0'),('project_categories',''),('subtask_restriction','0'),('subtask_time_tracking','1'),('webhook_token','7a9d4cd8c7fc4d52c60f01b775d4f2bd6e186d2e44f5b3723157b8eb372b'),('webhook_url','');
+INSERT INTO `settings` VALUES ('api_token','dcae89653bfd780f56a5c2ffabc54174bcdd877940e97eaa5d800b35df0c'),('application_currency','USD'),('application_date_format','m/d/Y'),('application_language','en_US'),('application_stylesheet',''),('application_timezone','UTC'),('application_url',''),('board_columns',''),('board_highlight_period','172800'),('board_private_refresh_interval','10'),('board_public_refresh_interval','60'),('calendar_project_tasks','date_started'),('calendar_user_subtasks_time_tracking','0'),('calendar_user_tasks','date_started'),('cfd_include_closed_tasks','1'),('default_color','yellow'),('integration_gravatar','0'),('password_reset','1'),('project_categories',''),('subtask_restriction','0'),('subtask_time_tracking','1'),('webhook_token','6c0a16d06e31add3ca1ca8713a69c6b410f72c80fd49cdfe27c4a62eef13'),('webhook_url','');
/*!40000 ALTER TABLE `settings` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
@@ -580,4 +649,4 @@ UNLOCK TABLES;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-INSERT INTO users (username, password, is_admin) VALUES ('admin', '$2y$10$fDbO.nKAjDxm70DyghADCuqIhF919BAkRTAq0bARDTGwcxZscqIZq', '1');INSERT INTO schema_version VALUES ('93');
+INSERT INTO users (username, password, role) VALUES ('admin', '$2y$10$f6brAPgJ6iTtOWUMJANDuuRG.VWDH61.aCb5v3MJnSrZodhDaCcmy', 'app-admin');INSERT INTO schema_version VALUES ('104');
diff --git a/app/Schema/Sql/postgres.sql b/app/Schema/Sql/postgres.sql
index 8738010f..68415805 100644
--- a/app/Schema/Sql/postgres.sql
+++ b/app/Schema/Sql/postgres.sql
@@ -68,7 +68,7 @@ CREATE TABLE actions (
id integer NOT NULL,
project_id integer NOT NULL,
event_name character varying(50) NOT NULL,
- action_name character varying(50) NOT NULL
+ action_name character varying(255) NOT NULL
);
@@ -218,6 +218,46 @@ CREATE TABLE files (
--
+-- Name: group_has_users; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE group_has_users (
+ group_id integer NOT NULL,
+ user_id integer NOT NULL
+);
+
+
+--
+-- Name: groups; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE groups (
+ id integer NOT NULL,
+ external_id character varying(255) DEFAULT ''::character varying,
+ name character varying(100) NOT NULL
+);
+
+
+--
+-- Name: groups_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE groups_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: groups_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE groups_id_seq OWNED BY groups.id;
+
+
+--
-- Name: last_logins; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
@@ -225,7 +265,7 @@ CREATE TABLE last_logins (
id integer NOT NULL,
auth_type character varying(25),
user_id integer,
- ip character varying(40),
+ ip character varying(45),
user_agent character varying(255),
date_creation bigint
);
@@ -281,6 +321,21 @@ ALTER SEQUENCE links_id_seq OWNED BY links.id;
--
+-- Name: password_reset; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE password_reset (
+ token character varying(80) NOT NULL,
+ user_id integer NOT NULL,
+ date_expiration integer NOT NULL,
+ date_creation integer NOT NULL,
+ ip character varying(45) NOT NULL,
+ user_agent character varying(255) NOT NULL,
+ is_active boolean NOT NULL
+);
+
+
+--
-- Name: plugin_schema_versions; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
@@ -421,6 +476,17 @@ ALTER SEQUENCE project_has_categories_id_seq OWNED BY project_has_categories.id;
--
+-- Name: project_has_groups; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE project_has_groups (
+ group_id integer NOT NULL,
+ project_id integer NOT NULL,
+ role character varying(25) NOT NULL
+);
+
+
+--
-- Name: project_has_metadata; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
@@ -466,33 +532,13 @@ ALTER SEQUENCE project_has_notification_types_id_seq OWNED BY project_has_notifi
--
CREATE TABLE project_has_users (
- id integer NOT NULL,
project_id integer NOT NULL,
user_id integer NOT NULL,
- is_owner boolean DEFAULT false
+ role character varying(25) DEFAULT 'project-viewer'::character varying NOT NULL
);
--
--- Name: project_has_users_id_seq; Type: SEQUENCE; Schema: public; Owner: -
---
-
-CREATE SEQUENCE project_has_users_id_seq
- START WITH 1
- INCREMENT BY 1
- NO MINVALUE
- NO MAXVALUE
- CACHE 1;
-
-
---
--- Name: project_has_users_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
---
-
-ALTER SEQUENCE project_has_users_id_seq OWNED BY project_has_users.id;
-
-
---
-- Name: projects; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
@@ -510,7 +556,11 @@ CREATE TABLE projects (
description text,
identifier character varying(50) DEFAULT ''::character varying,
start_date character varying(10) DEFAULT ''::character varying,
- end_date character varying(10) DEFAULT ''::character varying
+ end_date character varying(10) DEFAULT ''::character varying,
+ owner_id integer DEFAULT 0,
+ priority_default integer DEFAULT 0,
+ priority_start integer DEFAULT 0,
+ priority_end integer DEFAULT 3
);
@@ -540,7 +590,7 @@ ALTER SEQUENCE projects_id_seq OWNED BY projects.id;
CREATE TABLE remember_me (
id integer NOT NULL,
user_id integer,
- ip character varying(40),
+ ip character varying(45),
user_agent character varying(255),
token character varying(255),
sequence character varying(255),
@@ -670,6 +720,42 @@ ALTER SEQUENCE swimlanes_id_seq OWNED BY swimlanes.id;
--
+-- Name: task_has_external_links; Type: TABLE; Schema: public; Owner: -; Tablespace:
+--
+
+CREATE TABLE task_has_external_links (
+ id integer NOT NULL,
+ link_type character varying(100) NOT NULL,
+ dependency character varying(100) NOT NULL,
+ title character varying(255) NOT NULL,
+ url character varying(255) NOT NULL,
+ date_creation integer NOT NULL,
+ date_modification integer NOT NULL,
+ task_id integer NOT NULL,
+ creator_id integer DEFAULT 0
+);
+
+
+--
+-- Name: task_has_external_links_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE task_has_external_links_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: task_has_external_links_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE task_has_external_links_id_seq OWNED BY task_has_external_links.id;
+
+
+--
-- Name: task_has_files_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
@@ -782,7 +868,8 @@ CREATE TABLE tasks (
recurrence_timeframe integer DEFAULT 0 NOT NULL,
recurrence_basedate integer DEFAULT 0 NOT NULL,
recurrence_parent integer,
- recurrence_child integer
+ recurrence_child integer,
+ priority integer DEFAULT 0
);
@@ -931,7 +1018,6 @@ CREATE TABLE users (
id integer NOT NULL,
username character varying(50) NOT NULL,
password character varying(255),
- is_admin boolean DEFAULT false,
is_ldap_user boolean DEFAULT false,
name character varying(255),
email character varying(255),
@@ -939,7 +1025,7 @@ CREATE TABLE users (
github_id character varying(30),
notifications_enabled boolean DEFAULT false,
timezone character varying(50),
- language character(5),
+ language character varying(5),
disable_login_form boolean DEFAULT false,
twofactor_activated boolean DEFAULT false,
twofactor_secret character(16),
@@ -947,8 +1033,8 @@ CREATE TABLE users (
notifications_filter integer DEFAULT 4,
nb_failed_login integer DEFAULT 0,
lock_expiration_date bigint DEFAULT 0,
- is_project_admin boolean DEFAULT false,
- gitlab_id integer
+ gitlab_id integer,
+ role character varying(25) DEFAULT 'app-user'::character varying NOT NULL
);
@@ -1017,6 +1103,13 @@ ALTER TABLE ONLY files ALTER COLUMN id SET DEFAULT nextval('task_has_files_id_se
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--
+ALTER TABLE ONLY groups ALTER COLUMN id SET DEFAULT nextval('groups_id_seq'::regclass);
+
+
+--
+-- Name: id; Type: DEFAULT; Schema: public; Owner: -
+--
+
ALTER TABLE ONLY last_logins ALTER COLUMN id SET DEFAULT nextval('last_logins_id_seq'::regclass);
@@ -1066,42 +1159,42 @@ ALTER TABLE ONLY project_has_notification_types ALTER COLUMN id SET DEFAULT next
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--
-ALTER TABLE ONLY project_has_users ALTER COLUMN id SET DEFAULT nextval('project_has_users_id_seq'::regclass);
+ALTER TABLE ONLY projects ALTER COLUMN id SET DEFAULT nextval('projects_id_seq'::regclass);
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--
-ALTER TABLE ONLY projects ALTER COLUMN id SET DEFAULT nextval('projects_id_seq'::regclass);
+ALTER TABLE ONLY remember_me ALTER COLUMN id SET DEFAULT nextval('remember_me_id_seq'::regclass);
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--
-ALTER TABLE ONLY remember_me ALTER COLUMN id SET DEFAULT nextval('remember_me_id_seq'::regclass);
+ALTER TABLE ONLY subtask_time_tracking ALTER COLUMN id SET DEFAULT nextval('subtask_time_tracking_id_seq'::regclass);
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--
-ALTER TABLE ONLY subtask_time_tracking ALTER COLUMN id SET DEFAULT nextval('subtask_time_tracking_id_seq'::regclass);
+ALTER TABLE ONLY subtasks ALTER COLUMN id SET DEFAULT nextval('task_has_subtasks_id_seq'::regclass);
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--
-ALTER TABLE ONLY subtasks ALTER COLUMN id SET DEFAULT nextval('task_has_subtasks_id_seq'::regclass);
+ALTER TABLE ONLY swimlanes ALTER COLUMN id SET DEFAULT nextval('swimlanes_id_seq'::regclass);
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--
-ALTER TABLE ONLY swimlanes ALTER COLUMN id SET DEFAULT nextval('swimlanes_id_seq'::regclass);
+ALTER TABLE ONLY task_has_external_links ALTER COLUMN id SET DEFAULT nextval('task_has_external_links_id_seq'::regclass);
--
@@ -1203,6 +1296,30 @@ ALTER TABLE ONLY custom_filters
--
+-- Name: group_has_users_group_id_user_id_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY group_has_users
+ ADD CONSTRAINT group_has_users_group_id_user_id_key UNIQUE (group_id, user_id);
+
+
+--
+-- Name: groups_name_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY groups
+ ADD CONSTRAINT groups_name_key UNIQUE (name);
+
+
+--
+-- Name: groups_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY groups
+ ADD CONSTRAINT groups_pkey PRIMARY KEY (id);
+
+
+--
-- Name: last_logins_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
@@ -1227,6 +1344,14 @@ ALTER TABLE ONLY links
--
+-- Name: password_reset_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY password_reset
+ ADD CONSTRAINT password_reset_pkey PRIMARY KEY (token);
+
+
+--
-- Name: plugin_schema_versions_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
@@ -1275,6 +1400,14 @@ ALTER TABLE ONLY project_has_categories
--
+-- Name: project_has_groups_group_id_project_id_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
+--
+
+ALTER TABLE ONLY project_has_groups
+ ADD CONSTRAINT project_has_groups_group_id_project_id_key UNIQUE (group_id, project_id);
+
+
+--
-- Name: project_has_metadata_project_id_name_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
@@ -1299,14 +1432,6 @@ ALTER TABLE ONLY project_has_notification_types
--
--- Name: project_has_users_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
---
-
-ALTER TABLE ONLY project_has_users
- ADD CONSTRAINT project_has_users_pkey PRIMARY KEY (id);
-
-
---
-- Name: project_has_users_project_id_user_id_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
@@ -1315,14 +1440,6 @@ ALTER TABLE ONLY project_has_users
--
--- Name: projects_name_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
---
-
-ALTER TABLE ONLY projects
- ADD CONSTRAINT projects_name_key UNIQUE (name);
-
-
---
-- Name: projects_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
@@ -1578,13 +1695,6 @@ CREATE UNIQUE INDEX user_has_notification_types_user_idx ON user_has_notificatio
--
--- Name: users_admin_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
---
-
-CREATE INDEX users_admin_idx ON users USING btree (is_admin);
-
-
---
-- Name: users_username_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
@@ -1624,6 +1734,22 @@ ALTER TABLE ONLY comments
--
+-- Name: group_has_users_group_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY group_has_users
+ ADD CONSTRAINT group_has_users_group_id_fkey FOREIGN KEY (group_id) REFERENCES groups(id) ON DELETE CASCADE;
+
+
+--
+-- Name: group_has_users_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY group_has_users
+ ADD CONSTRAINT group_has_users_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE;
+
+
+--
-- Name: last_logins_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--
@@ -1632,6 +1758,14 @@ ALTER TABLE ONLY last_logins
--
+-- Name: password_reset_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY password_reset
+ ADD CONSTRAINT password_reset_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE;
+
+
+--
-- Name: project_activities_creator_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--
@@ -1688,6 +1822,22 @@ ALTER TABLE ONLY project_has_categories
--
+-- Name: project_has_groups_group_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY project_has_groups
+ ADD CONSTRAINT project_has_groups_group_id_fkey FOREIGN KEY (group_id) REFERENCES groups(id) ON DELETE CASCADE;
+
+
+--
+-- Name: project_has_groups_project_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY project_has_groups
+ ADD CONSTRAINT project_has_groups_project_id_fkey FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
+
+
+--
-- Name: project_has_metadata_project_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--
@@ -1752,6 +1902,14 @@ ALTER TABLE ONLY swimlanes
--
+-- Name: task_has_external_links_task_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY task_has_external_links
+ ADD CONSTRAINT task_has_external_links_task_id_fkey FOREIGN KEY (task_id) REFERENCES tasks(id) ON DELETE CASCADE;
+
+
+--
-- Name: task_has_files_task_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--
@@ -1930,8 +2088,8 @@ INSERT INTO settings (option, value) VALUES ('board_highlight_period', '172800')
INSERT INTO settings (option, value) VALUES ('board_public_refresh_interval', '60');
INSERT INTO settings (option, value) VALUES ('board_private_refresh_interval', '10');
INSERT INTO settings (option, value) VALUES ('board_columns', '');
-INSERT INTO settings (option, value) VALUES ('webhook_token', '29877f0b69d230e57bee9d02e0aa9034a69f7a2c0ba1e3b5d3b390241f36');
-INSERT INTO settings (option, value) VALUES ('api_token', '5682955e965bd0cd7618559a25131fe6094d9fff3bb56c31291d64991353');
+INSERT INTO settings (option, value) VALUES ('webhook_token', '083531659240f36021edc73a4ed3920646ef8798b798c5894e2277f048a2');
+INSERT INTO settings (option, value) VALUES ('api_token', 'b97b4abc7e8f0e0569bdad8cb54f7fb1931615932e552fa255f87a3e1360');
INSERT INTO settings (option, value) VALUES ('application_language', 'en_US');
INSERT INTO settings (option, value) VALUES ('application_timezone', 'UTC');
INSERT INTO settings (option, value) VALUES ('application_url', '');
@@ -1948,6 +2106,7 @@ INSERT INTO settings (option, value) VALUES ('webhook_url', '');
INSERT INTO settings (option, value) VALUES ('default_color', 'yellow');
INSERT INTO settings (option, value) VALUES ('subtask_time_tracking', '1');
INSERT INTO settings (option, value) VALUES ('cfd_include_closed_tasks', '1');
+INSERT INTO settings (option, value) VALUES ('password_reset', '1');
--
@@ -1995,4 +2154,4 @@ SELECT pg_catalog.setval('links_id_seq', 11, true);
-- PostgreSQL database dump complete
--
-INSERT INTO users (username, password, is_admin) VALUES ('admin', '$2y$10$fDbO.nKAjDxm70DyghADCuqIhF919BAkRTAq0bARDTGwcxZscqIZq', '1');INSERT INTO schema_version VALUES ('73');
+INSERT INTO users (username, password, role) VALUES ('admin', '$2y$10$f6brAPgJ6iTtOWUMJANDuuRG.VWDH61.aCb5v3MJnSrZodhDaCcmy', 'app-admin');INSERT INTO schema_version VALUES ('84');
diff --git a/app/Schema/Sqlite.php b/app/Schema/Sqlite.php
index b9ab86f8..8bcad291 100644
--- a/app/Schema/Sqlite.php
+++ b/app/Schema/Sqlite.php
@@ -2,10 +2,185 @@
namespace Schema;
-use Kanboard\Core\Security;
+use Kanboard\Core\Security\Token;
+use Kanboard\Core\Security\Role;
use PDO;
-const VERSION = 88;
+const VERSION = 99;
+
+function version_99(PDO $pdo)
+{
+ $pdo->exec("UPDATE project_activities SET event_name='task.file.create' WHERE event_name='file.create'");
+}
+
+function version_98(PDO $pdo)
+{
+ $pdo->exec('ALTER TABLE files RENAME TO task_has_files');
+
+ $pdo->exec("
+ CREATE TABLE project_has_files (
+ id INTEGER PRIMARY KEY,
+ project_id INTEGER NOT NULL,
+ name TEXT COLLATE NOCASE NOT NULL,
+ path TEXT NOT NULL,
+ is_image INTEGER DEFAULT 0,
+ size INTEGER DEFAULT 0 NOT NULL,
+ user_id INTEGER DEFAULT 0 NOT NULL,
+ date INTEGER DEFAULT 0 NOT NULL,
+ FOREIGN KEY(project_id) REFERENCES projects(id) ON DELETE CASCADE
+ )"
+ );
+}
+
+function version_97(PDO $pdo)
+{
+ $pdo->exec("ALTER TABLE users ADD COLUMN is_active INTEGER DEFAULT 1");
+}
+
+function version_96(PDO $pdo)
+{
+ $pdo->exec("
+ CREATE TABLE task_has_external_links (
+ id INTEGER PRIMARY KEY,
+ link_type TEXT NOT NULL,
+ dependency TEXT NOT NULL,
+ title TEXT NOT NULL,
+ url TEXT NOT NULL,
+ date_creation INTEGER NOT NULL,
+ date_modification INTEGER NOT NULL,
+ task_id INTEGER NOT NULL,
+ creator_id INTEGER DEFAULT 0,
+ FOREIGN KEY(task_id) REFERENCES tasks(id) ON DELETE CASCADE
+ )
+ ");
+}
+
+function version_95(PDO $pdo)
+{
+ $pdo->exec("ALTER TABLE projects ADD COLUMN priority_default INTEGER DEFAULT 0");
+ $pdo->exec("ALTER TABLE projects ADD COLUMN priority_start INTEGER DEFAULT 0");
+ $pdo->exec("ALTER TABLE projects ADD COLUMN priority_end INTEGER DEFAULT 3");
+ $pdo->exec("ALTER TABLE tasks ADD COLUMN priority INTEGER DEFAULT 0");
+}
+
+function version_94(PDO $pdo)
+{
+ $pdo->exec("ALTER TABLE projects ADD COLUMN owner_id INTEGER DEFAULT 0");
+}
+
+function version_93(PDO $pdo)
+{
+ $pdo->exec("
+ CREATE TABLE password_reset (
+ token TEXT PRIMARY KEY,
+ user_id INTEGER NOT NULL,
+ date_expiration INTEGER NOT NULL,
+ date_creation INTEGER NOT NULL,
+ ip TEXT NOT NULL,
+ user_agent TEXT NOT NULL,
+ is_active INTEGER NOT NULL,
+ FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE
+ )
+ ");
+
+ $pdo->exec("INSERT INTO settings VALUES ('password_reset', '1')");
+}
+
+function version_92(PDO $pdo)
+{
+ $rq = $pdo->prepare('SELECT * FROM actions');
+ $rq->execute();
+ $rows = $rq->fetchAll(PDO::FETCH_ASSOC) ?: array();
+
+ $rq = $pdo->prepare('UPDATE actions SET action_name=? WHERE id=?');
+
+ foreach ($rows as $row) {
+ if ($row['action_name'] === 'TaskAssignCurrentUser' && $row['event_name'] === 'task.move.column') {
+ $row['action_name'] = '\Kanboard\Action\TaskAssignCurrentUserColumn';
+ } elseif ($row['action_name'] === 'TaskClose' && $row['event_name'] === 'task.move.column') {
+ $row['action_name'] = '\Kanboard\Action\TaskCloseColumn';
+ } elseif ($row['action_name'] === 'TaskLogMoveAnotherColumn') {
+ $row['action_name'] = '\Kanboard\Action\CommentCreationMoveTaskColumn';
+ } elseif ($row['action_name']{0} !== '\\') {
+ $row['action_name'] = '\Kanboard\Action\\'.$row['action_name'];
+ }
+
+ $rq->execute(array($row['action_name'], $row['id']));
+ }
+}
+
+function version_91(PDO $pdo)
+{
+ $pdo->exec("ALTER TABLE users ADD COLUMN role TEXT NOT NULL DEFAULT '".Role::APP_USER."'");
+
+ $rq = $pdo->prepare('SELECT * FROM users');
+ $rq->execute();
+ $rows = $rq->fetchAll(PDO::FETCH_ASSOC) ?: array();
+
+ $rq = $pdo->prepare('UPDATE users SET "role"=? WHERE "id"=?');
+
+ foreach ($rows as $row) {
+ $role = Role::APP_USER;
+
+ if ($row['is_admin'] == 1) {
+ $role = Role::APP_ADMIN;
+ } else if ($row['is_project_admin']) {
+ $role = Role::APP_MANAGER;
+ }
+
+ $rq->execute(array($role, $row['id']));
+ }
+}
+
+function version_90(PDO $pdo)
+{
+ $pdo->exec("
+ CREATE TABLE project_has_groups (
+ group_id INTEGER NOT NULL,
+ project_id INTEGER NOT NULL,
+ role TEXT NOT NULL,
+ FOREIGN KEY(group_id) REFERENCES groups(id) ON DELETE CASCADE,
+ FOREIGN KEY(project_id) REFERENCES projects(id) ON DELETE CASCADE,
+ UNIQUE(group_id, project_id)
+ )
+ ");
+
+ $pdo->exec("ALTER TABLE project_has_users ADD COLUMN role TEXT NOT NULL DEFAULT '".Role::PROJECT_VIEWER."'");
+
+ $rq = $pdo->prepare('SELECT * FROM project_has_users');
+ $rq->execute();
+ $rows = $rq->fetchAll(PDO::FETCH_ASSOC) ?: array();
+
+ $rq = $pdo->prepare('UPDATE project_has_users SET "role"=? WHERE "id"=?');
+
+ foreach ($rows as $row) {
+ $rq->execute(array(
+ $row['is_owner'] == 1 ? Role::PROJECT_MANAGER : Role::PROJECT_MEMBER,
+ $row['id'],
+ ));
+ }
+}
+
+function version_89(PDO $pdo)
+{
+ $pdo->exec("
+ CREATE TABLE groups (
+ id INTEGER PRIMARY KEY,
+ external_id TEXT DEFAULT '',
+ name TEXT NOCASE NOT NULL UNIQUE
+ )
+ ");
+
+ $pdo->exec("
+ CREATE TABLE group_has_users (
+ group_id INTEGER NOT NULL,
+ user_id INTEGER NOT NULL,
+ FOREIGN KEY(group_id) REFERENCES groups(id) ON DELETE CASCADE,
+ FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE,
+ UNIQUE(group_id, user_id)
+ )
+ ");
+}
function version_88(PDO $pdo)
{
@@ -799,7 +974,7 @@ function version_20(PDO $pdo)
function version_19(PDO $pdo)
{
$pdo->exec("ALTER TABLE config ADD COLUMN api_token TEXT DEFAULT ''");
- $pdo->exec("UPDATE config SET api_token='".Security::generateToken()."'");
+ $pdo->exec("UPDATE config SET api_token='".Token::getToken()."'");
}
function version_18(PDO $pdo)
@@ -969,7 +1144,6 @@ function version_7(PDO $pdo)
{
$pdo->exec("
CREATE TABLE project_has_users (
- id INTEGER PRIMARY KEY,
project_id INTEGER NOT NULL,
user_id INTEGER NOT NULL,
FOREIGN KEY(project_id) REFERENCES projects(id) ON DELETE CASCADE,
@@ -1026,7 +1200,7 @@ function version_1(PDO $pdo)
$pdo->exec("
CREATE TABLE projects (
id INTEGER PRIMARY KEY,
- name TEXT NOCASE NOT NULL UNIQUE,
+ name TEXT NOCASE NOT NULL,
is_active INTEGER DEFAULT 1
)
");
@@ -1068,6 +1242,6 @@ function version_1(PDO $pdo)
$pdo->exec("
INSERT INTO config
(webhooks_token)
- VALUES ('".Security::generateToken()."')
+ VALUES ('".Token::getToken()."')
");
}