[freeside-commits] freeside/bin generate-table-module,NONE,1.1
Ivan,,,
ivan at wavetail.420.am
Wed Aug 17 15:23:48 PDT 2005
- Previous message: [freeside-commits] freeside README.1.5.8, NONE, 1.1 SCHEMA_CHANGE,
1.3, 1.4
- Next message: [freeside-commits] freeside/FS/FS Schema.pm, NONE, 1.1 Record.pm,
1.104, 1.105 cust_main.pm, 1.189, 1.190 payment_gateway.pm,
NONE, 1.1 payment_gateway_option.pm, NONE,
1.1 option_Common.pm, NONE, 1.1 part_export.pm, 1.98,
1.99 part_pkg.pm, 1.41, 1.42 part_export_option.pm, 1.5, 1.6
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /home/cvs/cvsroot/freeside/bin
In directory wavetail:/tmp/cvs-serv31511/bin
Added Files:
generate-table-module
Log Message:
infrastructure for easier schema changes, and: add payment_gateway, payment_gateway_option and agent_payment_gateway tables, add paystart_month, paystart_year, payissue and payip fields to cust_main, add preliminary gateway and gateway override editing to web UI, use payment gateway override when processing payments (card type, not taxclass yet)
--- NEW FILE: generate-table-module ---
#!/usr/bin/perl
use FS::Schema qw( dbdef_dist );
my $table = shift;
###
# add a new FS/FS/table.pm
###
my %ut = ( #just guesses
'int' => 'number',
'number' => 'float',
'varchar' => 'text',
'text' => 'text',
);
my $dbdef_table = dbdef_dist->table($table)
or die "define table in Schema.pm first";
my $primary_key = $dbdef_table->primary_key;
open(SRC,"<eg/table_template.pm") or die $!;
-e "FS/FS/$table.pm" and die "FS/FS/$table.pm already exists!";
open(DEST,">FS/FS/$table.pm") or die $!;
while (my $line = <SRC>) {
$line =~ s/table_name/$table/g;
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";
}
next;
} elsif ( $line=~ /^(\s*)\$self->ut_numbern\('primary_key'\)\s*/ ) {
print DEST "$1\$self->ut_numbern('$primary_key')\n"
if $primary_key;
next;
} elsif (
$line =~ /^(\s*)\|\|\s+\$self->ut_number\('validate_other_fields'\)\s*/
) {
foreach my $column ( grep { $_ ne $primary_key } $dbdef_table->columns ) {
my $ut = $ut{$dbdef_table->column($column)->type};
$ut .= 'n' if $dbdef_table->column($column)->null;
print DEST "$1|| \$self->ut_$ut('$column')\n";
}
next;
}
print DEST $line;
}
close SRC;
close DEST;
###
# 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;}
use FS::$table;
\$loaded=1;
print "ok 1\n";
ENDTEST
close TEST;
###
# add them to MANIFEST
###
open(MANIFEST,">>FS/MANIFEST") or die $!;
print MANIFEST "FS/$table.pm\n",
"t/$table.t\n";
close MANIFEST;
- Previous message: [freeside-commits] freeside README.1.5.8, NONE, 1.1 SCHEMA_CHANGE,
1.3, 1.4
- Next message: [freeside-commits] freeside/FS/FS Schema.pm, NONE, 1.1 Record.pm,
1.104, 1.105 cust_main.pm, 1.189, 1.190 payment_gateway.pm,
NONE, 1.1 payment_gateway_option.pm, NONE,
1.1 option_Common.pm, NONE, 1.1 part_export.pm, 1.98,
1.99 part_pkg.pm, 1.41, 1.42 part_export_option.pm, 1.5, 1.6
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the freeside-commits
mailing list