X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=bin%2Fcreate-history-tables;h=33eb0e5a39fc336475a56a88328cef60d5df2a34;hb=5b1348a5b82cb153e6f42be8187de1a7c84dfb6d;hp=9ed641efdcc529dadeaf6094d6bba2b3d8f13479;hpb=20bb426a02c0ea54d8feaea7c5da51735ab70293;p=freeside.git diff --git a/bin/create-history-tables b/bin/create-history-tables index 9ed641efd..33eb0e5a3 100755 --- a/bin/create-history-tables +++ b/bin/create-history-tables @@ -2,7 +2,7 @@ use strict; use DBI; -use DBIx::DBSchema 0.20; +use DBIx::DBSchema 0.21; use DBIx::DBSchema::Table; use DBIx::DBSchema::Column; use DBIx::DBSchema::ColGroup::Unique; @@ -22,7 +22,7 @@ my @tables = scalar(@ARGV) foreach my $table ( @tables ) { warn "creating history table for $table\n"; my $tableobj = $schema->table($table) - or die "unknown talble $table (did you run dbdef-create?)\n"; + or die "unknown table $table (did you run dbdef-create?)\n"; my $h_tableobj = DBIx::DBSchema::Table->new( { name => "h_$table", primary_key => 'historynum', @@ -64,7 +64,16 @@ foreach my $table ( @tables ) { 'default' => '', 'local' => '', } ), - map { $tableobj->column($_) } $tableobj->columns + map { + my $column = $tableobj->column($_); + $column->type('int') + if $column->type eq 'serial'; + $column->default('') + if $column->default =~ /^nextval\(/i; + ( my $local = $column->local ) =~ s/AUTO_INCREMENT//i; + $column->local($local); + $column; + } $tableobj->columns ], } ); foreach my $statement ( $h_tableobj->sql_create_table($dbh) ) {