File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -39,13 +39,22 @@ def to_sql(self) -> str:
39
39
raise ValueError (f"No source SQL available for { self .new .raw_name } table" )
40
40
41
41
columns = ", " .join (c .raw_name for c in self .old .columns .values ())
42
+
43
+ new_sql_temp = self .new .sql .replace (
44
+ f"CREATE TABLE { self .new .raw_name } " ,
45
+ "CREATE TABLE sqlitediff_temp" ,
46
+ 1
47
+ )
48
+ if new_sql_temp == self .new .sql :
49
+ raise ValueError (f"Table { self .new .name } SQL does not match name" )
50
+
42
51
sql = [
43
52
f"-- Previous table schema for { self .old .raw_name } :" ,
44
53
f"{ sql_comment (self .old .sql + ';' )} " ,
45
- f"ALTER TABLE { self .old .raw_name } RENAME TO sqlitediff_temp;" ,
46
- f"{ self .new .sql } ;" ,
54
+ f"{ new_sql_temp } ;" ,
47
55
f"INSERT INTO { self .new .raw_name } ({ columns } ) SELECT * FROM sqlitediff_temp;" ,
48
- f"DROP TABLE sqlitediff_temp;" ,
56
+ f"DROP TABLE { self .old .raw_name } ;" ,
57
+ f"ALTER TABLE sqlitediff_temp RENAME TO { self .new .raw_name } ;" ,
49
58
]
50
59
51
60
if len (self .references ) > 0 :
You can’t perform that action at this time.
0 commit comments