This commit is contained in:
Robert Lechte 2022-09-13 23:12:40 +10:00
parent 2c38e8c483
commit 3ff01951b2
3 changed files with 4 additions and 5 deletions

View File

@ -122,7 +122,7 @@ def statements_from_differences(
for k, v in added.items():
if not has_uncreated_dependencies(v, pending_creations):
if k in pending_creations:
if hasattr(v, 'safer_create_statements'):
if hasattr(v, "safer_create_statements"):
statements += v.safer_create_statements
else:
statements.append(v.create_statement)
@ -137,7 +137,7 @@ def statements_from_differences(
if creations:
if not has_uncreated_dependencies(v, pending_creations):
if k in pending_creations:
if hasattr(v, 'safer_create_statements'):
if hasattr(v, "safer_create_statements"):
statements += v.safer_create_statements
else:
statements.append(v.create_statement)

View File

@ -4,8 +4,6 @@ import argparse
import sys
from contextlib import contextmanager
from .migra import Migration
from .statements import UnsafeMigrationException
@ -17,6 +15,7 @@ def arg_context(x):
else:
from sqlbag import S
with S(x) as s:
yield s

View File

@ -2,7 +2,6 @@ from __future__ import unicode_literals
from schemainspect import DBInspector, get_inspector
from .changes import Changes
from .statements import Statements
@ -60,6 +59,7 @@ class Migration(object):
def apply(self):
from sqlbag import raw_execute
for stmt in self.statements:
raw_execute(self.s_from, stmt)
self.changes.i_from = get_inspector(