summaryrefslogtreecommitdiffstats
path: root/modules-available/usblockoff/install.inc.php
diff options
context:
space:
mode:
Diffstat (limited to 'modules-available/usblockoff/install.inc.php')
-rw-r--r--modules-available/usblockoff/install.inc.php65
1 files changed, 65 insertions, 0 deletions
diff --git a/modules-available/usblockoff/install.inc.php b/modules-available/usblockoff/install.inc.php
new file mode 100644
index 00000000..dda0ac35
--- /dev/null
+++ b/modules-available/usblockoff/install.inc.php
@@ -0,0 +1,65 @@
+<?php
+
+$res = array();
+
+$t1 = $res[] = tableCreate('usblockoff_hw', '
+ `hwid` INT(10) UNSIGNED NOT NULL,
+ `serial` VARCHAR(128),
+ PRIMARY KEY (`hwid`, `serial`)
+');
+
+$t2 = $res[] = tableCreate('usblockoff_hw_prop', '
+ `hwid` INT(10) UNSIGNED NOT NULL,
+ `serial` VARCHAR(128),
+ `prop` CHAR(16),
+ `value` VARCHAR(500),
+ PRIMARY KEY (`hwid`, `serial`, `prop`)
+');
+
+$t4 = $res[] = tableCreate('usb_configs', '
+ `configid` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+ `configname` VARCHAR(200) NOT NULL,
+ `rulesconfig` VARCHAR(512),
+ `daemonconfig` BLOB,
+ PRIMARY KEY (`configid`)
+');
+
+$t3 = $res[] = tableCreate('usb_rule_prop', '
+ `ruleid` INT(10) UNSIGNED NOT NULL,
+ `prop` CHAR(16),
+ `value` VARCHAR(500)
+');
+
+/*
+$res[] = tableCreate('usb_configs', '
+ `configid` int(10) UNSIGNED NOT NULL AUTO_INCREMENTloadAddDeviceModal,
+ `configname` VARCHAR(200) NOT NULL,
+ `rulesconfig` BLOB,
+ `daemonconfig` BLOB,
+ PRIMARY KEY (`configid`)
+');
+*/
+
+//$ret = Database::exec("DROP TABLE `usb_devices`");
+//$ret = Database::exec("DROP TABLE `usblockoff_hw`");
+//$ret = Database::exec("DROP TABLE `usblockoff_hw_prop`");
+//$ret = Database::exec("DROP TABLE `usb_configs`");
+
+
+if ($t4 === UPDATE_DONE) {
+ $ret = Database::exec("ALTER TABLE `usb_configs` ADD `configdesc` VARCHAR(200)");
+ if ($ret === false) {
+ finalResponse(UPDATE_FAILED, 'Adding column configdesc to usb_configs failed.');
+ }
+}
+
+$res[] = tableAddConstraint("usblockoff_hw", "hwid", "statistic_hw", "hwid", "ON DELETE CASCADE");
+
+// TODO: Works, as the one above already forces retry. How to write it in tableAddConstraint ?
+if ($t2 === UPDATE_DONE) {
+ $ret = Database::exec('ALTER TABLE `usblockoff_hw_prop`
+ ADD CONSTRAINT `usblockoff_hw__prop_ibfk_1` FOREIGN KEY (`hwid`, `serial`) REFERENCES `usblockoff_hw` (`hwid`, `serial`) ON DELETE CASCADE');
+}
+
+responseFromArray($res);
+