commit bcaba9037bb16c526bbb537eb8d2066741ff1d79
parent 0080dd57738f20bd20a0fc0afd35e229a00e5c5b
Author: Jan Dankert <develop@jandankert.de>
Date: Thu, 16 May 2019 20:44:16 +0200
New: database column 'format' in table 'value'.
Diffstat:
2 files changed, 34 insertions(+), 1 deletion(-)
diff --git a/modules/database-update/DbUpdate.class.php b/modules/database-update/DbUpdate.class.php
@@ -2,7 +2,7 @@
use database\Database;
-define('OR_DB_SUPPORTED_VERSION' ,18);
+define('OR_DB_SUPPORTED_VERSION' ,19);
define('OR_DB_STATUS_UPDATE_PROGRESS', 0);
define('OR_DB_STATUS_UPDATE_SUCCESS' , 1);
diff --git a/modules/database-update/update/DBVersion000019.class.php b/modules/database-update/update/DBVersion000019.class.php
@@ -0,0 +1,33 @@
+<?php
+
+use database\DbVersion;
+use security\Password;
+
+/**
+ * The format of a value is stored in the value table, so users can change the format of a value, independent of the element.
+ *
+ * @author dankert
+ *
+ */
+class DBVersion000019 extends DbVersion
+{
+ /**
+ *
+ */
+ public function update()
+ {
+ $this->addColumn('value','format' ,OR_DB_COLUMN_TYPE_INT,1,0,OR_DB_COLUMN_NOT_NULLABLE);
+
+ // Initial Value: Copy from element.
+ $tableValue = $this->getTableName('value');
+ $tableElement = $this->getTableName('element');
+
+ $updateStmt = $this->getDb()->sql(<<<SQL
+UPDATE $tableValue
+ SET format=(select format from $tableElement where $tableValue.elementid=$tableElement.id)
+SQL
+ );
+ $updateStmt->query();
+ }
+}
+