migrations: don't check existing type before jsonb migration (#43131)
This commit is contained in:
parent
d0b6c50cb2
commit
247f091b80
|
@ -35,16 +35,9 @@ class EnsureJsonbType(Operation):
|
|||
_, column_name = field.get_attname_column()
|
||||
with schema_editor.connection.cursor() as cursor:
|
||||
cursor.execute(
|
||||
'SELECT data_type FROM information_schema.columns WHERE table_name = %s AND '
|
||||
'column_name = %s;', (table_name, column_name)
|
||||
'ALTER TABLE {table} ALTER COLUMN {col} TYPE jsonb USING {col}::jsonb;'
|
||||
.format(table=table_name, col=column_name)
|
||||
)
|
||||
current_type = cursor.fetchone()[0].lower()
|
||||
if current_type != 'jsonb':
|
||||
assert current_type in ('json', 'text')
|
||||
cursor.execute(
|
||||
'ALTER TABLE {table} ALTER COLUMN {col} TYPE jsonb USING {col}::jsonb;'
|
||||
.format(table=table_name, col=column_name)
|
||||
)
|
||||
|
||||
def database_backwards(self, app_label, schema_editor, from_state, to_state):
|
||||
pass
|
||||
|
|
Loading…
Reference in New Issue