Bug 23321: Add cash_registers table
Sponsored-by: PTFS Europe Sponsored-by: Cheshire Libraries Shared Services Signed-off-by: Maryse Simard <maryse.simard@inlibro.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
parent
ac89be111a
commit
fd56dce7af
|
|
@ -0,0 +1,30 @@
|
|||
$DBversion = 'XXX'; # will be replaced by the RM
|
||||
if ( CheckVersion($DBversion) ) {
|
||||
|
||||
$dbh->do(qq{
|
||||
CREATE TABLE `cash_registers` (
|
||||
`id` int(11) NOT NULL auto_increment, -- unique identifier for each account register
|
||||
`name` varchar(24) NOT NULL, -- the user friendly identifier for each account register
|
||||
`description` longtext NOT NULL, -- the user friendly description for each account register
|
||||
`branch` varchar(10) NOT NULL, -- the foreign key the library this account register belongs
|
||||
`branch_default` tinyint(1) NOT NULL DEFAULT 0, -- boolean flag to denote that this till is the branch default
|
||||
`starting_float` decimal(28, 6), -- the starting float this account register should be assigned
|
||||
`archived` tinyint(1) NOT NULL DEFAULT 0, -- boolean flag to denote if this till is archived or not
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `name` (`name`,`branch`),
|
||||
CONSTRAINT cash_registers_branch FOREIGN KEY (branch) REFERENCES branches (branchcode) ON UPDATE CASCADE ON DELETE CASCADE
|
||||
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
|
||||
});
|
||||
|
||||
unless ( column_exists( 'accountlines', 'register_id' ) ) {
|
||||
$dbh->do(qq{ALTER TABLE `accountlines` ADD `register_id` int(11) NULL DEFAULT NULL AFTER `manager_id`});
|
||||
$dbh->do(qq{
|
||||
ALTER TABLE `accountlines`
|
||||
ADD CONSTRAINT `accountlines_ibfk_registers` FOREIGN KEY (`register_id`)
|
||||
REFERENCES `cash_registers` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
|
||||
});
|
||||
}
|
||||
|
||||
SetVersion($DBversion);
|
||||
print "Upgrade to $DBversion done (Bug 23321 - Add cash_registers table)\n";
|
||||
}
|
||||
|
|
@ -2600,6 +2600,24 @@ CREATE TABLE `messages` ( -- circulation messages left via the patron's check ou
|
|||
CONSTRAINT `messages_borrowernumber` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
--
|
||||
-- Table structure for table `cash_registers`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `cash_registers`;
|
||||
CREATE TABLE `cash_registers` (
|
||||
`id` int(11) NOT NULL auto_increment, -- unique identifier for each account register
|
||||
`name` varchar(24) NOT NULL, -- the user friendly identifier for each account register
|
||||
`description` longtext NOT NULL, -- the user friendly description for each account register
|
||||
`branch` varchar(10) NOT NULL, -- the foreign key the library this account register belongs
|
||||
`branch_default` tinyint(1) NOT NULL DEFAULT 0, -- boolean flag to denote that this till is the branch default
|
||||
`starting_float` decimal(28, 6), -- the starting float this account register should be assigned
|
||||
`archived` tinyint(1) NOT NULL DEFAULT 0, -- boolean flag to denote if this till is archived or not
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `name` (`name`,`branch`),
|
||||
CONSTRAINT cash_registers_branch FOREIGN KEY (branch) REFERENCES branches (branchcode) ON UPDATE CASCADE ON DELETE CASCADE
|
||||
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
|
||||
|
||||
--
|
||||
-- Table structure for table `accountlines`
|
||||
--
|
||||
|
|
@ -2620,6 +2638,7 @@ CREATE TABLE `accountlines` (
|
|||
`timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
|
||||
`note` MEDIUMTEXT NULL default NULL,
|
||||
`manager_id` int(11) NULL DEFAULT NULL,
|
||||
`register_id` int(11) NULL DEFAULT NULL,
|
||||
`interface` VARCHAR(16) NOT NULL,
|
||||
`branchcode` VARCHAR( 10 ) NULL DEFAULT NULL, -- the branchcode of the library where a payment was made, a manual invoice created, etc.
|
||||
PRIMARY KEY (`accountlines_id`),
|
||||
|
|
@ -2631,7 +2650,8 @@ CREATE TABLE `accountlines` (
|
|||
CONSTRAINT `accountlines_ibfk_borrowers` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE,
|
||||
CONSTRAINT `accountlines_ibfk_items` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE SET NULL ON UPDATE CASCADE,
|
||||
CONSTRAINT `accountlines_ibfk_borrowers_2` FOREIGN KEY (`manager_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE,
|
||||
CONSTRAINT `accountlines_ibfk_branches` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE SET NULL ON UPDATE CASCADE
|
||||
CONSTRAINT `accountlines_ibfk_branches` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE SET NULL ON UPDATE CASCADE,
|
||||
CONSTRAINT `accountlines_ibfk_registers` FOREIGN KEY (`register_id`) REFERENCES `cash_registers` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
--
|
||||
|
|
|
|||
Loading…
Reference in New Issue