summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Kreen2011-09-16 10:45:26 +0000
committerMarko Kreen2011-09-16 10:45:26 +0000
commit108590ef2ce89d226da0cf1e9e4a3cb7d1afc4e4 (patch)
treed439c7b36b10c87bafd02750a5f1daba3de17aa7
parentc2f7264869cc2bc5ffdde272ea20f441b7d884e2 (diff)
londiste.upgrade_schema: move table_info check upgrade here
-rw-r--r--sql/londiste/functions/londiste.upgrade_schema.sql15
-rw-r--r--upgrade/src/londiste.table_info.sql2
2 files changed, 14 insertions, 3 deletions
diff --git a/sql/londiste/functions/londiste.upgrade_schema.sql b/sql/londiste/functions/londiste.upgrade_schema.sql
index 8da164fb..455fe414 100644
--- a/sql/londiste/functions/londiste.upgrade_schema.sql
+++ b/sql/londiste/functions/londiste.upgrade_schema.sql
@@ -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
index b199bfd6..00000000
--- a/upgrade/src/londiste.table_info.sql
+++ /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'));