27 $sql =
"SELECT EXISTS (SELECT 1 FROM pg_catalog.pg_inherits WHERE inhrelid = 'public.uploadtree_a'::regclass::oid);";
28 $row =
RunSQL($sql, $DryRun);
30 foreach ($row as $exist_key => $exist_value) {
33 if (@$exist_value ==
't')
36 echo __FUNCTION__.
": Data previously migrated.\n";
42 $sql =
"select uploadtree_pk from uploadtree limit 1";
43 $row =
RunSQL($sql, $DryRun);
46 echo
"Migrating existing uploadtree data.\n";
49 $sql =
"drop table uploadtree_a";
53 $sql =
"alter table uploadtree rename to uploadtree_a";
57 $sql =
"create table uploadtree (like uploadtree_a INCLUDING DEFAULTS INCLUDING CONSTRAINTS INCLUDING INDEXES)";
61 $sql =
"alter table uploadtree add foreign key (upload_fk) references upload(upload_pk) on delete cascade";
66 $sql =
"SELECT conname from pg_constraint where conname= 'uploadtree_a_upload_fk_fkey';";
67 $row =
RunSQL($sql, $DryRun);
69 $sql =
"alter table uploadtree_a add foreign key (upload_fk) references upload(upload_pk) on delete cascade";
74 $sql =
"update upload set uploadtree_tablename='uploadtree_a' where uploadtree_tablename is null";
78 $sql =
"alter table uploadtree_a inherit uploadtree";
98 echo
"DryRun: $sql\n";
103 $row = pg_fetch_assoc($result);
104 pg_free_result($result);
DBCheckResult($result, $sql, $filenm, $lineno)
Check the postgres result for unexpected errors. If found, treat them as fatal.
Migrate_20_21($DryRun)
Migrate to the uploadtree_a table.
RunSQL($sql, $DryRun)
Run a SQL query and return the result array.
foreach($Options as $Option=> $OptVal) if(0==$reference_flag &&0==$nomos_flag) $PG_CONN