Skip to content

Instantly share code, notes, and snippets.

@bluethon
Created November 1, 2016 03:22
Show Gist options
  • Save bluethon/e6f0c6221bfac6556ef32d4e48303c84 to your computer and use it in GitHub Desktop.
Save bluethon/e6f0c6221bfac6556ef32d4e48303c84 to your computer and use it in GitHub Desktop.
# 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