3 # You write good Perl, so you start with Modern::Perl, of course
6 # then you load Packages that could be usefull
8 # Loading this package is usefull if you need to check if a table exist (TableExists)
9 use C4::Update::Database;
11 # you *must* have the sub _get_queries
12 # it returns an array of all SQL that have to be executed
13 # this array will be stored "forever" in your Koha database
14 # thus, you will be able to know which SQL has been executed
15 # at the time of upgrade. Very handy, because since then
16 # your database configuration may have changed and you'll wonder
17 # what has really be executed, not what would be executed today !
19 # put in an array the SQL to execute
20 # put in an array the comments
24 push @comments, "Add sample feature";
25 unless ( C4::Update::Database::TableExists('testtable') ) {
27 CREATE TABLE `testtable` (
28 `id` int(11) NOT NULL AUTO_INCREMENT,
29 `source` text DEFAULT NULL,
30 `text` mediumtext NOT NULL,
31 `timestamp` datetime NOT NULL,
33 ) ENGINE=InnoDB DEFAULT CHARSET=utf8
35 push @comments, qq { * Added the table testtable that did not exist};
37 push @queries, qq{INSERT IGNORE INTO `systempreferences` (variable,value,explanation,options,type) VALUES('testsyspref1',0,'Enable or disable display of Quote of the Day on the OPAC home page',NULL,'YesNo')};
38 push @queries, qq{INSERT IGNORE INTO `systempreferences` (variable,value,explanation,options,type) VALUES('testsyspref2',0,'Enable or disable display of Quote of the Day on the OPAC home page',NULL,'YesNo')};
39 push @comments , qq{ * Added 2 sysprefs};
41 # return queries and comments
42 return { queries => \@queries, comments => \@comments };