Naz Gassiep <naz@mira.net> writes:
> I'm trying to remove a schema and move all the tables to another schema.
> I've manually run alter table on every table to move them, however all
> the foreign keys still reference the old schema,
What? It works fine for me:
regression=# create schema s1;
CREATE SCHEMA
regression=# create table s1.t1(f1 int primary key);
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "t1_pkey" for table "t1"
CREATE TABLE
regression=# create table s1.t2(f1 int references s1.t1);
CREATE TABLE
regression=# create schema s2;
CREATE SCHEMA
regression=# alter table s1.t1 set schema s2;
ALTER TABLE
regression=# \d s1.t2
Table "s1.t2"
Column | Type | Modifiers
--------+---------+-----------
f1 | integer |
Foreign-key constraints:
"t2_f1_fkey" FOREIGN KEY (f1) REFERENCES s2.t1(f1)
regards, tom lane