fix for when we are adding /dropping columns in sqlite and need to roundtrip via...
[dbsrgits/SQL-Translator.git] / lib / SQL / Translator / Producer / SQLServer.pm
index 1812418..cbab3c0 100644 (file)
@@ -11,46 +11,11 @@ use SQL::Translator::Utils qw(debug header_comment);
 use SQL::Translator::Generator::DDL::SQLServer;
 
 sub produce {
-    my $translator     = shift;
-    my $future = SQL::Translator::Generator::DDL::SQLServer->new(
-      add_comments    => !$translator->no_comments,
-      add_drop_tables => $translator->add_drop_table,
-    );
-
-    my $no_comments    = $translator->no_comments;
-    my $add_drop_table = $translator->add_drop_table;
-    my $schema         = $translator->schema;
-
-    my $output = $future->header_comments
-      . $future->drop_tables($schema);
-
-    my @foreign_constraints = ();
-
-    for my $table ( grep { $_->name } $schema->get_tables ) {
-        push @foreign_constraints, map $future->foreign_key_constraint($_),
-           grep { $_->type eq FOREIGN_KEY } $table->get_constraints;
-
-        $output .= join( "\n\n",
-            $future->table_comments($table),
-            # index defs
-            $future->table($table),
-            (map $future->unique_constraint_multiple($_),
-               grep {
-                  $_->type eq UNIQUE &&
-                  grep { $_->is_nullable } $_->fields
-               } $table->get_constraints),
-
-            (map $future->index($_), $table->get_indices)
-        );
-    }
-
-# Add FK constraints
-    $output .= join ("\n", '', @foreign_constraints) if @foreign_constraints;
-
-# create view/procedure are NOT prepended to the input $sql, needs
-# to be filled in with the proper syntax
-
-    return $output;
+  my $translator = shift;
+  SQL::Translator::Generator::DDL::SQLServer->new(
+    add_comments    => !$translator->no_comments,
+    add_drop_tables => $translator->add_drop_table,
+  )->schema($translator->schema)
 }
 
 1;