Line 0
Link Here
|
|
|
1 |
#!/usr/bin/perl |
2 |
|
3 |
# You write good Perl, so you start with Modern::Perl, of course |
4 |
use Modern::Perl; |
5 |
|
6 |
# then you load Packages that could be usefull |
7 |
use C4::Context; |
8 |
# Loading this package is usefull if you need to check if a table exist (TableExists) |
9 |
use C4::Update::Database; |
10 |
|
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 ! |
18 |
|
19 |
# put in an array the SQL to execute |
20 |
# put in an array the comments |
21 |
sub _get_queries { |
22 |
my @queries; |
23 |
my @comments; |
24 |
push @comments, "Add sample feature"; |
25 |
unless ( C4::Update::Database::TableExists('testtable') ) { |
26 |
push @queries, qq{ |
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, |
32 |
PRIMARY KEY (`id`) |
33 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
34 |
}; |
35 |
push @comments, qq { * Added the table testtable that did not exist}; |
36 |
} |
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}; |
40 |
|
41 |
# return queries and comments |
42 |
return { queries => \@queries, comments => \@comments }; |
43 |
} |
44 |
1; |