summaryrefslogtreecommitdiff
path: root/app/Schema
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2014-10-04 23:31:03 -0400
committerFrédéric Guillot <fred@kanboard.net>2014-10-04 23:31:03 -0400
commit8e5673e3d289e4d28b4fc9f20721bda9f1c858c7 (patch)
treea5dc3eff7408e8709d20ea92b926c5424d70c5f9 /app/Schema
parentf531d57dc27b9d1568de0a10b19f69e8c2b2f156 (diff)
Improve settings page and move some config parameters to the database
Diffstat (limited to 'app/Schema')
-rw-r--r--app/Schema/Mysql.php33
-rw-r--r--app/Schema/Postgres.php33
-rw-r--r--app/Schema/Sqlite.php33
3 files changed, 96 insertions, 3 deletions
diff --git a/app/Schema/Mysql.php b/app/Schema/Mysql.php
index 577fac80..e6a33ee5 100644
--- a/app/Schema/Mysql.php
+++ b/app/Schema/Mysql.php
@@ -2,9 +2,40 @@
namespace Schema;
+use PDO;
use Core\Security;
-const VERSION = 28;
+const VERSION = 29;
+
+function version_29($pdo)
+{
+ $pdo->exec("
+ CREATE TABLE settings (
+ option VARCHAR(100) PRIMARY KEY,
+ value VARCHAR(255) DEFAULT ''
+ )
+ ");
+
+ // Migrate old config parameters
+ $rq = $pdo->prepare('SELECT * FROM config');
+ $rq->execute();
+ $parameters = $rq->fetch(PDO::FETCH_ASSOC);
+
+ $rq = $pdo->prepare('INSERT INTO settings VALUES (?, ?)');
+ $rq->execute(array('board_highlight_period', defined('RECENT_TASK_PERIOD') ? RECENT_TASK_PERIOD : 48*60*60));
+ $rq->execute(array('board_public_refresh_interval', defined('BOARD_PUBLIC_CHECK_INTERVAL') ? BOARD_PUBLIC_CHECK_INTERVAL : 60));
+ $rq->execute(array('board_private_refresh_interval', defined('BOARD_CHECK_INTERVAL') ? BOARD_CHECK_INTERVAL : 10));
+ $rq->execute(array('board_columns', $parameters['default_columns']));
+ $rq->execute(array('webhook_url_task_creation', $parameters['webhooks_url_task_creation']));
+ $rq->execute(array('webhook_url_task_modification', $parameters['webhooks_url_task_modification']));
+ $rq->execute(array('webhook_token', $parameters['webhooks_token']));
+ $rq->execute(array('api_token', $parameters['api_token']));
+ $rq->execute(array('application_language', $parameters['language']));
+ $rq->execute(array('application_timezone', $parameters['timezone']));
+ $rq->execute(array('application_url', defined('KANBOARD_URL') ? KANBOARD_URL : ''));
+
+ $pdo->exec('DROP TABLE config');
+}
function version_28($pdo)
{
diff --git a/app/Schema/Postgres.php b/app/Schema/Postgres.php
index 33859513..0eeb2a72 100644
--- a/app/Schema/Postgres.php
+++ b/app/Schema/Postgres.php
@@ -2,9 +2,40 @@
namespace Schema;
+use PDO;
use Core\Security;
-const VERSION = 9;
+const VERSION = 10;
+
+function version_10($pdo)
+{
+ $pdo->exec("
+ CREATE TABLE settings (
+ option VARCHAR(100) PRIMARY KEY,
+ value VARCHAR(255) DEFAULT ''
+ )
+ ");
+
+ // Migrate old config parameters
+ $rq = $pdo->prepare('SELECT * FROM config');
+ $rq->execute();
+ $parameters = $rq->fetch(PDO::FETCH_ASSOC);
+
+ $rq = $pdo->prepare('INSERT INTO settings VALUES (?, ?)');
+ $rq->execute(array('board_highlight_period', defined('RECENT_TASK_PERIOD') ? RECENT_TASK_PERIOD : 48*60*60));
+ $rq->execute(array('board_public_refresh_interval', defined('BOARD_PUBLIC_CHECK_INTERVAL') ? BOARD_PUBLIC_CHECK_INTERVAL : 60));
+ $rq->execute(array('board_private_refresh_interval', defined('BOARD_CHECK_INTERVAL') ? BOARD_CHECK_INTERVAL : 10));
+ $rq->execute(array('board_columns', $parameters['default_columns']));
+ $rq->execute(array('webhook_url_task_creation', $parameters['webhooks_url_task_creation']));
+ $rq->execute(array('webhook_url_task_modification', $parameters['webhooks_url_task_modification']));
+ $rq->execute(array('webhook_token', $parameters['webhooks_token']));
+ $rq->execute(array('api_token', $parameters['api_token']));
+ $rq->execute(array('application_language', $parameters['language']));
+ $rq->execute(array('application_timezone', $parameters['timezone']));
+ $rq->execute(array('application_url', defined('KANBOARD_URL') ? KANBOARD_URL : ''));
+
+ $pdo->exec('DROP TABLE config');
+}
function version_9($pdo)
{
diff --git a/app/Schema/Sqlite.php b/app/Schema/Sqlite.php
index d9b3787d..5986d327 100644
--- a/app/Schema/Sqlite.php
+++ b/app/Schema/Sqlite.php
@@ -3,8 +3,39 @@
namespace Schema;
use Core\Security;
+use PDO;
-const VERSION = 28;
+const VERSION = 29;
+
+function version_29($pdo)
+{
+ $pdo->exec("
+ CREATE TABLE settings (
+ option TEXT PRIMARY KEY,
+ value TEXT DEFAULT ''
+ )
+ ");
+
+ // Migrate old config parameters
+ $rq = $pdo->prepare('SELECT * FROM config');
+ $rq->execute();
+ $parameters = $rq->fetch(PDO::FETCH_ASSOC);
+
+ $rq = $pdo->prepare('INSERT INTO settings VALUES (?, ?)');
+ $rq->execute(array('board_highlight_period', defined('RECENT_TASK_PERIOD') ? RECENT_TASK_PERIOD : 48*60*60));
+ $rq->execute(array('board_public_refresh_interval', defined('BOARD_PUBLIC_CHECK_INTERVAL') ? BOARD_PUBLIC_CHECK_INTERVAL : 60));
+ $rq->execute(array('board_private_refresh_interval', defined('BOARD_CHECK_INTERVAL') ? BOARD_CHECK_INTERVAL : 10));
+ $rq->execute(array('board_columns', $parameters['default_columns']));
+ $rq->execute(array('webhook_url_task_creation', $parameters['webhooks_url_task_creation']));
+ $rq->execute(array('webhook_url_task_modification', $parameters['webhooks_url_task_modification']));
+ $rq->execute(array('webhook_token', $parameters['webhooks_token']));
+ $rq->execute(array('api_token', $parameters['api_token']));
+ $rq->execute(array('application_language', $parameters['language']));
+ $rq->execute(array('application_timezone', $parameters['timezone']));
+ $rq->execute(array('application_url', defined('KANBOARD_URL') ? KANBOARD_URL : ''));
+
+ $pdo->exec('DROP TABLE config');
+}
function version_28($pdo)
{