C4::Installer
use C4::Installer; my $installer = C4::Installer->new(); my $all_languages = getAllLanguages(); my $error = $installer->load_db_schema(); my $list; #fill $list with list of sql files my ($fwk_language, $error_list) = $installer->load_sql_in_order($all_languages, @$list); $installer->set_version_syspref(); $installer->set_marcflavour_syspref('MARC21');
my $installer = C4::Installer->new();
Creates a new installer.
my ($defaulted_to_en, $list) = $installer->marc_framework_sql_list($lang, $marcflavour);
Returns in $list
a structure listing the filename, description, section, and mandatory/optional status of MARC framework scripts available for $lang
and $marcflavour
.
If the $defaulted_to_en
return value is true, no scripts are available for language $lang
and the 'en' ones are returned.
my ($defaulted_to_en, $list) = $installer->sample_data_sql_list($lang);
Returns in $list
a structure listing the filename, description, section, and mandatory/optional status of sample data scripts available for $lang
. If the $defaulted_to_en
return value is true, no scripts are available for language $lang
and the 'en' ones are returned.
my $error = $installer->load_db_schema();
Loads the SQL script that creates Koha's tables and indexes. The return value is a string containing error messages reported by the load.
my ($fwk_language, $list) = $installer->load_sql_in_order($all_languages, @sql_list);
Given a list of SQL scripts supplied in @sql_list
, loads each of them into the database and sets the FrameworksLoaded system preference to names of the scripts that were loaded.
The SQL files are loaded in alphabetical order by filename (not including directory path). This means that dependencies among the scripts are to be resolved by carefully naming them, keeping in mind that the directory name does *not* currently count.
FIXME: this is a rather delicate way of dealing with dependencies between the install scripts.
The return value $list
is an arrayref containing a hashref for each "level" or directory containing SQL scripts; the hashref in turns contains a list of hashrefs containing a list of each script load and any error messages associated with the loading of each script.
FIXME: The $fwk_language
code probably doesn't belong and needs to be moved to a different method.
$installer->set_marcflavour_syspref($marcflavour);
Set the 'marcflavour' system preference. The incoming $marcflavour
references to a subdirectory of installer/data/$dbms/$lang/marcflavour, and is normalized to MARC21 or UNIMARC.
FIXME: this method assumes that the MARC flavour will be either MARC21 or UNIMARC.
$installer->set_version_syspref();
Set or update the 'Version' system preference to the current Koha software version.
$installer->set_languages_syspref();
Add the installation language to 'language' and 'OPACLanguages' system preferences if different from 'en'
my $query_info = $installer->process_yml_table($table);
Analyzes a table loaded in YAML format. Returns the values required to build an insert statement.
my $error = $installer->load_sql($filename);
Runs the specified input file using a sql loader DBIx::RunSQL, or a yaml loader Returns any strings sent to STDERR
# FIXME This should be improved: sometimes the caller and load_sql warn the same error.
my $filename = $installer->get_file_path_from_name('script_name');
searches through the set of known SQL scripts and finds the fully qualified path name for the script that mathches the input.
returns undef if no match was found.
Drop all foreign keys of the table $table
Transform the Koha version from a 4 parts string to a number, with just 1 .
set the DBversion in the systempreferences
Check whether a given update should be run when passed the proposed version number. The update will always be run if the proposed version is greater than the current database version and less than or equal to the version in kohaversion.pl. The update is also run if the version contains XXX, though this behavior will be changed following the adoption of non-linear updates as implemented in bug 7167.
Return the number of tables with row_format that is not Dynamic
C4::Installer is a refactoring of logic originally from installer/installer.pl, which was originally written by Henri-Damien Laurant.
Koha Development Team <http://koha-community.org/>
Galen Charlton <galen.charlton@liblime.com>