add unique_constraints_multiple and indices
[dbsrgits/SQL-Translator.git] / lib / SQL / Translator / Generator / Role / DDL.pm
index abdd46e..f7c2964 100644 (file)
@@ -1,6 +1,7 @@
 package SQL::Translator::Generator::Role::DDL;
 
 use Moo::Role;
+use SQL::Translator::Utils qw(header_comment);
 
 requires '_build_shim';
 requires '_build_type_map';
@@ -45,6 +46,21 @@ sub field_comments {
    ( $_[1]->comments ? ('-- ' . $_[1]->comments . "\n ") : () )
 }
 
+sub table_comments {
+   my ($self, $table) = @_;
+   if ($self->add_comments) {
+      return (
+         "\n",
+         "--\n",
+         "-- Table: " . $self->quote($table->name) . "\n",
+         "--\n",
+         map "-- $_\n", $table->comments
+      )
+   } else {
+      return ()
+   }
+}
+
 sub field_nullable { ($_[1]->is_nullable ? $_[0]->nullable : 'NOT NULL' ) }
 
 sub field_default {
@@ -67,6 +83,13 @@ sub fields {
   ( map $self->field($_), $table->get_fields )
 }
 
+sub indices {
+  my ($self, $table) = @_;
+  (map $self->index($_), $table->get_indices)
+}
+
 sub nullable { 'NULL' }
 
+sub header_comments { header_comment() . "\n" if $_[0]->add_comments }
+
 1;