X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=bin%2Fcreate-history-tables;h=39248bf3f28e87eb62eb8d77ae61d5cd77f3d012;hp=d37d682d84d7de13c9e7a3a05a5629d322ff28a5;hb=348b6d6744d7bdb4359b29c9f117ed7263cfd16b;hpb=6fd7d458e1fcd100546168ec3992182d628d89ce diff --git a/bin/create-history-tables b/bin/create-history-tables index d37d682d8..39248bf3f 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; @@ -18,8 +18,9 @@ my $schema = dbdef(); #false laziness w/fs-setup my @tables = scalar(@ARGV) ? @ARGV - : grep { ! /^h_/ } $schema->tables; + : grep { ! /^(h|pg)_/ } $schema->tables; foreach my $table ( @tables ) { + next if grep { /^h_$table/ } $schema->tables; warn "creating history table for $table\n"; my $tableobj = $schema->table($table) or die "unknown table $table (did you run dbdef-create?)\n"; @@ -64,7 +65,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) ) {