Created
November 1, 2016 03:22
-
-
Save bluethon/e6f0c6221bfac6556ef32d4e48303c84 to your computer and use it in GitHub Desktop.
From http://stackoverflow.com/questions/22311427/django-south-migration-cant-cast-the-column-type-wants-me-to-use-using
修改CASE 到END部分
从`sqlmigrate app 0003`中获取sql语句
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Changing field 'MyTable.associated' | |
# db.alter_column(u'data_mytable', 'associated', | |
# self.gf('django.db.models.fields.IntegerField')() | |
# ) | |
db.execute( | |
'ALTER TABLE "data_mytable" ' | |
'ALTER COLUMN "associated" DROP DEFAULT, ' | |
'ALTER COLUMN "associated" DROP NOT NULL, ' | |
'ALTER COLUMN "associated" TYPE INTEGER ' | |
'USING ' | |
'CASE ' | |
' WHEN FALSE THEN 0 ELSE 1 ' | |
'END' | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment