I’m currently stuck in a catch 22 with my Django Application. I have to change the type of a column from Varying char to Integer as i’m moving from UUID’s to plain old ID’s (the data is not changing ever as it’s physical constants). Now django threw a Fit originally about not being able to cast from VarChar to Int, so i “helped” it out with:
ALTER TABLE glass_fill ALTER COLUMN id TYPE INTEGER USING CAST(id AS INT);
Now, it says:
django.db.utils.DatabaseError: foreign key constraint "glass_fill_manufacturer_glass_fill_id_fkey" cannot be implemented
DETAIL: Key columns "glass_fill_id" and "id" are of incompatible types: integer and character varying.
Any Ideas?
Note: The glass_fill_manufacturer Table hasn’t been created yet django trys to on syncdb but fails. also the,
ALTER TABLE glass_fill ALTER COLUMN id TYPE INTEGER USING CAST(id AS INT);
line didn’t alter the column as I thought.
glass_fill table schema:
-- Table: glass_fill
-- DROP TABLE glass_fill;
CREATE TABLE glass_fill
(
id character varying(36) NOT NULL,
name character varying(255),
temperature real,
density real,
viscosity real,
conductivity real,
heat_capacity real,
colour text,
CONSTRAINT glass_fill_pkey PRIMARY KEY (id )
)
WITH (
OIDS=FALSE
);
I guess by your text that Django will somehow do it but if it doesn’t: