londiste.upgrade_schema: move table_info check upgrade here
authorMarko Kreen <markokr@gmail.com>
Fri, 16 Sep 2011 10:45:26 +0000 (13:45 +0300)
committerMarko Kreen <markokr@gmail.com>
Fri, 16 Sep 2011 10:45:26 +0000 (13:45 +0300)
sql/londiste/functions/londiste.upgrade_schema.sql
upgrade/src/londiste.table_info.sql [deleted file]

index 8da164fbdb144b9a9dd8fa55521755484103b58c..455fe4146e7e575e5bf722527f7b117fabdc790f 100644 (file)
@@ -5,8 +5,21 @@ returns int4 as $$
 declare
     cnt int4 = 0;
 begin
+
+    -- table_info: check (dropped_ddl is null or merge_state in ('in-copy', 'catching-up'))
+    perform 1 from information_schema.check_constraints
+      where constraint_schema = 'londiste'
+        and constraint_name = 'table_info_check'
+        and position('in-copy' in check_clause) > 0
+        and position('catching' in check_clause) = 0;
+    if found then
+        alter table londiste.table_info drop constraint table_info_check;
+        alter table londiste.table_info add constraint table_info_check
+            check (dropped_ddl is null or merge_state in ('in-copy', 'catching-up'));
+        cnt := cnt + 1;
+    end if;
+
     return cnt;
 end;
 $$ language plpgsql;
 
-
diff --git a/upgrade/src/londiste.table_info.sql b/upgrade/src/londiste.table_info.sql
deleted file mode 100644 (file)
index b199bfd..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-ALTER TABLE londiste.table_info DROP CONSTRAINT table_info_check;
-ALTER TABLE londiste.table_info ADD CHECK (dropped_ddl is null or merge_state in ('in-copy', 'catching-up'));