View | Details | Raw Unified | Return to bug 23321
Collapse All | Expand All

(-)a/installer/data/mysql/atomicupdate/bug_23321.perl (+30 lines)
Line 0 Link Here
1
$DBversion = 'XXX';    # will be replaced by the RM
2
if ( CheckVersion($DBversion) ) {
3
4
    $dbh->do(qq{
5
CREATE TABLE `cash_registers` (
6
  `id` int(11) NOT NULL auto_increment, -- unique identifier for each account register
7
  `name` varchar(24) NOT NULL, -- the user friendly identifier for each account register
8
  `description` longtext NOT NULL, -- the user friendly description for each account register
9
  `branch` varchar(10) NOT NULL, -- the foreign key the library this account register belongs
10
  `branch_default` tinyint(1) NOT NULL DEFAULT 0, -- boolean flag to denote that this till is the branch default
11
  `starting_float` decimal(28, 6), -- the starting float this account register should be assigned
12
  `archived` tinyint(1) NOT NULL DEFAULT 0, -- boolean flag to denote if this till is archived or not
13
  PRIMARY KEY (`id`),
14
  UNIQUE KEY `name` (`name`,`branch`),
15
  CONSTRAINT cash_registers_branch FOREIGN KEY (branch) REFERENCES branches (branchcode) ON UPDATE CASCADE ON DELETE CASCADE
16
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
17
    });
18
19
    unless ( column_exists( 'accountlines', 'register_id' ) ) {
20
        $dbh->do(qq{ALTER TABLE `accountlines` ADD `register_id` int(11) NULL DEFAULT NULL AFTER `manager_id`});
21
        $dbh->do(qq{
22
            ALTER TABLE `accountlines`
23
            ADD CONSTRAINT `accountlines_ibfk_registers` FOREIGN KEY (`register_id`)
24
            REFERENCES `cash_registers` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
25
        });
26
    }
27
28
    SetVersion($DBversion);
29
    print "Upgrade to $DBversion done (Bug 23321 - Add cash_registers table)\n";
30
}
(-)a/installer/data/mysql/kohastructure.sql (-2 / +21 lines)
Lines 2600-2605 CREATE TABLE `messages` ( -- circulation messages left via the patron's check ou Link Here
2600
  CONSTRAINT `messages_borrowernumber` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
2600
  CONSTRAINT `messages_borrowernumber` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
2601
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2601
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2602
2602
2603
--
2604
-- Table structure for table `cash_registers`
2605
--
2606
2607
DROP TABLE IF EXISTS `cash_registers`;
2608
CREATE TABLE `cash_registers` (
2609
  `id` int(11) NOT NULL auto_increment, -- unique identifier for each account register
2610
  `name` varchar(24) NOT NULL, -- the user friendly identifier for each account register
2611
  `description` longtext NOT NULL, -- the user friendly description for each account register
2612
  `branch` varchar(10) NOT NULL, -- the foreign key the library this account register belongs
2613
  `branch_default` tinyint(1) NOT NULL DEFAULT 0, -- boolean flag to denote that this till is the branch default
2614
  `starting_float` decimal(28, 6), -- the starting float this account register should be assigned
2615
  `archived` tinyint(1) NOT NULL DEFAULT 0, -- boolean flag to denote if this till is archived or not
2616
  PRIMARY KEY (`id`),
2617
  UNIQUE KEY `name` (`name`,`branch`),
2618
  CONSTRAINT cash_registers_branch FOREIGN KEY (branch) REFERENCES branches (branchcode) ON UPDATE CASCADE ON DELETE CASCADE
2619
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
2620
2603
--
2621
--
2604
-- Table structure for table `accountlines`
2622
-- Table structure for table `accountlines`
2605
--
2623
--
Lines 2620-2625 CREATE TABLE `accountlines` ( Link Here
2620
  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
2638
  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
2621
  `note` MEDIUMTEXT NULL default NULL,
2639
  `note` MEDIUMTEXT NULL default NULL,
2622
  `manager_id` int(11) NULL DEFAULT NULL,
2640
  `manager_id` int(11) NULL DEFAULT NULL,
2641
  `register_id` int(11) NULL DEFAULT NULL,
2623
  `interface` VARCHAR(16) NOT NULL,
2642
  `interface` VARCHAR(16) NOT NULL,
2624
  `branchcode` VARCHAR( 10 ) NULL DEFAULT NULL, -- the branchcode of the library where a payment was made, a manual invoice created, etc.
2643
  `branchcode` VARCHAR( 10 ) NULL DEFAULT NULL, -- the branchcode of the library where a payment was made, a manual invoice created, etc.
2625
  PRIMARY KEY (`accountlines_id`),
2644
  PRIMARY KEY (`accountlines_id`),
Lines 2631-2637 CREATE TABLE `accountlines` ( Link Here
2631
  CONSTRAINT `accountlines_ibfk_borrowers` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE,
2650
  CONSTRAINT `accountlines_ibfk_borrowers` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE,
2632
  CONSTRAINT `accountlines_ibfk_items` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE SET NULL ON UPDATE CASCADE,
2651
  CONSTRAINT `accountlines_ibfk_items` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE SET NULL ON UPDATE CASCADE,
2633
  CONSTRAINT `accountlines_ibfk_borrowers_2` FOREIGN KEY (`manager_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE,
2652
  CONSTRAINT `accountlines_ibfk_borrowers_2` FOREIGN KEY (`manager_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE,
2634
  CONSTRAINT `accountlines_ibfk_branches` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE SET NULL ON UPDATE CASCADE
2653
  CONSTRAINT `accountlines_ibfk_branches` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE SET NULL ON UPDATE CASCADE,
2654
  CONSTRAINT `accountlines_ibfk_registers` FOREIGN KEY (`register_id`) REFERENCES `cash_registers` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
2635
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2655
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2636
2656
2637
--
2657
--
2638
- 

Return to bug 23321