From: Dan Scott Date: Sun, 23 Sep 2012 01:51:59 +0000 (-0400) Subject: Avoid specific version mention for database extensions X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=40e0fcad6b3c5a102ca7569a7a9978ae6a400172;p=evergreen%2Fpines.git Avoid specific version mention for database extensions As tsbere pointed out, the 9.1 database script will be used for every version after 9.1... which makes it confusing to have a version number. As the primary reason for the difference is the switch to extensions instead of contrib modules, use a name that flags that difference. Convert the 9.1 full-text search configuration into a symbolic link instead of maintaining a separate copy of the file. Given that the pre-9.1 database script was focused on the creation of PostgreSQL contribs, call it that, rather than the (now confusingly) generic "create_database.sql" that existed from a time when contribs ruled the earth and extensions were mere fantasy. Adjust eg_db_config.sql for these changes as well - including the command line switches. Signed-off-by: Dan Scott Signed-off-by: Thomas Berezansky --- diff --git a/Open-ILS/src/sql/Pg/000.english.pg91.fts-config.sql b/Open-ILS/src/sql/Pg/000.english.pg91.fts-config.sql deleted file mode 100644 index 7ddce06b73..0000000000 --- a/Open-ILS/src/sql/Pg/000.english.pg91.fts-config.sql +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2004-2008 Georgia Public Library Service - * Copyright (C) 2008 Equinox Software, Inc., Laurentian University - * Mike Rylander - * Dan Scott - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - */ - -BEGIN; - -SET search_path = public, pg_catalog; - -CREATE OR REPLACE FUNCTION oils_tsearch2 () RETURNS TRIGGER AS $$ -BEGIN - NEW.index_vector = to_tsvector((TG_ARGV[0])::regconfig, NEW.value); - RETURN NEW; -END; -$$ LANGUAGE PLPGSQL; - -DROP TEXT SEARCH DICTIONARY IF EXISTS english_nostop CASCADE; - -CREATE TEXT SEARCH DICTIONARY english_nostop (TEMPLATE=pg_catalog.snowball, language='english'); -COMMENT ON TEXT SEARCH DICTIONARY english_nostop IS 'English snowball stemmer with no stopwords for ASCII words only.'; - -CREATE TEXT SEARCH CONFIGURATION title ( COPY = pg_catalog.english ); -ALTER TEXT SEARCH CONFIGURATION title ALTER MAPPING FOR word, hword, hword_part WITH pg_catalog.simple; -ALTER TEXT SEARCH CONFIGURATION title ALTER MAPPING FOR asciiword, asciihword, hword_asciipart WITH english_nostop; -CREATE TEXT SEARCH CONFIGURATION author ( COPY = title ); -CREATE TEXT SEARCH CONFIGURATION subject ( COPY = title ); -CREATE TEXT SEARCH CONFIGURATION keyword ( COPY = title ); -CREATE TEXT SEARCH CONFIGURATION identifier ( COPY = title ); -CREATE TEXT SEARCH CONFIGURATION series ( COPY = title ); -CREATE TEXT SEARCH CONFIGURATION "default" ( COPY = title ); - -COMMIT; diff --git a/Open-ILS/src/sql/Pg/000.english.pg91.fts-config.sql b/Open-ILS/src/sql/Pg/000.english.pg91.fts-config.sql new file mode 120000 index 0000000000..fd3fe587ae --- /dev/null +++ b/Open-ILS/src/sql/Pg/000.english.pg91.fts-config.sql @@ -0,0 +1 @@ +000.english.pg90.fts-config.sql \ No newline at end of file diff --git a/Open-ILS/src/sql/Pg/create_database.sql b/Open-ILS/src/sql/Pg/create_database.sql deleted file mode 100644 index aec933e708..0000000000 --- a/Open-ILS/src/sql/Pg/create_database.sql +++ /dev/null @@ -1,30 +0,0 @@ --- This file is intended to be called by eg_db_config.pl - --- If manually calling: --- Connect to the postgres database initially --- Specify the database to create as -vdb_name=DATABASE --- Specify the postgres contrib directory as -vcontrib_dir=CONTRIBDIR --- You can get the contrib directory using pg_config --sharedir and adding a /contrib to it - --- NOTE: This file does not do transactions --- This is intentional. Please do not wrap in BEGIN/COMMIT. -DROP DATABASE IF EXISTS :db_name; - -CREATE DATABASE :db_name TEMPLATE template0 ENCODING 'UNICODE' LC_COLLATE 'C' LC_CTYPE 'C'; - -\connect :db_name - ---CREATE LANGUAGE plperl; -CREATE LANGUAGE plperlu; - --- This dance is because :variable/blah doesn't seem to work when doing \i --- But it does when doing \set --- So we \set to a single variable, then use that single variable with \i -\set load_file :contrib_dir/tablefunc.sql -\i :load_file -\set load_file :contrib_dir/tsearch2.sql -\i :load_file -\set load_file :contrib_dir/pgxml.sql -\i :load_file -\set load_file :contrib_dir/hstore.sql -\i :load_file diff --git a/Open-ILS/src/sql/Pg/create_database_9_1.sql b/Open-ILS/src/sql/Pg/create_database_9_1.sql deleted file mode 100644 index dd6066fbbf..0000000000 --- a/Open-ILS/src/sql/Pg/create_database_9_1.sql +++ /dev/null @@ -1,23 +0,0 @@ --- This file is intended to be called by eg_db_config.pl - --- If manually calling: --- Connect to the postgres database initially --- Specify the database to create as -vdb_name=DATABASE --- Specify the postgres contrib directory as -vcontrib_dir=CONTRIBDIR --- You can get the contrib directory using pg_config --sharedir and adding a /contrib to it - --- NOTE: This file does not do transactions --- This is intentional. Please do not wrap in BEGIN/COMMIT. -DROP DATABASE IF EXISTS :db_name; - -CREATE DATABASE :db_name TEMPLATE template0 ENCODING 'UNICODE' LC_COLLATE 'C' LC_CTYPE 'C'; - -\connect :db_name - ---CREATE LANGUAGE plperl; -CREATE LANGUAGE plperlu; - -CREATE EXTENSION tablefunc; -CREATE EXTENSION tsearch2; -CREATE EXTENSION xml2; -CREATE EXTENSION hstore; diff --git a/Open-ILS/src/sql/Pg/create_database_contribs.sql b/Open-ILS/src/sql/Pg/create_database_contribs.sql new file mode 100644 index 0000000000..aec933e708 --- /dev/null +++ b/Open-ILS/src/sql/Pg/create_database_contribs.sql @@ -0,0 +1,30 @@ +-- This file is intended to be called by eg_db_config.pl + +-- If manually calling: +-- Connect to the postgres database initially +-- Specify the database to create as -vdb_name=DATABASE +-- Specify the postgres contrib directory as -vcontrib_dir=CONTRIBDIR +-- You can get the contrib directory using pg_config --sharedir and adding a /contrib to it + +-- NOTE: This file does not do transactions +-- This is intentional. Please do not wrap in BEGIN/COMMIT. +DROP DATABASE IF EXISTS :db_name; + +CREATE DATABASE :db_name TEMPLATE template0 ENCODING 'UNICODE' LC_COLLATE 'C' LC_CTYPE 'C'; + +\connect :db_name + +--CREATE LANGUAGE plperl; +CREATE LANGUAGE plperlu; + +-- This dance is because :variable/blah doesn't seem to work when doing \i +-- But it does when doing \set +-- So we \set to a single variable, then use that single variable with \i +\set load_file :contrib_dir/tablefunc.sql +\i :load_file +\set load_file :contrib_dir/tsearch2.sql +\i :load_file +\set load_file :contrib_dir/pgxml.sql +\i :load_file +\set load_file :contrib_dir/hstore.sql +\i :load_file diff --git a/Open-ILS/src/sql/Pg/create_database_extensions.sql b/Open-ILS/src/sql/Pg/create_database_extensions.sql new file mode 100644 index 0000000000..dd6066fbbf --- /dev/null +++ b/Open-ILS/src/sql/Pg/create_database_extensions.sql @@ -0,0 +1,23 @@ +-- This file is intended to be called by eg_db_config.pl + +-- If manually calling: +-- Connect to the postgres database initially +-- Specify the database to create as -vdb_name=DATABASE +-- Specify the postgres contrib directory as -vcontrib_dir=CONTRIBDIR +-- You can get the contrib directory using pg_config --sharedir and adding a /contrib to it + +-- NOTE: This file does not do transactions +-- This is intentional. Please do not wrap in BEGIN/COMMIT. +DROP DATABASE IF EXISTS :db_name; + +CREATE DATABASE :db_name TEMPLATE template0 ENCODING 'UNICODE' LC_COLLATE 'C' LC_CTYPE 'C'; + +\connect :db_name + +--CREATE LANGUAGE plperl; +CREATE LANGUAGE plperlu; + +CREATE EXTENSION tablefunc; +CREATE EXTENSION tsearch2; +CREATE EXTENSION xml2; +CREATE EXTENSION hstore; diff --git a/Open-ILS/src/support-scripts/eg_db_config.pl b/Open-ILS/src/support-scripts/eg_db_config.pl index 93c53fa0b4..e98710f331 100755 --- a/Open-ILS/src/support-scripts/eg_db_config.pl +++ b/Open-ILS/src/support-scripts/eg_db_config.pl @@ -32,8 +32,8 @@ my $offline_file = ''; my $prefix = ''; my $sysconfdir = ''; my $pg_contribdir = ''; -my $create_db_sql = ''; -my $create_db_sql_9_1 = ''; +my $create_db_sql_contribs = ''; +my $create_db_sql_extensions = ''; my @services; my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); @@ -127,7 +127,7 @@ sub get_settings { $settings->{pw} = $settings->{pw} || $opensrf_config->findnodes($pw); } -=item create_database() - Creates the database using create_database.sql +=item create_database() - Creates the database using create_database_contribs.sql =cut sub create_database { my $settings = shift; @@ -140,13 +140,13 @@ sub create_database { chomp $temp[0]; my $pgversion = $temp[0]; my $cmd; - # If it looks like it is 9.1 or greater, use create_database_9_1.sql - # Otherwise use create_database.sql + # If it looks like it is 9.1 or greater, use create_database_extensions.sql + # Otherwise use create_database_contribs.sql if($pgversion >= '91') { - $cmd = 'psql -vdb_name=' . $settings->{db} . ' -d postgres -f ' . $create_db_sql_9_1; + $cmd = 'psql -vdb_name=' . $settings->{db} . ' -d postgres -f ' . $create_db_sql_extensions; } else { $cmd = 'psql -vdb_name=' . $settings->{db} . ' -vcontrib_dir=' . $pg_contribdir . - ' -d postgres -f ' . $create_db_sql; + ' -d postgres -f ' . $create_db_sql_contribs; } my @output = `$cmd 2>&1`; if(grep(/(ERROR|No such file or directory)/,@output)) { @@ -221,8 +221,8 @@ GetOptions("create-schema" => \$cschema, "config-file=s" => \$config_file, "build-db-file=s" => \$build_db_sh, "pg-contrib-dir=s" => \$pg_contribdir, - "create-db-sql=s" => \$create_db_sql, - "create-db-sql-9-1=s" => \$create_db_sql_9_1, + "create-db-sql-contribs=s" => \$create_db_sql_contribs, + "create-db-sql-extensions=s" => \$create_db_sql_extensions, "pg-config=s" => \$pgconfig, "admin-user=s" => \$admin_user, "admin-password=s" => \$admin_pw, @@ -265,12 +265,12 @@ if (!$pg_contribdir) { $pg_contribdir = File::Spec->catdir($temp[0], 'contrib'); } -if (!$create_db_sql) { - $create_db_sql = File::Spec->catfile($script_dir, '../sql/Pg/create_database.sql'); +if (!$create_db_sql_contribs) { + $create_db_sql_contribs = File::Spec->catfile($script_dir, '../sql/Pg/create_database_contribs.sql'); } -if (!$create_db_sql_9_1) { - $create_db_sql_9_1 = File::Spec->catfile($script_dir, '../sql/Pg/create_database_9_1.sql'); +if (!$create_db_sql_extensions) { + $create_db_sql_extensions = File::Spec->catfile($script_dir, '../sql/Pg/create_database_extensions.sql'); } if (!$offline_file) {