Bug 14826: Update database
authorKyle M Hall <kyle@bywatersolutions.com>
Tue, 12 Jul 2016 13:50:11 +0000 (13:50 +0000)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 20 Oct 2017 19:54:33 +0000 (16:54 -0300)
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
installer/data/mysql/atomicupdate/bug_14826.sql [new file with mode: 0644]
installer/data/mysql/kohastructure.sql

diff --git a/installer/data/mysql/atomicupdate/bug_14826.sql b/installer/data/mysql/atomicupdate/bug_14826.sql
new file mode 100644 (file)
index 0000000..91d183b
--- /dev/null
@@ -0,0 +1,12 @@
+DROP TABLE IF EXISTS `accountoffsets`;
+CREATE TABLE IF NOT EXISTS `account_offsets` (
+  `id` int(11) NOT NULL auto_increment, -- unique identifier for each offset
+  `credit_id` int(11) NULL DEFAULT NULL, -- The id of the accountline the increased the patron's balance
+  `debit_id` int(11) NULL DEFAULT NULL, -- The id of the accountline that decreased the patron's balance
+  `type` varchar(16) NOT NULL, -- The type of offset this is
+  `amount` decimal(26,6) NOT NULL, -- The amount of the change
+  `created_on` timestamp NOT NULL default CURRENT_TIMESTAMP,
+  PRIMARY KEY (`id`),
+  CONSTRAINT `account_offsets_ibfk_p` FOREIGN KEY (`credit_id`) REFERENCES `accountlines` (`accountlines_id`) ON DELETE CASCADE ON UPDATE CASCADE,
+  CONSTRAINT `account_offsets_ibfk_f` FOREIGN KEY (`debit_id`) REFERENCES `accountlines` (`accountlines_id`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
index b0d6cf2..d339e41 100644 (file)
@@ -2737,17 +2737,20 @@ CREATE TABLE `accountlines` (
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
 
 --
--- Table structure for table `accountoffsets`
+-- Table structure for table `account_offsets`
 --
 
-DROP TABLE IF EXISTS `accountoffsets`;
-CREATE TABLE `accountoffsets` (
-  `borrowernumber` int(11) NOT NULL default 0,
-  `accountno` smallint(6) NOT NULL default 0,
-  `offsetaccount` smallint(6) NOT NULL default 0,
-  `offsetamount` decimal(28,6) default NULL,
-  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
-  CONSTRAINT `accountoffsets_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
+DROP TABLE IF EXISTS `account_offsets`;
+CREATE TABLE `account_offsets` (
+  `id` int(11) NOT NULL auto_increment, -- unique identifier for each offset
+  `credit_id` int(11) NULL DEFAULT NULL, -- The id of the accountline the increased the patron's balance
+  `debit_id` int(11) NULL DEFAULT NULL, -- The id of the accountline that decreased the patron's balance
+  `type` varchar(16) NOT NULL, -- The type of offset this is
+  `amount` decimal(26,6) NOT NULL, -- The amount of the change
+  `created_on` timestamp NOT NULL default CURRENT_TIMESTAMP,
+  PRIMARY KEY (`id`),
+  CONSTRAINT `account_offsets_ibfk_p` FOREIGN KEY (`credit_id`) REFERENCES `accountlines` (`accountlines_id`) ON DELETE CASCADE ON UPDATE CASCADE,
+  CONSTRAINT `account_offsets_ibfk_f` FOREIGN KEY (`debit_id`) REFERENCES `accountlines` (`accountlines_id`) ON DELETE CASCADE ON UPDATE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
 
 --