sub dbdef { $dbdef; }
-=item dbdef_dist [ OPTION => VALUE ... ]
+=item dbdef_dist [ DATASRC ]
Returns the current canoical database definition as defined in this file.
+Optionally, pass a DBI data source to enable syntax specific to that database.
+Currently, this enables "TYPE=InnoDB" for MySQL databases.
+
=cut
sub dbdef_dist {
+ my $datasrc = @_ ? shift : '';
+
+ my $local_options = '';
+ if ( $datasrc =~ /^dbi:mysql/i ) {
+ $local_options = 'TYPE=InnoDB';
+ }
###
# create a dbdef object from the old data structure
my $tables_hashref = tables_hashref();
-
#turn it into objects
my $dbdef = new DBIx::DBSchema map {
@$index;
DBIx::DBSchema::Table->new({
- 'name' => $tablename,
- 'primary_key' => $tables_hashref->{$tablename}{'primary_key'},
- 'columns' => \@columns,
- 'indices' => \@indices,
+ 'name' => $tablename,
+ 'primary_key' => $tables_hashref->{$tablename}{'primary_key'},
+ 'columns' => \@columns,
+ 'indices' => \@indices,
+ 'local_options' => $local_options,
});
} keys %$tables_hashref;
keys %indices;
my $h_tableobj = DBIx::DBSchema::Table->new( {
- 'name' => "h_$table",
- 'primary_key' => 'historynum',
- 'indices' => \%h_indices,
- 'columns' => [
- DBIx::DBSchema::Column->new( {
- 'name' => 'historynum',
- 'type' => 'serial',
- 'null' => 'NOT NULL',
- 'length' => '',
- 'default' => '',
- 'local' => '',
- } ),
- DBIx::DBSchema::Column->new( {
- 'name' => 'history_date',
- 'type' => 'int',
- 'null' => 'NULL',
- 'length' => '',
- 'default' => '',
- 'local' => '',
- } ),
- DBIx::DBSchema::Column->new( {
- 'name' => 'history_user',
- 'type' => 'varchar',
- 'null' => 'NOT NULL',
- 'length' => '80',
- 'default' => '',
- 'local' => '',
- } ),
- DBIx::DBSchema::Column->new( {
- 'name' => 'history_action',
- 'type' => 'varchar',
- 'null' => 'NOT NULL',
- 'length' => '80',
- 'default' => '',
- 'local' => '',
- } ),
- map {
- my $column = $tableobj->column($_);
+ 'name' => "h_$table",
+ 'primary_key' => 'historynum',
+ 'indices' => \%h_indices,
+ 'local_options' => $local_options,
+ 'columns' => [
+ DBIx::DBSchema::Column->new( {
+ 'name' => 'historynum',
+ 'type' => 'serial',
+ 'null' => 'NOT NULL',
+ 'length' => '',
+ 'default' => '',
+ 'local' => '',
+ } ),
+ DBIx::DBSchema::Column->new( {
+ 'name' => 'history_date',
+ 'type' => 'int',
+ 'null' => 'NULL',
+ 'length' => '',
+ 'default' => '',
+ 'local' => '',
+ } ),
+ DBIx::DBSchema::Column->new( {
+ 'name' => 'history_user',
+ 'type' => 'varchar',
+ 'null' => 'NOT NULL',
+ 'length' => '80',
+ 'default' => '',
+ 'local' => '',
+ } ),
+ DBIx::DBSchema::Column->new( {
+ 'name' => 'history_action',
+ 'type' => 'varchar',
+ 'null' => 'NOT NULL',
+ 'length' => '80',
+ 'default' => '',
+ 'local' => '',
+ } ),
+ map {
+ my $column = $tableobj->column($_);
- #clone so as to not disturb the original
- $column = DBIx::DBSchema::Column->new( {
- map { $_ => $column->$_() }
- qw( name type null length default local )
- } );
+ #clone so as to not disturb the original
+ $column = DBIx::DBSchema::Column->new( {
+ map { $_ => $column->$_() }
+ qw( name type null length default local )
+ } );
- if ( $column->type eq 'serial' ) {
- $column->type('int');
- $column->null('NULL');
- }
- #$column->default('')
- # if $column->default =~ /^nextval\(/i;
- #( my $local = $column->local ) =~ s/AUTO_INCREMENT//i;
- #$column->local($local);
- $column;
- } $tableobj->columns
- ],
+ if ( $column->type =~ /^(\w*)SERIAL$/i ) {
+ $column->type('int');
+ $column->null('NULL');
+ }
+ #$column->default('')
+ # if $column->default =~ /^nextval\(/i;
+ #( my $local = $column->local ) =~ s/AUTO_INCREMENT//i;
+ #$column->local($local);
+ $column;
+ } $tableobj->columns
+ ],
} );
$dbdef->addtable($h_tableobj);
}
+ if ( $datasrc =~ /^dbi:mysql/i ) {
+
+ my $dup_lock_table = DBIx::DBSchema::Table->new( {
+ 'name' => 'duplicate_lock',
+ 'primary_key' => 'duplocknum',
+ 'local_options' => $local_options,
+ 'columns' => [
+ DBIx::DBSchema::Column->new( {
+ 'name' => 'duplocknum',
+ 'type' => 'serial',
+ 'null' => 'NOT NULL',
+ 'length' => '',
+ 'default' => '',
+ 'local' => '',
+ } ),
+ DBIx::DBSchema::Column->new( {
+ 'name' => 'lockname',
+ 'type' => 'varchar',
+ 'null' => 'NOT NULL',
+ 'length' => '80',
+ 'default' => '',
+ 'local' => '',
+ } ),
+ ],
+ 'indices' => { 'duplicate_lock1' =>
+ DBIx::DBSchema::Index->new({
+ 'name' => 'duplicate_lock1',
+ 'unique' => 1,
+ 'columns' => [ 'lockname' ],
+ })
+ },
+ } );
+
+ $dbdef->addtable($dup_lock_table);
+
+ }
+
$dbdef;
}
'amount', @money_type, '', '',
'otaker', 'varchar', '', 32, '', '',
'reason', 'text', 'NULL', '', '', '',
+ 'reasonnum', 'int', 'NULL', '', '', '',
'closed', 'char', 'NULL', 1, '', '',
],
'primary_key' => 'crednum',
'unique' => [],
- 'index' => [ ['custnum'] ],
+ 'index' => [ ['custnum'], ['_date'] ],
},
'cust_credit_bill' => {
'index' => [ [ 'county' ], [ 'state' ], [ 'country' ] ],
},
+ 'cust_pay_pending' => {
+ 'columns' => [
+ 'paypendingnum','serial', '', '', '', '',
+ 'custnum', 'int', '', '', '', '',
+ 'paid', @money_type, '', '',
+ '_date', @date_type, '', '',
+ 'payby', 'char', '', 4, '', '', #CARD/BILL/COMP, should
+ # be index into payby
+ # table eventually
+ 'payinfo', 'varchar', 'NULL', 512, '', '', #see cust_main above
+ 'paymask', 'varchar', 'NULL', $char_d, '', '',
+ 'paydate', 'varchar', 'NULL', 10, '', '',
+ #'paybatch', 'varchar', 'NULL', $char_d, '', '', #for auditing purposes.
+ 'payunique', 'varchar', 'NULL', $char_d, '', '', #separate paybatch "unique" functions from current usage
+
+ 'status', 'varchar', '', $char_d, '', '',
+ 'statustext', 'text', 'NULL', '', '', '',
+ 'gatewaynum', 'int', 'NULL', '', '', '',
+ #'cust_balance', @money_type, '', '',
+ 'paynum', 'int', 'NULL', '', '', '',
+ ],
+ 'primary_key' => 'paypendingnum',
+ 'unique' => [ [ 'payunique' ] ],
+ 'index' => [ [ 'custnum' ], [ 'status' ], ],
+ },
+
'cust_pay' => {
'columns' => [
'paynum', 'serial', '', '', '', '',
- #now cust_bill_pay #'invnum', 'int', '', '', '', '',
'custnum', 'int', '', '', '', '',
- 'paid', @money_type, '', '',
'_date', @date_type, '', '',
+ 'paid', @money_type, '', '',
+ 'otaker', 'varchar', 'NULL', 32, '', '', #NULL for the upgrade so we can create & populate the field
'payby', 'char', '', 4, '', '', # CARD/BILL/COMP, should be
# index into payby table
# eventually
'closed', 'char', 'NULL', 1, '', '',
],
'primary_key' => 'paynum',
- 'unique' => [ [ 'payunique' ] ],
+ #i guess not now, with cust_pay_pending, if we actually make it here, we _do_ want to record it# 'unique' => [ [ 'payunique' ] ],
'index' => [ [ 'custnum' ], [ 'paybatch' ], [ 'payby' ], [ '_date' ] ],
},
'cust_pkg' => {
'columns' => [
- 'pkgnum', 'serial', '', '', '', '',
- 'custnum', 'int', '', '', '', '',
- 'pkgpart', 'int', '', '', '', '',
- 'otaker', 'varchar', '', 32, '', '',
- 'setup', @date_type, '', '',
- 'bill', @date_type, '', '',
- 'last_bill', @date_type, '', '',
- 'susp', @date_type, '', '',
- 'adjourn', @date_type, '', '',
- 'cancel', @date_type, '', '',
- 'expire', @date_type, '', '',
- 'manual_flag', 'char', 'NULL', 1, '', '',
+ 'pkgnum', 'serial', '', '', '', '',
+ 'custnum', 'int', '', '', '', '',
+ 'pkgpart', 'int', '', '', '', '',
+ 'otaker', 'varchar', '', 32, '', '',
+ 'setup', @date_type, '', '',
+ 'bill', @date_type, '', '',
+ 'last_bill', @date_type, '', '',
+ 'susp', @date_type, '', '',
+ 'adjourn', @date_type, '', '',
+ 'cancel', @date_type, '', '',
+ 'expire', @date_type, '', '',
+ 'change_date', @date_type, '', '',
+ 'change_pkgnum', 'int', 'NULL', '', '', '',
+ 'change_pkgpart', 'int', 'NULL', '', '', '',
+ 'manual_flag', 'char', 'NULL', 1, '', '',
],
'primary_key' => 'pkgnum',
'unique' => [],
'index' => [ ['custnum'], ['pkgpart'],
['setup'], ['last_bill'], ['bill'], ['susp'], ['adjourn'],
- ['expire'], ['cancel']
+ ['expire'], ['cancel'],
+ ['change_date'],
],
},
'cust_refund' => {
'columns' => [
'refundnum', 'serial', '', '', '', '',
- #now cust_credit_refund #'crednum', 'int', '', '', '', '',
'custnum', 'int', '', '', '', '',
'_date', @date_type, '', '',
'refund', @money_type, '', '',
],
'primary_key' => 'refundnum',
'unique' => [],
- 'index' => [ [ 'custnum' ] ],
+ 'index' => [ ['custnum'], ['_date'] ],
},
'cust_credit_refund' => {
],
'primary_key' => 'creditrefundnum',
'unique' => [],
- 'index' => [ [ 'crednum', 'refundnum' ] ],
+ 'index' => [ ['crednum'], ['refundnum'] ],
},
'classnum', 'int', 'NULL', '', '', '',
'pay_weight', 'real', 'NULL', '', '', '',
'credit_weight', 'real', 'NULL', '', '', '',
+ 'agentnum', 'int', 'NULL', '', '', '',
+
],
'primary_key' => 'pkgpart',
'unique' => [],
- 'index' => [ [ 'promo_code' ], [ 'disabled' ] ],
+ 'index' => [ [ 'promo_code' ], [ 'disabled' ], [ 'agentnum' ], ],
},
# 'part_title' => {
],
'primary_key' => 'refnum',
'unique' => [],
- 'index' => [ ['disabled'] ],
+ 'index' => [ ['disabled'], ['agentnum'], ],
},
'part_svc' => {
'totalbytes','bigint', 'NULL', '', '', '',
'totalbytes_threshold', 'bigint', 'NULL', '', '', '',
'domsvc', 'int', '', '', '', '',
+ 'last_login', @date_type, '', '',
+ 'last_logout', @date_type, '', '',
],
'primary_key' => 'svcnum',
#'unique' => [ [ 'username', 'domsvc' ] ],
'index' => [ ['username'], ['domsvc'] ],
},
+ 'acct_rt_transaction' => {
+ 'columns' => [
+ 'svcrtid', 'int', '', '', '', '',
+ 'svcnum', 'int', '', '', '', '',
+ 'transaction_id', 'int', '', '', '', '',
+ '_date', @date_type, '', '',
+ 'seconds', 'int', '', '', '', '', #uhhhh
+ 'support', 'int', '', '', '', '',
+ ],
+ 'primary_key' => 'svcrtid',
+ 'unique' => [],
+ 'index' => [ ['svcnum', 'transaction_id'] ],
+ },
+
#'svc_charge' => {
# 'columns' => [
# 'svcnum', 'int', '', '',
'catchall', 'int', 'NULL', '', '', '',
'parent_svcnum', 'int', 'NULL', '', '', '',
'registrarnum', 'int', 'NULL', '', '', '',
- 'registrarkey', 'varchar', 'NULL', '', '', '',
+ 'registrarkey', 'varchar', 'NULL', 512, '', '',
'setup_date', @date_type, '', '',
'renewal_interval', 'int', 'NULL', '', '', '',
'expiration_date', @date_type, '', '',
'status', 'varchar', '', $char_d, '', '',
'statustext', 'text', 'NULL', '', '', '',
'svcnum', 'int', 'NULL', '', '', '',
+ 'secure', 'char', 'NULL', 1, '', '', # Y = needs to be run on machine
+ # w/private key
],
'primary_key' => 'jobnum',
'unique' => [],
###
'acctid', 'bigserial', '', '', '', '',
- 'calldate', 'TIMESTAMP with time zone', '', '', \'now()', '',
+ #'calldate', 'TIMESTAMP with time zone', '', '', \'now()', '',
+ 'calldate', 'timestamp', '', '', \'now()', '',
'clid', 'varchar', '', $char_d, \"''", '',
'src', 'varchar', '', $char_d, \"''", '',
'dst', 'varchar', '', $char_d, \"''", '',
'cdr_type' => {
'columns' => [
'cdrtypenum' => 'serial', '', '', '', '',
- 'cdrtypename' => 'varchar', '', '', '', '',
+ 'cdrtypename' => 'varchar', '', $char_d, '', '',
],
'primary_key' => 'cdrtypenum',
'unique' => [],
'cdr_carrier' => {
'columns' => [
'carrierid' => 'serial', '', '', '', '',
- 'carriername' => 'varchar', '', '', '', '',
+ 'carriername' => 'varchar', '', $char_d, '', '',
],
'primary_key' => 'carrierid',
'unique' => [],
'usernum', 'int', '', '', '', '',
'prefname', 'varchar', '', $char_d, '', '',
'prefvalue', 'text', 'NULL', '', '', '',
+ 'expiration', @date_type, '', '',
],
'primary_key' => 'prefnum',
'unique' => [],
'rightnum', 'serial', '', '', '', '',
'righttype', 'varchar', '', $char_d, '', '',
'rightobjnum', 'int', '', '', '', '',
- 'rightname', 'varchar', '', '', '', '',
+ 'rightname', 'varchar', '', $char_d, '', '',
],
'primary_key' => 'rightnum',
'unique' => [ [ 'righttype', 'rightobjnum', 'rightname' ] ],
'columns' => [
'reasonnum', 'serial', '', '', '', '',
'reason_type', 'int', '', '', '', '',
- 'reason', 'varchar', '', $char_d, '', '',
+ 'reason', 'text', '', '', '', '',
'disabled', 'char', 'NULL', 1, '', '',
],
'primary_key' => 'reasonnum',
'confnum', 'serial', '', '', '', '',
'agentnum', 'int', 'NULL', '', '', '',
'name', 'varchar', '', $char_d, '', '',
- 'value', 'varchar', 'NULL', '', '', '', # Pg specific
+ 'value', 'text', 'NULL', '', '', '',
],
'primary_key' => 'confnum',
'unique' => [ [ 'agentnum', 'name' ]],