Bug 7317: Rewrite atomicupdate file
authorTomas Cohen Arazi <tomascohen@theke.io>
Wed, 25 Oct 2017 18:34:34 +0000 (15:34 -0300)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 9 Nov 2017 14:42:14 +0000 (11:42 -0300)
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Benjamin Rokseth <benjamin.rokseth@kul.oslo.kommune.no>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
installer/data/mysql/atomicupdate/bug_7317_ill.perl [new file with mode: 0644]
installer/data/mysql/atomicupdate/ill_tables.sql [deleted file]

diff --git a/installer/data/mysql/atomicupdate/bug_7317_ill.perl b/installer/data/mysql/atomicupdate/bug_7317_ill.perl
new file mode 100644 (file)
index 0000000..4757d09
--- /dev/null
@@ -0,0 +1,69 @@
+$DBversion = 'XXX';
+if( CheckVersion( $DBversion ) ) {
+
+    if ( !TableExists( 'illrequests' ) ) {
+        $dbh->do(q{
+            CREATE TABLE illrequests (
+               illrequest_id serial PRIMARY KEY,           -- ILL request number
+               borrowernumber integer DEFAULT NULL,        -- Patron associated with request
+               biblio_id integer DEFAULT NULL,             -- Potential bib linked to request
+               branchcode varchar(50) NOT NULL,            -- The branch associated with the request
+               status varchar(50) DEFAULT NULL,            -- Current Koha status of request
+               placed date DEFAULT NULL,                   -- Date the request was placed
+               replied date DEFAULT NULL,                  -- Last API response
+               updated timestamp DEFAULT CURRENT_TIMESTAMP -- Last modification to request
+                 ON UPDATE CURRENT_TIMESTAMP,
+               completed date DEFAULT NULL,                -- Date the request was completed
+               medium varchar(30) DEFAULT NULL,            -- The Koha request type
+               accessurl varchar(500) DEFAULT NULL,        -- Potential URL for accessing item
+               cost varchar(20) DEFAULT NULL,              -- Cost of request
+               notesopac text DEFAULT NULL,                -- Patron notes attached to request
+               notesstaff text DEFAULT NULL,               -- Staff notes attached to request
+               orderid varchar(50) DEFAULT NULL,           -- Backend id attached to request
+               backend varchar(20) DEFAULT NULL,           -- The backend used to create request
+               CONSTRAINT `illrequests_bnfk`
+                 FOREIGN KEY (`borrowernumber`)
+                 REFERENCES `borrowers` (`borrowernumber`)
+                 ON UPDATE CASCADE ON DELETE CASCADE,
+               CONSTRAINT `illrequests_bcfk_2`
+                 FOREIGN KEY (`branchcode`)
+                 REFERENCES `branches` (`branchcode`)
+                 ON UPDATE CASCADE ON DELETE CASCADE
+           ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+        });
+    }
+
+    if ( !TableExists( 'illrequestattributes' ) ) {
+        $dbh->do(q{
+            CREATE TABLE illrequestattributes (
+                illrequest_id bigint(20) unsigned NOT NULL, -- ILL request number
+                type varchar(200) NOT NULL,                 -- API ILL property name
+                value text NOT NULL,                        -- API ILL property value
+                PRIMARY KEY  (`illrequest_id`,`type`),
+                CONSTRAINT `illrequestattributes_ifk`
+                  FOREIGN KEY (illrequest_id)
+                  REFERENCES `illrequests` (`illrequest_id`)
+                  ON UPDATE CASCADE ON DELETE CASCADE
+            ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+        });
+    }
+
+    # System preferences
+    $dbh->do(q{
+        INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES
+            ('ILLModule','0','If ON, enables the interlibrary loans module.','','YesNo');
+    });
+
+    $dbh->do(q{
+        INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES
+            ('ILLModuleCopyrightClearance','','70|10','Enter text to enable the copyright clearance stage of request creation. Text will be displayed','Textarea');
+    });
+    # userflags
+    $dbh->do(q{
+        INSERT IGNORE INTO userflags (bit,flag,flagdesc,defaulton) VALUES
+            (22,'ill','The Interlibrary Loans Module',0);
+    });
+
+    SetVersion( $DBversion );
+    print "Upgrade to $DBversion done (Bug 7317 - Add an Interlibrary Loan Module to Circulation and OPAC)\n";
+}
diff --git a/installer/data/mysql/atomicupdate/ill_tables.sql b/installer/data/mysql/atomicupdate/ill_tables.sql
deleted file mode 100644 (file)
index cab65f2..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
--- ILL Requests
-
-CREATE TABLE illrequests (
-    illrequest_id serial PRIMARY KEY,           -- ILL request number
-    borrowernumber integer DEFAULT NULL,        -- Patron associated with request
-    biblio_id integer DEFAULT NULL,             -- Potential bib linked to request
-    branchcode varchar(50) NOT NULL,            -- The branch associated with the request
-    status varchar(50) DEFAULT NULL,            -- Current Koha status of request
-    placed date DEFAULT NULL,                   -- Date the request was placed
-    replied date DEFAULT NULL,                  -- Last API response
-    updated timestamp DEFAULT CURRENT_TIMESTAMP -- Last modification to request
-      ON UPDATE CURRENT_TIMESTAMP,
-    completed date DEFAULT NULL,                -- Date the request was completed
-    medium varchar(30) DEFAULT NULL,            -- The Koha request type
-    accessurl varchar(500) DEFAULT NULL,        -- Potential URL for accessing item
-    cost varchar(20) DEFAULT NULL,              -- Cost of request
-    notesopac text DEFAULT NULL,                -- Patron notes attached to request
-    notesstaff text DEFAULT NULL,               -- Staff notes attached to request
-    orderid varchar(50) DEFAULT NULL,           -- Backend id attached to request
-    backend varchar(20) DEFAULT NULL,           -- The backend used to create request
-    CONSTRAINT `illrequests_bnfk`
-      FOREIGN KEY (`borrowernumber`)
-      REFERENCES `borrowers` (`borrowernumber`)
-      ON UPDATE CASCADE ON DELETE CASCADE,
-    CONSTRAINT `illrequests_bcfk_2`
-      FOREIGN KEY (`branchcode`)
-      REFERENCES `branches` (`branchcode`)
-      ON UPDATE CASCADE ON DELETE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-
--- ILL Request Attributes
-
-CREATE TABLE illrequestattributes (
-    illrequest_id bigint(20) unsigned NOT NULL, -- ILL request number
-    type varchar(200) NOT NULL,                 -- API ILL property name
-    value text NOT NULL,                        -- API ILL property value
-    PRIMARY KEY  (`illrequest_id`,`type`),
-    CONSTRAINT `illrequestattributes_ifk`
-      FOREIGN KEY (illrequest_id)
-      REFERENCES `illrequests` (`illrequest_id`)
-      ON UPDATE CASCADE ON DELETE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-
--- System preferences
-
-INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES
-       ('ILLModule','0','If ON, enables the interlibrary loans module.','','YesNo');
-
-INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES
-       ('ILLModuleCopyrightClearance','','70|10','Enter text to enable the copyright clearance stage of request creation. Text will be displayed','Textarea');
-
--- Userflags
-
-INSERT INTO userflags (bit,flag,flagdesc,defaulton)
-VALUES (22,'ill','The Interlibrary Loans Module',0);