Skip to content

Commit c53f134

Browse files
authored
Merge pull request #12 from rafaelqm/master
Correction on the down of foreign keys
2 parents d3f83d1 + 3e7553b commit c53f134

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

export-laravel-5-migrations.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,15 @@ def export_schema(out, schema, is_main_schema):
205205
if item['table'] not in keyed_tables:
206206
keyed_tables.append(item['table'])
207207
if schema_table == 0:
208+
foreign_tbl_name = item['table']
209+
migrations[tbl.name].append('\n')
208210
migrations[tbl.name].append(' Schema::table(\'%s\', function (Blueprint $table) {\n' % (item['table']))
209211
schema_table = 1
212+
elif foreign_tbl_name != item['table']:
213+
foreign_tbl_name = item['table']
214+
migrations[tbl.name].append(" });\n")
215+
migrations[tbl.name].append('\n')
216+
migrations[tbl.name].append(' Schema::table(\'%s\', function (Blueprint $table) {\n' % (item['table']))
210217
migrations[tbl.name].append(' $table->dropForeign([\'%s\']);\n' % (item['name']))
211218
if schema_table == 1:
212219
migrations[tbl.name].append(" });\n")

0 commit comments

Comments
 (0)