@@ -379,52 +379,53 @@ def export_schema(out, schema, is_main_schema, table_tree):
379379
380380 migrations [ti ].append (migrationDownTemplate )
381381
382- first_foreign_created = False
383- for fkey in tbl .foreignKeys :
384- if fkey .name != '' :
385- if fkey .referencedColumns [0 ].owner .name in migration_tables or tbl .indices :
386- if not first_foreign_created :
387- migrations [ti ].append (
388- schemaCreateTemplate .format (tableName = tbl .name )
389- )
390- first_foreign_created = True
391-
392- migrations [ti ].append (
393- " $table->dropForeign('{key}');\n " .format (key = fkey .columns [0 ].name ))
394-
395- if first_foreign_created :
396- migrations [ti ].append (" });\n " )
397- migrations [ti ].append ('\n ' )
398-
399- for fkey , fval in foreign_keys .iteritems ():
400- if fkey == table .name :
401- keyed_tables = []
402- schema_table = 0
403- for item in fval :
404- if item ['table' ] not in keyed_tables :
405- keyed_tables .append (item ['table' ])
406-
407- if schema_table == 0 :
408- foreign_table_name = item ['table' ]
409- migrations [table .name ].append ('\n ' )
410- migrations [table .name ].append (
411- ' Schema::table(\' %s\' , function (Blueprint $table) {\n ' % (item ['table' ]))
412- schema_table = 1
413-
414- elif foreign_table_name != item ['table' ]:
415- foreign_table_name = item ['table' ]
416- migrations [table .name ].append (" });\n " )
417- migrations [table .name ].append ('\n ' )
418- migrations [table .name ].append (
419- ' Schema::table(\' %s\' , function (Blueprint $table) {\n ' % (item ['table' ]))
420-
421- migrations [table .name ].append (
422- " $table->dropForeign('{key}');\n " .format (key = item ['name' ])
423- )
424-
425- if schema_table == 1 :
426- migrations [table .name ].append (" });\n " )
427- migrations [table .name ].append ('\n ' )
382+ # Not needed?
383+ # first_foreign_created = False
384+ # for fkey in tbl.foreignKeys:
385+ # if fkey.name != '':
386+ # if fkey.referencedColumns[0].owner.name in migration_tables or tbl.indices:
387+ # if not first_foreign_created:
388+ # migrations[ti].append(
389+ # schemaCreateTemplate.format(tableName=tbl.name)
390+ # )
391+ # first_foreign_created = True
392+ #
393+ # migrations[ti].append(
394+ # " $table->dropForeign('{key}');\n".format(key=fkey.columns[0].name))
395+ #
396+ # if first_foreign_created:
397+ # migrations[ti].append(" });\n")
398+ # migrations[ti].append('\n')
399+ #
400+ # for fkey, fval in foreign_keys.iteritems():
401+ # if fkey == table.name:
402+ # keyed_tables = []
403+ # schema_table = 0
404+ # for item in fval:
405+ # if item['table'] not in keyed_tables:
406+ # keyed_tables.append(item['table'])
407+ #
408+ # if schema_table == 0:
409+ # foreign_table_name = item['table']
410+ # migrations[table.name].append('\n')
411+ # migrations[table.name].append(
412+ # ' Schema::table(\'%s\', function (Blueprint $table) {\n' % (item['table']))
413+ # schema_table = 1
414+ #
415+ # elif foreign_table_name != item['table']:
416+ # foreign_table_name = item['table']
417+ # migrations[table.name].append(" });\n")
418+ # migrations[table.name].append('\n')
419+ # migrations[table.name].append(
420+ # ' Schema::table(\'%s\', function (Blueprint $table) {\n' % (item['table']))
421+ #
422+ # migrations[table.name].append(
423+ # " $table->dropForeign('{key}');\n".format(key=item['name'])
424+ # )
425+ #
426+ # if schema_table == 1:
427+ # migrations[table.name].append(" });\n")
428+ # migrations[table.name].append('\n')
428429
429430 migrations [ti ].append (migrationEndingTemplate .format (tableName = table_name ))
430431 ti += 1
@@ -443,7 +444,7 @@ def export_schema(out, schema, is_main_schema, table_tree):
443444 return 1
444445
445446 for name in sorted (migrations ):
446- out .write ('Table name: {0}\n \n \n ' .format (name ))
447+ out .write ('Table name: {0}\n \n \n ' .format (migration_tables [ mkey ] ))
447448 out .write ('' .join (migrations [name ]))
448449 out .write ('\n \n \n ' .format (name ))
449450
0 commit comments