Clean up build errors when creating/recreating database schema
authordbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sat, 12 Mar 2011 23:37:45 +0000 (23:37 +0000)
committerdbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sat, 12 Mar 2011 23:37:45 +0000 (23:37 +0000)
Dropping the evergreen schema cascaded and wiped out some previously
defined functions, so move it ahead of the other functions. (And maybe
we can start moving those public functions into the evergreen schema?)

DROP AGGREGATE IF EXISTS exists on any version of PostgreSQL that we
care about for Evergreen 2.0, so we can use it to avoid false errors
during schema creation.

FTS config was complaining about public.english_nostop in the ALTER
statement, so remove the schema qualification. This seems to have
been there for a long time?

Use IF EXISTS when dropping the unapi schema to avoid an error.

git-svn-id: svn://svn.open-ils.org/ILS/trunk@19723 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/sql/Pg/000.english.pg84.fts-config.sql
Open-ILS/src/sql/Pg/000.english.pg90.fts-config.sql
Open-ILS/src/sql/Pg/002.functions.aggregate.sql
Open-ILS/src/sql/Pg/002.functions.general.sql
Open-ILS/src/sql/Pg/990.schema.unapi.sql
Open-ILS/src/sql/Pg/build-db.sh

index b0b1157..e4e50e4 100644 (file)
@@ -32,7 +32,7 @@ COMMENT ON TEXT SEARCH DICTIONARY english_nostop IS 'English snowball stemmer wi
 
 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 public.english_nostop;
+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 );
index b0b1157..e4e50e4 100644 (file)
@@ -32,7 +32,7 @@ COMMENT ON TEXT SEARCH DICTIONARY english_nostop IS 'English snowball stemmer wi
 
 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 public.english_nostop;
+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 );
index 70dc588..fb0c311 100644 (file)
  *
  */
 
--- Allow these to fail gracelessly outside the transaction
--- because PostgreSQL 8.1 does not support IF EXISTS
-DROP AGGREGATE array_accum(anyelement) CASCADE;
-DROP AGGREGATE public.first(anyelement) CASCADE;
-DROP AGGREGATE public.last(anyelement) CASCADE;
-DROP AGGREGATE public.agg_text(text) CASCADE;
-DROP AGGREGATE public.agg_tsvector(tsvector) CASCADE;
-
 BEGIN;
 
+DROP AGGREGATE IF EXISTS array_accum(anyelement) CASCADE;
+DROP AGGREGATE IF EXISTS public.first(anyelement) CASCADE;
+DROP AGGREGATE IF EXISTS public.last(anyelement) CASCADE;
+DROP AGGREGATE IF EXISTS public.agg_text(text) CASCADE;
+DROP AGGREGATE IF EXISTS public.agg_tsvector(tsvector) CASCADE;
+
 CREATE AGGREGATE array_accum (
        sfunc = array_append,
        basetype = anyelement,
index 659adcc..f9407a5 100644 (file)
@@ -1,7 +1,14 @@
 -- Rather than polluting the public schema with general Evergreen
 -- functions, carve out a dedicated schema
+
+DROP SCHEMA IF EXISTS evergreen CASCADE;
+
+BEGIN;
+
 CREATE SCHEMA evergreen;
 
 CREATE OR REPLACE FUNCTION evergreen.lowercase( TEXT ) RETURNS TEXT AS $$
     return lc(shift);
 $$ LANGUAGE PLPERLU STRICT IMMUTABLE;
+
+COMMIT;
index a189c57..e7abed5 100644 (file)
@@ -1,4 +1,4 @@
-DROP SCHEMA unapi CASCADE;
+DROP SCHEMA IF EXISTS unapi CASCADE;
 
 BEGIN;
 CREATE SCHEMA unapi;
index bc988d7..0e8f6f8 100755 (executable)
@@ -83,10 +83,10 @@ ordered_file_list="
 
   001.schema.offline.sql
 
+  002.functions.general.sql
   002.schema.config.sql
   002.functions.aggregate.sql
   002.functions.config.sql
-  002.functions.general.sql
 
   005.schema.actors.sql
   006.schema.permissions.sql