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

(-)a/installer/data/mysql/atomicupdate/bug_23681_add_debarment_types.perl (+33 lines)
Line 0 Link Here
1
$DBversion = 'XXX';
2
3
if ( CheckVersion( $DBversion ) ) {
4
5
    if ( !TableExists( 'debarment_types' ) ) {
6
        $dbh->do( q|
7
            CREATE TABLE debarment_types (
8
                code varchar(50) NOT NULL PRIMARY KEY,
9
                display_text text NOT NULL,
10
                ronly tinyint(1) NOT NULL DEFAULT 0,
11
                dflt tinyint(1) NOT NULL DEFAULT 0
12
            ) ENGINE=InnoDB  DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
13
        | );
14
        $dbh->do( q|
15
            INSERT INTO debarment_types (code, display_text, ronly, dflt) VALUES
16
            ('MANUAL', 'Manual', 1, 1),
17
            ('OVERDUES', 'Overdues', 1, 0),
18
            ('SUSPENSION', 'Suspension', 1, 0),
19
            ('DISCHARGE', 'Discharge', 1, 0);
20
        |);
21
    }
22
    $dbh->do( q|
23
        ALTER TABLE borrower_debarments
24
        MODIFY COLUMN type varchar(50) NOT NULL
25
    | );
26
    $dbh->do( q|
27
        ALTER TABLE borrower_debarments
28
        ADD CONSTRAINT borrower_debarments_ibfk_2 FOREIGN KEY (type) REFERENCES debarment_types(code) ON DELETE NO ACTION ON UPDATE CASCADE;
29
    | );
30
31
    SetVersion( $DBversion );
32
    print "Upgrade to $DBversion done (Bug 23681 - Add debarment_types)\n";
33
}
(-)a/installer/data/mysql/en/mandatory/patron_restrictions.sql (+5 lines)
Line 0 Link Here
1
INSERT INTO debarment_types (code, display_text, ronly, dflt) VALUES
2
    ('MANUAL', 'Manual', 1, 1),
3
    ('OVERDUES', 'Overdues', 1, 0),
4
    ('SUSPENSION', 'Suspension', 1, 0),
5
    ('DISCHARGE', 'Discharge', 1, 0);
(-)a/installer/data/mysql/en/mandatory/patron_restrictions.txt (+1 lines)
Line 0 Link Here
1
Default Koha system patron restriction types
(-)a/installer/data/mysql/kohastructure.sql (-3 / +11 lines)
Lines 1186-1199 CREATE TABLE `borrower_debarments` ( Link Here
1186
  `borrower_debarment_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique key for the restriction',
1186
  `borrower_debarment_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique key for the restriction',
1187
  `borrowernumber` int(11) NOT NULL COMMENT 'foreign key for borrowers.borrowernumber for patron who is restricted',
1187
  `borrowernumber` int(11) NOT NULL COMMENT 'foreign key for borrowers.borrowernumber for patron who is restricted',
1188
  `expiration` date DEFAULT NULL COMMENT 'expiration date of the restriction',
1188
  `expiration` date DEFAULT NULL COMMENT 'expiration date of the restriction',
1189
  `type` enum('SUSPENSION','OVERDUES','MANUAL','DISCHARGE') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'MANUAL' COMMENT 'type of restriction',
1189
  `type` varchar(50) NOT NULL COMMENT 'type of restriction, FK to debarment_types.code',
1190
  `comment` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'comments about the restriction',
1190
  `comment` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'comments about the restriction',
1191
  `manager_id` int(11) DEFAULT NULL COMMENT 'foreign key for borrowers.borrowernumber for the librarian managing the restriction',
1191
  `manager_id` int(11) DEFAULT NULL COMMENT 'foreign key for borrowers.borrowernumber for the librarian managing the restriction',
1192
  `created` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'date the restriction was added',
1192
  `created` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'date the restriction was added',
1193
  `updated` timestamp NULL DEFAULT NULL COMMENT 'date the restriction was updated',
1193
  `updated` timestamp NULL DEFAULT NULL COMMENT 'date the restriction was updated',
1194
  PRIMARY KEY (`borrower_debarment_id`),
1194
  PRIMARY KEY (`borrower_debarment_id`),
1195
  KEY `borrowernumber` (`borrowernumber`),
1195
  KEY `borrowernumber` (`borrowernumber`),
1196
  CONSTRAINT `borrower_debarments_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE
1196
  CONSTRAINT `borrower_debarments_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE,
1197
  CONSTRAINT `borrower_debarments_ibfk_2` FOREIGN KEY (`type`)  REFERENCES `debarment_types` (`code`) ON DELETE NO ACTION ON UPDATE CASCADE
1197
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1198
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1198
/*!40101 SET character_set_client = @saved_cs_client */;
1199
/*!40101 SET character_set_client = @saved_cs_client */;
1199
1200
Lines 2079-2084 CREATE TABLE `collections_tracking` ( Link Here
2079
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2080
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2080
/*!40101 SET character_set_client = @saved_cs_client */;
2081
/*!40101 SET character_set_client = @saved_cs_client */;
2081
2082
2083
DROP TABLE IF EXISTS `debarment_types`;
2084
CREATE TABLE debarment_types (
2085
    code varchar(50) NOT NULL PRIMARY KEY,
2086
    display_text text NOT NULL,
2087
    ronly tinyint(1) NOT NULL DEFAULT 0,
2088
    dflt tinyint(1) NOT NULL DEFAULT 0
2089
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2090
2082
--
2091
--
2083
-- Table structure for table `columns_settings`
2092
-- Table structure for table `columns_settings`
2084
--
2093
--
2085
- 

Return to bug 23681