communigate provisioning phase 2: add svc_domain.trailer -> communigate TrailerText...
[freeside.git] / bin / generate-table-module
index 0baf23d..16a23e5 100755 (executable)
@@ -13,6 +13,7 @@ my %ut = ( #just guesses
   'number'  => 'float',
   'varchar' => 'text',
   'text'    => 'text',
+  'serial'  => 'number',
 );
 
 my $dbdef_table = dbdef_dist->table($table)
@@ -30,10 +31,12 @@ while (my $line = <SRC>) {
   if ( $line =~ /^=item\s+field\s+-\s+description\s*$/ ) {
 
     foreach my $column ( $dbdef_table->columns ) {
-      print DEST "=item $column - ";
-      print DEST "primary key"
-        if $column eq $primary_key;
-      print DEST "\n\n";
+      print DEST "=item $column\n\n";
+      if ( $column eq $primary_key ) {
+        print DEST "primary key\n\n";
+      } else {
+        print DEST "$column\n\n";
+      }
     }
     next;
 
@@ -63,16 +66,27 @@ close SRC;
 close DEST;
 
 ###
+# add to FS/FS/Mason.pm
+###
+
+# it needs to be:
+# 1. disablable (have an option to turn it off)
+# 2. documented in the schema change docs
+#
+#my $magic = '# Sammath Naur';
+#system("perl -pi -e 's/$magic/use FS::$table;\n  $magic/' FS/FS/Mason.pm");
+
+###
 # add FS/t/table.t
 ###
 
 open(TEST,">FS/t/$table.t") or die $!;
 print TEST <<ENDTEST;
-BEGIN { \$| = 1; print "1..1\n" }
-END {print "not ok 1\n" unless \$loaded;}
+BEGIN { \$| = 1; print "1..1\\n" }
+END {print "not ok 1\\n" unless \$loaded;}
 use FS::$table;
 \$loaded=1;
-print "ok 1\n";
+print "ok 1\\n";
 ENDTEST
 close TEST;
 
@@ -80,6 +94,8 @@ close TEST;
 # add them to MANIFEST
 ###
 
+system('cvs edit FS/MANIFEST');
+
 open(MANIFEST,">>FS/MANIFEST") or die $!;
 print MANIFEST "FS/$table.pm\n",
                "t/$table.t\n";