From af36b6d36681f0eddaa6aa9f15ba27d302c55d33 Mon Sep 17 00:00:00 2001
From: gpawel <gpawel>
Date: Fri, 22 Jun 2012 13:05:25 +0000
Subject: [PATCH] filter not needed schema lines during migration

SVN: 25835
---
 .../postgresql/DumpPreparator.java            | 20 ++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/dbmigration/source/java/ch/systemsx/cisd/dbmigration/postgresql/DumpPreparator.java b/dbmigration/source/java/ch/systemsx/cisd/dbmigration/postgresql/DumpPreparator.java
index d96194d1667..a73bcec3003 100644
--- a/dbmigration/source/java/ch/systemsx/cisd/dbmigration/postgresql/DumpPreparator.java
+++ b/dbmigration/source/java/ch/systemsx/cisd/dbmigration/postgresql/DumpPreparator.java
@@ -59,16 +59,18 @@ import ch.systemsx.cisd.dbmigration.SimpleTableMetaData;
 public class DumpPreparator
 {
     private static final String MAC_POSTGRESQL_91PATH = "/opt/local/lib/postgresql91/bin/";
+
     private static final String MAC_POSTGRESQL_90_PATH = "/opt/local/lib/postgresql90/bin/";
 
     private static final String DUMP_EXEC = "pg_dump";
-    
+
     private static final String PSQL_EXEC = "psql";
 
-    private static final Set<String> FILTERED_SCHEMA_LINES =
-            new LinkedHashSet<String>(Arrays.asList("SET client_encoding = 'UTF8';",
+    private static final Set<String> FILTERED_SCHEMA_LINES = new LinkedHashSet<String>(
+            Arrays.asList("SET client_encoding = 'UTF8';",
                     "COMMENT ON SCHEMA public IS 'Standard public schema';",
-                    "CREATE PROCEDURAL LANGUAGE plpgsql;"));
+                    "CREATE PROCEDURAL LANGUAGE plpgsql;",
+                    "CREATE OR REPLACE PROCEDURAL LANGUAGE plpgsql;"));
 
     public static void main(String[] args) throws IOException
     {
@@ -149,7 +151,7 @@ public class DumpPreparator
     {
         return getExecutable(PSQL_EXEC);
     }
-    
+
     private static String getExecutable(String executable)
     {
         final Set<String> paths = OSUtilities.getSafeOSPath();
@@ -359,8 +361,8 @@ public class DumpPreparator
         {
             String databaseVersion = getDatabaseVersion();
             File folder = createDestinationFolder();
-            writeTo(folder, "schema-" + databaseVersion + ".sql", Arrays.asList(schemaScript
-                    .toString()));
+            writeTo(folder, "schema-" + databaseVersion + ".sql",
+                    Arrays.asList(schemaScript.toString()));
             ArrayList<SimpleTableMetaData> metaData = new ArrayList<SimpleTableMetaData>();
             for (Table table : tables.values())
             {
@@ -372,8 +374,8 @@ public class DumpPreparator
                     writeTo(folder, tableMetaData.getTableFileName(), rows);
                 }
             }
-            writeTo(folder, "finish-" + databaseVersion + ".sql", Arrays.asList(finishScript
-                    .toString()));
+            writeTo(folder, "finish-" + databaseVersion + ".sql",
+                    Arrays.asList(finishScript.toString()));
             return new SimpleDatabaseMetaData(databaseVersion, metaData);
         }
 
-- 
GitLab