2đź‘Ť
You current migration works that way:
- Alter column “project_length” to another type.
It is broken because you are making alter that is not supported by PostgreSQL.
You must fix your migration. You can change it to following migration (it will work, but probably can be done easier):
- Create another column project_length_tmp with type you want to project_length have and some default value.
- Make data migration from column project_length to project_lenght_tmp (see data migrations in south docs).
- Remove column project_length.
- Rename column project_length_tmp to project_length.
Kind complicated migration but it have two major strengths:
1. It will work on all databases.
2. It is compatible with your old migration, so you can just override old migration (change the file) and it will be fine.
Approach 2
Another approach to your problem would be just to remove all your migrations and start from scratch. If you have only single deployment of your project it will work fine for you.
0đź‘Ť
You don’t provide any details of the SQL being executed, but it seems unlikely that it’s an ALTER TYPE failing – assuming the SQL is correct.
=> CREATE TABLE t (c_text text, c_date date, c_datearray date[]);
CREATE TABLE
=> INSERT INTO t VALUES ('abc','2011-01-02',ARRAY['2011-01-02'::date,'2011-02-03'::date]);
INSERT 0 1
=> ALTER TABLE t ALTER COLUMN c_text TYPE integer USING (length(c_text));
ALTER TABLE
=> ALTER TABLE t ALTER COLUMN c_date TYPE integer USING (c_date - '2001-01-01');
ALTER TABLE
=> ALTER TABLE t ALTER COLUMN c_datearray TYPE integer USING (array_upper(c_datearray, 1));
ALTER TABLE
=> SELECT * FROM t;
c_text | c_date | c_datearray
--------+--------+-------------
3 | 3653 | 2
(1 row)
There’s not much you can’t do. I’m guessing it’s incorrect SQL being generated from this Django module you are using.
- [Answered ]-Django: 1 database shared by N applications
- [Answered ]-How to generate a responsive PDF with Django?