use vars qw(@ISA @EXPORT_OK $DEBUG $setup_hack %dbdef_cache);
use subs qw(reload_dbdef);
use Exporter;
-use DBIx::DBSchema 0.40; #0.40 for mysql upgrade fixes
+use DBIx::DBSchema 0.44; #for foreign keys with MATCH / ON DELETE/UPDATE
use DBIx::DBSchema::Table;
use DBIx::DBSchema::Column;
use DBIx::DBSchema::Index;
+use DBIx::DBSchema::ForeignKey;
+#can't use this yet, dependency bs #use FS::Conf;
@ISA = qw(Exporter);
@EXPORT_OK = qw( dbdef dbdef_dist reload_dbdef );
=cut
sub dbdef_dist {
- my $datasrc = @_ ? shift : '';
+ my $datasrc = @_ && !ref($_[0]) ? shift : '';
+ my $opt = @_ ? shift : {};
my $local_options = '';
if ( $datasrc =~ /^dbi:mysql/i ) {
}
@index;
+ my @foreign_keys =
+ map DBIx::DBSchema::ForeignKey->new($_),
+ @{ $tables_hashref->{$tablename}{'foreign_keys'} || [] };
+
DBIx::DBSchema::Table->new({
- 'name' => $tablename,
- 'primary_key' => $tables_hashref->{$tablename}{'primary_key'},
- 'columns' => \@columns,
- 'indices' => \@indices,
- 'local_options' => $local_options,
+ name => $tablename,
+ primary_key => $tables_hashref->{$tablename}{'primary_key'},
+ columns => \@columns,
+ indices => \@indices,
+ foreign_keys => \@foreign_keys,
+ local_options => $local_options,
});
} keys %$tables_hashref;
my $tables_hashref_torrus = tables_hashref_torrus();
- #create history tables (false laziness w/create-history-tables)
+ #create history tables
foreach my $table (
- grep { ! /^clientapi_session/
+ grep { ! /^(clientapi|access_user)_session/
&& ! /^h_/
&& ! /^log(_context)?$/
+ && ( ! /^queue(_arg|_depend|_stat)?$/ || ! $opt->{'queue-no_history'} )
&& ! $tables_hashref_torrus->{$_}
}
$dbdef->tables
my %h_indices = ();
- unless ( $table eq 'cust_event' ) { #others?
+ unless ( $table eq 'cust_event' || $table eq 'cdr' ) { #others?
my %indices = $tableobj->indices;
],
});
+ #necessary for queries that want to look at *who* made changes
+ $h_indices{"h_${table}_usernum"} =
+ DBIx::DBSchema::Index->new({
+ 'name' => "h_${table}_usernum",
+ 'unique' => 0,
+ 'columns' => [ 'history_usernum'],
+ });
+
+ # necessary because of the evil OR username for older data, be really nice if everything was just migrated to usernum and we could drop username
+ # This will not be helpful to mysql, but postgres smartly does a bitmap across both indexes, mysql will just use one
+
+ $h_indices{"h_${table}_user"} =
+ DBIx::DBSchema::Index->new({
+ 'name' => "h_${table}_user",
+ 'unique' => 0,
+ 'columns' => [ 'history_user'],
+ });
}
+ my $primary_key_col = $tableobj->column($tableobj->primary_key)
+ or die "$table: primary key declared as ". $tableobj->primary_key.
+ ", but no column of that name\n";
+
+ my $historynum_type = ( $tableobj->column($tableobj->primary_key)->type
+ =~ /^(bigserial|bigint|int8)$/i
+ ? 'bigserial'
+ : 'serial'
+ );
+
my $h_tableobj = DBIx::DBSchema::Table->new( {
'name' => "h_$table",
'primary_key' => 'historynum',
'columns' => [
DBIx::DBSchema::Column->new( {
'name' => 'historynum',
- 'type' => 'serial',
+ 'type' => $historynum_type,
'null' => 'NOT NULL',
'length' => '',
'default' => '',
DBIx::DBSchema::Column->new( {
'name' => 'history_user',
'type' => 'varchar',
- 'null' => 'NOT NULL',
+ 'null' => 'NULL',
'length' => '80',
'default' => '',
'local' => '',
} ),
DBIx::DBSchema::Column->new( {
+ 'name' => 'history_usernum',
+ 'type' => 'int',
+ 'null' => 'NULL',
+ 'length' => '',
+ 'default' => '',
+ 'local' => '',
+ } ),
+ DBIx::DBSchema::Column->new( {
'name' => 'history_action',
'type' => 'varchar',
'null' => 'NOT NULL',
my $char_d = 80; #default maxlength for text fields
#my(@date_type) = ( 'timestamp', '', '' );
- my @date_type = ( 'int', 'NULL', '' );
+ my @date_type = ( 'int', 'NULL', '' );
my @perl_type = ( 'text', 'NULL', '' );
my @money_type = ( 'decimal', '', '10,2' );
my @money_typen = ( 'decimal', 'NULL', '10,2' );
'freq', 'int', 'NULL', '', '', '', #deprecated (never used)
'prog', @perl_type, '', '', #deprecated (never used)
],
- 'primary_key' => 'agentnum',
+ 'primary_key' => 'agentnum',
#'unique' => [ [ 'agent_custnum' ] ], #one agent per customer?
#insert is giving it a value, tho..
#'index' => [ ['typenum'], ['disabled'] ],
- 'unique' => [],
- 'index' => [ ['typenum'], ['disabled'], ['agent_custnum'] ],
+ 'unique' => [],
+ 'index' => [ ['typenum'], ['disabled'], ['agent_custnum'] ],
+ 'foreign_keys' => [
+ { columns => [ 'typenum' ],
+ table => 'agent_type',
+ },
+ # 1. RT tables aren't part of our data structure, so
+ # we can't make sure Queue is created already
+ # 2. Future ability to plug in other ticketing systems
+ #{ columns => [ 'ticketing_queueid' ],
+ # table => 'Queue',
+ # references => [ 'id' ],
+ #},
+ { columns => [ 'agent_custnum' ],
+ table => 'cust_main',
+ references => [ 'custnum' ],
+ },
+ ],
},
'agent_pkg_class' => {
'classnum', 'int', 'NULL', '', '', '',
'commission_percent', 'decimal', '', '7,4', '', '',
],
- 'primary_key' => 'agentpkgclassnum',
- 'unique' => [ [ 'agentnum', 'classnum' ], ],
- 'index' => [],
+ 'primary_key' => 'agentpkgclassnum',
+ 'unique' => [ [ 'agentnum', 'classnum' ], ],
+ 'index' => [],
+ 'foreign_keys' => [
+ { columns => [ 'agentnum' ],
+ table => 'agent',
+ },
+ { columns => [ 'classnum' ],
+ table => 'pkg_class',
+ },
+ ],
},
'agent_type' => {
'columns' => [
- 'typenum', 'serial', '', '', '', '',
- 'atype', 'varchar', '', $char_d, '', '',
+ 'typenum', 'serial', '', '', '', '',
+ 'atype', 'varchar', '', $char_d, '', '',
+ 'disabled', 'char', 'NULL', 1, '', '',
],
'primary_key' => 'typenum',
'unique' => [],
- 'index' => [],
+ 'index' => [ ['disabled'] ],
},
'type_pkgs' => {
'typenum', 'int', '', '', '', '',
'pkgpart', 'int', '', '', '', '',
],
- 'primary_key' => 'typepkgnum',
- 'unique' => [ ['typenum', 'pkgpart'] ],
- 'index' => [ ['typenum'] ],
+ 'primary_key' => 'typepkgnum',
+ 'unique' => [ ['typenum', 'pkgpart'] ],
+ 'index' => [ ['typenum'] ],
+ 'foreign_keys' => [
+ { columns => [ 'typenum' ],
+ table => 'agent_type',
+ },
+ { columns => [ 'pkgpart' ],
+ table => 'part_pkg',
+ },
+ ],
+ },
+
+ 'agent_currency' => {
+ 'columns' => [
+ 'agentcurrencynum', 'serial', '', '', '', '',
+ 'agentnum', 'int', '', '', '', '',
+ 'currency', 'char', '', 3, '', '',
+ ],
+ 'primary_key' => 'agentcurrencynum',
+ 'unique' => [],
+ 'index' => [ ['agentnum'] ],
+ 'foreign_keys' => [
+ { columns => [ 'agentnum' ],
+ table => 'agent',
+ },
+ ],
},
'sales' => {
'salesnum', 'serial', '', '', '', '',
'salesperson', 'varchar', '', $char_d, '', '',
'agentnum', 'int', 'NULL', '', '', '',
+ 'sales_custnum', 'int', 'NULL', '', '', '',
'disabled', 'char', 'NULL', 1, '', '',
],
- 'primary_key' => 'salesnum',
- 'unique' => [],
- 'index' => [ ['salesnum'], ['disabled'] ],
+ 'primary_key' => 'salesnum',
+ 'unique' => [],
+ 'index' => [ ['salesnum'], ['disabled'] ],
+ 'foreign_keys' => [
+ { columns => [ 'agentnum' ],
+ table => 'agent',
+ },
+ { columns => [ 'sales_custnum' ],
+ table => 'cust_main',
+ references => [ 'custnum' ],
+ },
+ ],
+ },
+
+ 'sales_pkg_class' => {
+ 'columns' => [
+ 'salespkgclassnum', 'serial', '', '', '', '',
+ 'salesnum', 'int', '', '', '', '',
+ 'classnum', 'int', 'NULL', '', '', '',
+ 'commission_percent', 'decimal', '', '7,4', '', '',
+ 'commission_duration', 'int', 'NULL', '', '', '',
+ ],
+ 'primary_key' => 'salespkgclassnum',
+ 'unique' => [ [ 'salesnum', 'classnum' ], ],
+ 'index' => [],
+ 'foreign_keys' => [
+ { columns => [ 'salesnum' ],
+ table => 'sales',
+ },
+ { columns => [ 'classnum' ],
+ table => 'pkg_class',
+ },
+ ],
},
'cust_attachment' => {
'body', 'blob', 'NULL', '', '', '',
'disabled', @date_type, '', '',
],
- 'primary_key' => 'attachnum',
- 'unique' => [],
- 'index' => [ ['custnum'], ['usernum'], ],
- },
+ 'primary_key' => 'attachnum',
+ 'unique' => [],
+ 'index' => [ ['custnum'], ['usernum'], ],
+ 'foreign_keys' => [
+ { columns => [ 'custnum' ],
+ table => 'cust_main',
+ },
+ { columns => [ 'usernum' ],
+ table => 'access_user',
+ },
+ ],
+ },
'cust_bill' => {
'columns' => [
#regular fields
- 'invnum', 'serial', '', '', '', '',
- 'custnum', 'int', '', '', '', '',
- '_date', @date_type, '', '',
- 'charged', @money_type, '', '',
+ 'invnum', 'serial', '', '', '', '',
+ 'custnum', 'int', '', '', '', '',
+ '_date', @date_type, '', '',
+ 'charged', @money_type, '', '',
+ 'currency', 'char', 'NULL', 3, '', '',
'invoice_terms', 'varchar', 'NULL', $char_d, '', '',
#customer balance info at invoice generation time
+ #(deprecated)
'previous_balance', @money_typen, '', '', #eventually not nullable
'billing_balance', @money_typen, '', '', #eventually not nullable
'statementnum', 'int', 'NULL', '', '', '', #invoice aggregate statements
'agent_invid', 'int', 'NULL', '', '', '', #(varchar?) importing legacy
'promised_date', @date_type, '', '',
+
+ 'pending', 'char', 'NULL', 1, '', '',
],
- 'primary_key' => 'invnum',
- 'unique' => [ [ 'custnum', 'agent_invid' ] ], #agentnum? huh
- 'index' => [ ['custnum'], ['_date'], ['statementnum'], ['agent_invid'] ],
+ 'primary_key' => 'invnum',
+ 'unique' => [ [ 'custnum', 'agent_invid' ] ], #agentnum? huh
+ 'index' => [ ['custnum'], ['_date'], ['statementnum'],
+ ['agent_invid'],
+ ],
+ 'foreign_keys' => [
+ { columns => [ 'custnum' ],
+ table => 'cust_main',
+ },
+ { columns => [ 'statementnum' ],
+ table => 'cust_statement',
+ },
+ ],
},
'cust_bill_void' => {
'columns' => [
#regular fields
- 'invnum', 'int', '', '', '', '',
- 'custnum', 'int', '', '', '', '',
- '_date', @date_type, '', '',
- 'charged', @money_type, '', '',
+ 'invnum', 'int', '', '', '', '',
+ 'custnum', 'int', '', '', '', '',
+ '_date', @date_type, '', '',
+ 'charged', @money_type, '', '',
+ 'currency', 'char', 'NULL', 3, '', '',
'invoice_terms', 'varchar', 'NULL', $char_d, '', '',
#customer balance info at invoice generation time
'reason', 'varchar', 'NULL', $char_d, '', '',
'void_usernum', 'int', 'NULL', '', '', '',
],
- 'primary_key' => 'invnum',
- 'unique' => [ [ 'custnum', 'agent_invid' ] ], #agentnum? huh
- 'index' => [ ['custnum'], ['_date'], ['statementnum'], ['agent_invid'], [ 'void_usernum' ] ],
+ 'primary_key' => 'invnum',
+ 'unique' => [ [ 'custnum', 'agent_invid' ] ], #agentnum? huh
+ 'index' => [ ['custnum'], ['_date'], ['statementnum'],
+ ['agent_invid'], [ 'void_usernum' ],
+ ],
+ 'foreign_keys' => [
+ { columns => [ 'custnum' ],
+ table => 'cust_main',
+ },
+ { columns => [ 'statementnum' ],
+ table => 'cust_statement', #_void? both?
+ },
+ { columns => [ 'void_usernum' ],
+ table => 'access_user',
+ references => [ 'usernum' ],
+ },
+ ],
},
#for importing invoices from a legacy system for display purposes only
'custnum', 'int', '', '', '', '',
'_date', @date_type, '', '',
'charged', @money_type, '', '',
+ 'currency', 'char', 'NULL', 3, '', '',
'content_pdf', 'blob', 'NULL', '', '', '',
'content_html', 'text', 'NULL', '', '', '',
'locale', 'varchar', 'NULL', 16, '', '',
],
- 'primary_key' => 'legacyinvnum',
- 'unique' => [],
- 'index' => [ ['legacyid', 'custnum', 'locale' ], ],
+ 'primary_key' => 'legacyinvnum',
+ 'unique' => [],
+ 'index' => [ ['legacyid', 'custnum', 'locale' ], ],
+ 'foreign_keys' => [
+ { columns => [ 'custnum' ],
+ table => 'cust_main',
+ },
+ ],
},
'cust_statement' => {
'custnum', 'int', '', '', '', '',
'_date', @date_type, '', '',
],
- 'primary_key' => 'statementnum',
- 'unique' => [],
- 'index' => [ ['custnum'], ['_date'], ],
+ 'primary_key' => 'statementnum',
+ 'unique' => [],
+ 'index' => [ ['custnum'], ['_date'], ],
+ 'foreign_keys' => [
+ { columns => [ 'custnum' ],
+ table => 'cust_main',
+ },
+ ],
},
+ #old "invoice" events, deprecated
'cust_bill_event' => {
'columns' => [
'eventnum', 'serial', '', '', '', '',
'status', 'varchar', '', $char_d, '', '',
'statustext', 'text', 'NULL', '', '', '',
],
- 'primary_key' => 'eventnum',
+ 'primary_key' => 'eventnum',
#no... there are retries now #'unique' => [ [ 'eventpart', 'invnum' ] ],
- 'unique' => [],
- 'index' => [ ['invnum'], ['status'], ['eventpart'],
- ['statustext'], ['_date'],
- ],
+ 'unique' => [],
+ 'index' => [ ['invnum'], ['status'], ['eventpart'],
+ ['statustext'], ['_date'],
+ ],
+ 'foreign_keys' => [
+ { columns => [ 'invnum' ],
+ table => 'cust_bill',
+ },
+ { columns => [ 'eventpart' ],
+ table => 'part_bill_event',
+ },
+ ],
},
+ #old "invoice" events, deprecated
'part_bill_event' => {
'columns' => [
'eventpart', 'serial', '', '', '', '',
'reason', 'int', 'NULL', '', '', '',
'disabled', 'char', 'NULL', 1, '', '',
],
- 'primary_key' => 'eventpart',
- 'unique' => [],
- 'index' => [ ['payby'], ['disabled'], ],
+ 'primary_key' => 'eventpart',
+ 'unique' => [],
+ 'index' => [ ['payby'], ['disabled'], ],
+ 'foreign_keys' => [
+ { columns => [ 'reason' ],
+ table => 'reason',
+ references => [ 'reasonnum' ],
+ },
+ ],
},
'part_event' => {
'action', 'varchar', '', $char_d, '', '',
'disabled', 'char', 'NULL', 1, '', '',
],
- 'primary_key' => 'eventpart',
- 'unique' => [],
- 'index' => [ ['agentnum'], ['eventtable'], ['check_freq'], ['disabled'], ],
+ 'primary_key' => 'eventpart',
+ 'unique' => [],
+ 'index' => [ ['agentnum'], ['eventtable'], ['check_freq'],
+ ['disabled'],
+ ],
+ 'foreign_keys' => [
+ { columns => [ 'agentnum' ],
+ table => 'agent',
+ },
+ ],
},
'part_event_option' => {
'optionname', 'varchar', '', $char_d, '', '',
'optionvalue', 'text', 'NULL', '', '', '',
],
- 'primary_key' => 'optionnum',
- 'unique' => [],
- 'index' => [ [ 'eventpart' ], [ 'optionname' ] ],
+ 'primary_key' => 'optionnum',
+ 'unique' => [],
+ 'index' => [ [ 'eventpart' ], [ 'optionname' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'eventpart' ],
+ table => 'part_event',
+ },
+ ],
},
'part_event_condition' => {
'eventpart', 'int', '', '', '', '',
'conditionname', 'varchar', '', $char_d, '', '',
],
- 'primary_key' => 'eventconditionnum',
- 'unique' => [],
- 'index' => [ [ 'eventpart' ], [ 'conditionname' ] ],
+ 'primary_key' => 'eventconditionnum',
+ 'unique' => [],
+ 'index' => [ [ 'eventpart' ], [ 'conditionname' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'eventpart' ],
+ table => 'part_event',
+ },
+ ],
},
'part_event_condition_option' => {
'optionname', 'varchar', '', $char_d, '', '',
'optionvalue', 'text', 'NULL', '', '', '',
],
- 'primary_key' => 'optionnum',
- 'unique' => [],
- 'index' => [ [ 'eventconditionnum' ], [ 'optionname' ] ],
+ 'primary_key' => 'optionnum',
+ 'unique' => [],
+ 'index' => [ [ 'eventconditionnum' ], [ 'optionname' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'eventconditionnum' ],
+ table => 'part_event_condition',
+ },
+ ],
},
'part_event_condition_option_option' => {
'optionname', 'varchar', '', $char_d, '', '',
'optionvalue', 'text', 'NULL', '', '', '',
],
- 'primary_key' => 'optionoptionnum',
- 'unique' => [],
- 'index' => [ [ 'optionnum' ], [ 'optionname' ] ],
+ 'primary_key' => 'optionoptionnum',
+ 'unique' => [],
+ 'index' => [ [ 'optionnum' ], [ 'optionname' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'optionnum' ],
+ table => 'part_event_condition_option',
+ },
+ ],
},
'cust_event' => {
'status', 'varchar', '', $char_d, '', '',
'statustext', 'text', 'NULL', '', '', '',
],
- 'primary_key' => 'eventnum',
+ 'primary_key' => 'eventnum',
#no... there are retries now #'unique' => [ [ 'eventpart', 'invnum' ] ],
- 'unique' => [],
- 'index' => [ ['eventpart'], ['tablenum'], ['status'],
- ['statustext'], ['_date'],
- ],
+ 'unique' => [],
+ 'index' => [ ['eventpart'], ['tablenum'], ['status'],
+ ['statustext'], ['_date'],
+ ],
+ 'foreign_keys' => [
+ { columns => [ 'eventpart' ],
+ table => 'part_event',
+ },
+ ],
+ },
+
+ 'cust_event_fee' => {
+ 'columns' => [
+ 'eventfeenum', 'serial', '', '', '', '',
+ 'eventnum', 'int', '', '', '', '',
+ 'billpkgnum', 'int', 'NULL', '', '', '',
+ 'feepart', 'int', '', '', '', '',
+ 'nextbill', 'char', 'NULL', 1, '', '',
+ ],
+ 'primary_key' => 'eventfeenum', # I'd rather just use eventnum
+ 'unique' => [ [ 'billpkgnum' ], [ 'eventnum' ] ], # one-to-one link
+ 'index' => [ [ 'feepart' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'eventnum' ],
+ table => 'cust_event',
+ },
+ { columns => [ 'billpkgnum' ],
+ table => 'cust_bill_pkg',
+ },
+ { columns => [ 'feepart' ],
+ table => 'part_fee',
+ },
+ ],
},
'cust_bill_pkg' => {
'columns' => [
- 'billpkgnum', 'serial', '', '', '', '',
- 'invnum', 'int', '', '', '', '',
- 'pkgnum', 'int', '', '', '', '',
- 'pkgpart_override', 'int', 'NULL', '', '', '',
- 'setup', @money_type, '', '',
- 'recur', @money_type, '', '',
- 'sdate', @date_type, '', '',
- 'edate', @date_type, '', '',
- 'itemdesc', 'varchar', 'NULL', $char_d, '', '',
- 'itemcomment', 'varchar', 'NULL', $char_d, '', '',
- 'section', 'varchar', 'NULL', $char_d, '', '',
- 'freq', 'varchar', 'NULL', $char_d, '', '',
- 'quantity', 'int', 'NULL', '', '', '',
- 'unitsetup', @money_typen, '', '',
- 'unitrecur', @money_typen, '', '',
- 'hidden', 'char', 'NULL', 1, '', '',
- ],
- 'primary_key' => 'billpkgnum',
- 'unique' => [],
- 'index' => [ ['invnum'], [ 'pkgnum' ], [ 'itemdesc' ], ],
+ 'billpkgnum', 'serial', '', '', '', '',
+ 'invnum', 'int', '', '', '', '',
+ 'pkgnum', 'int', '', '', '', '',
+ 'pkgpart_override', 'int', 'NULL', '', '', '',
+ 'setup', @money_type, '', '',
+ 'unitsetup', @money_typen, '', '',
+ 'setup_billed_currency', 'char', 'NULL', 3, '', '',
+ 'setup_billed_amount', @money_typen, '', '',
+ 'recur', @money_type, '', '',
+ 'unitrecur', @money_typen, '', '',
+ 'recur_billed_currency', 'char', 'NULL', 3, '', '',
+ 'recur_billed_amount', @money_typen, '', '',
+ 'sdate', @date_type, '', '',
+ 'edate', @date_type, '', '',
+ 'itemdesc', 'varchar', 'NULL', $char_d, '', '',
+ 'itemcomment', 'varchar', 'NULL', $char_d, '', '',
+ 'section', 'varchar', 'NULL', $char_d, '', '',
+ 'freq', 'varchar', 'NULL', $char_d, '', '',
+ 'quantity', 'int', 'NULL', '', '', '',
+ 'hidden', 'char', 'NULL', 1, '', '',
+ 'feepart', 'int', 'NULL', '', '', '',
+ ],
+ 'primary_key' => 'billpkgnum',
+ 'unique' => [],
+ 'index' => [ ['invnum'], [ 'pkgnum' ], [ 'itemdesc' ], ],
+ 'foreign_keys' => [
+ { columns => [ 'invnum' ],
+ table => 'cust_bill',
+ },
+ #pkgnum 0 and -1 are used for special things
+ #{ columns => [ 'pkgnum' ],
+ # table => 'cust_pkg',
+ #},
+ { columns => [ 'pkgpart_override' ],
+ table => 'part_pkg',
+ references => [ 'pkgpart' ],
+ },
+ { columns => [ 'feepart' ],
+ table => 'part_fee',
+ },
+ ],
},
'cust_bill_pkg_detail' => {
'columns' => [
'detailnum', 'serial', '', '', '', '',
+ # bigserial? this table will eventually be as big as cdr...
'billpkgnum', 'int', 'NULL', '', '', '', # should not be nullable
'pkgnum', 'int', 'NULL', '', '', '', # deprecated
'invnum', 'int', 'NULL', '', '', '', # deprecated
'format', 'char', 'NULL', 1, '', '',
'classnum', 'int', 'NULL', '', '', '',
'duration', 'int', 'NULL', '', 0, '',
- 'phonenum', 'varchar', 'NULL', 25, '', '',
+ 'phonenum', 'varchar', 'NULL', 255, '', '', # has to hold a service label
'accountcode', 'varchar', 'NULL', 20, '', '',
'startdate', @date_type, '', '',
'regionname', 'varchar', 'NULL', $char_d, '', '',
- 'detail', 'varchar', '', 255, '', '',
+ 'detail', 'varchar', '', 255, '', '',
],
- 'primary_key' => 'detailnum',
- 'unique' => [],
- 'index' => [ [ 'billpkgnum' ], [ 'classnum' ], [ 'pkgnum', 'invnum' ] ],
+ 'primary_key' => 'detailnum',
+ 'unique' => [],
+ 'index' => [ [ 'billpkgnum' ], [ 'classnum' ],
+ [ 'pkgnum', 'invnum' ],
+ ],
+ 'foreign_keys' => [
+ { columns => [ 'billpkgnum' ],
+ table => 'cust_bill_pkg',
+ },
+ #{ columns => [ 'pkgnum' ],
+ # table => 'cust_pkg',
+ #},
+ #{ columns => [ 'invnum' ],
+ # table => 'cust_bill',
+ #},
+ { columns => [ 'classnum' ],
+ table => 'usage_class',
+ },
+ ],
},
'cust_bill_pkg_display' => {
'columns' => [
- 'billpkgdisplaynum', 'serial', '', '', '', '',
+ 'billpkgdisplaynum', 'serial', '', '', '', '',
'billpkgnum', 'int', '', '', '', '',
'section', 'varchar', 'NULL', $char_d, '', '',
#'unitsetup', @money_typen, '', '', #override the linked real one?
'type', 'char', 'NULL', 1, '', '',
'summary', 'char', 'NULL', 1, '', '',
],
- 'primary_key' => 'billpkgdisplaynum',
- 'unique' => [],
- 'index' => [ ['billpkgnum'], ],
+ 'primary_key' => 'billpkgdisplaynum',
+ 'unique' => [],
+ 'index' => [ ['billpkgnum'], ],
+ 'foreign_keys' => [
+ { columns => [ 'billpkgnum' ],
+ table => 'cust_bill_pkg',
+ },
+ ],
},
- 'cust_bill_pkg_tax_location' => {
+ 'cust_bill_pkg_fee' => {
'columns' => [
- 'billpkgtaxlocationnum', 'serial', '', '', '', '',
- 'billpkgnum', 'int', '', '', '', '',
- 'taxnum', 'int', '', '', '', '',
- 'taxtype', 'varchar', '', $char_d, '', '',
- 'pkgnum', 'int', '', '', '', '', #redundant
- 'locationnum', 'int', '', '', '', '', #redundant
- 'amount', @money_type, '', '',
- 'taxable_billpkgnum', 'int', 'NULL', '', '', '',
+ 'billpkgfeenum', 'serial', '', '', '', '',
+ 'billpkgnum', 'int', '', '', '', '',
+ 'base_invnum', 'int', '', '', '', '',
+ 'base_billpkgnum', 'int', 'NULL', '', '', '',
+ 'amount', @money_type, '', '',
],
- 'primary_key' => 'billpkgtaxlocationnum',
- 'unique' => [],
- 'index' => [ [ 'billpkgnum' ],
- [ 'taxnum' ],
- [ 'pkgnum' ],
- [ 'locationnum' ],
- [ 'taxable_billpkgnum' ],
- ],
+ 'primary_key' => 'billpkgfeenum',
+ 'unique' => [],
+ 'index' => [ ['billpkgnum'],
+ ['base_invnum'],
+ ['base_billpkgnum'],
+ ],
+ 'foreign_keys' => [
+ { columns => [ 'billpkgnum' ],
+ table => 'cust_bill_pkg',
+ },
+ { columns => [ 'base_billpkgnum' ],
+ table => 'cust_bill_pkg',
+ references => [ 'billpkgnum' ],
+ },
+ { columns => [ 'base_invnum' ],
+ table => 'cust_bill',
+ references => [ 'invnum' ],
+ },
+ ],
+ },
+
+ 'cust_bill_pkg_tax_location' => {
+ 'columns' => [
+ 'billpkgtaxlocationnum', 'serial', '', '', '', '',
+ 'billpkgnum', 'int', '', '', '', '',
+ 'taxnum', 'int', '', '', '', '',
+ 'taxtype', 'varchar', '', $char_d, '', '',
+ 'pkgnum', 'int', '', '', '', '', #redundant
+ 'locationnum', 'int', '', '', '', '', #redundant
+ 'amount', @money_type, '', '',
+ 'currency', 'char', 'NULL', 3, '', '',
+ 'taxable_billpkgnum', 'int', 'NULL', '', '', '',
+ ],
+ 'primary_key' => 'billpkgtaxlocationnum',
+ 'unique' => [],
+ 'index' => [ [ 'billpkgnum' ],
+ [ 'taxnum' ],
+ [ 'pkgnum' ],
+ [ 'locationnum' ],
+ [ 'taxable_billpkgnum' ],
+ ],
+ 'foreign_keys' => [
+ { columns => [ 'billpkgnum' ],
+ table => 'cust_bill_pkg',
+ },
+ #{ columns => [ 'pkgnum' ],
+ # table => 'cust_pkg',
+ #}, # taxes can apply to fees
+ { columns => [ 'locationnum' ],
+ table => 'cust_location',
+ },
+ { columns => [ 'taxable_billpkgnum' ],
+ table => 'cust_bill_pkg',
+ references => [ 'billpkgnum' ],
+ },
+ ],
},
'cust_bill_pkg_tax_rate_location' => {
'columns' => [
- 'billpkgtaxratelocationnum', 'serial', '', '', '', '',
- 'billpkgnum', 'int', '', '', '', '',
- 'taxnum', 'int', '', '', '', '',
+ 'billpkgtaxratelocationnum', 'serial', '', '', '', '',
+ 'billpkgnum', 'int', '', '', '', '',
+ 'taxnum', 'int', '', '', '', '',
'taxtype', 'varchar', '', $char_d, '', '',
'locationtaxid', 'varchar', 'NULL', $char_d, '', '',
- 'taxratelocationnum', 'int', '', '', '', '',
- 'amount', @money_type, '', '',
- 'taxable_billpkgnum', 'int', 'NULL', '', '', '',
- ],
- 'primary_key' => 'billpkgtaxratelocationnum',
- 'unique' => [],
- 'index' => [ [ 'billpkgnum' ], [ 'taxnum' ], [ 'taxratelocationnum' ],
- [ 'taxable_billpkgnum' ], ],
+ 'taxratelocationnum', 'int', '', '', '', '',
+ 'amount', @money_type, '', '',
+ 'currency', 'char', 'NULL', 3, '', '',
+ 'taxable_billpkgnum', 'int', 'NULL', '', '', '',
+ ],
+ 'primary_key' => 'billpkgtaxratelocationnum',
+ 'unique' => [],
+ 'index' => [ ['billpkgnum'], ['taxnum'], ['taxratelocationnum'],
+ ['taxable_billpkgnum'],
+ ],
+ 'foreign_keys' => [
+ { columns => [ 'billpkgnum' ],
+ table => 'cust_bill_pkg',
+ },
+ { columns => [ 'taxratelocationnum' ],
+ table => 'tax_rate_location',
+ },
+ { columns => [ 'taxable_billpkgnum' ],
+ table => 'cust_bill_pkg',
+ references => [ 'billpkgnum' ],
+ },
+ ],
},
'cust_bill_pkg_void' => {
'pkgpart_override', 'int', 'NULL', '', '', '',
'setup', @money_type, '', '',
'recur', @money_type, '', '',
+ #XXX a currency for a line item? or just one for the entire invoice
+ #'currency', 'char', 'NULL', 3, '', '',
'sdate', @date_type, '', '',
'edate', @date_type, '', '',
'itemdesc', 'varchar', 'NULL', $char_d, '', '',
'reason', 'varchar', 'NULL', $char_d, '', '',
'void_usernum', 'int', 'NULL', '', '', '',
],
- 'primary_key' => 'billpkgnum',
- 'unique' => [],
- 'index' => [ ['invnum'], [ 'pkgnum' ], [ 'itemdesc' ], [ 'void_usernum' ], ],
+ 'primary_key' => 'billpkgnum',
+ 'unique' => [],
+ 'index' => [ ['invnum'], ['pkgnum'], ['itemdesc'],
+ ['void_usernum'],
+ ],
+ 'foreign_keys' => [
+ { columns => [ 'invnum' ],
+ table => 'cust_bill_void',
+ },
+ #pkgnum 0 and -1 are used for special things
+ #{ columns => [ 'pkgnum' ],
+ # table => 'cust_pkg',
+ #},
+ { columns => [ 'pkgpart_override' ],
+ table => 'part_pkg',
+ references => [ 'pkgpart' ],
+ },
+ { columns => [ 'void_usernum' ],
+ table => 'access_user',
+ references => [ 'usernum' ],
+ },
+ ],
},
'cust_bill_pkg_detail_void' => {
'format', 'char', 'NULL', 1, '', '',
'classnum', 'int', 'NULL', '', '', '',
'duration', 'int', 'NULL', '', 0, '',
- 'phonenum', 'varchar', 'NULL', 25, '', '',
+ 'phonenum', 'varchar', 'NULL', 255, '', '',
'accountcode', 'varchar', 'NULL', 20, '', '',
'startdate', @date_type, '', '',
'regionname', 'varchar', 'NULL', $char_d, '', '',
'detail', 'varchar', '', 255, '', '',
],
- 'primary_key' => 'detailnum',
- 'unique' => [],
- 'index' => [ [ 'billpkgnum' ], [ 'classnum' ], [ 'pkgnum', 'invnum' ] ],
+ 'primary_key' => 'detailnum',
+ 'unique' => [],
+ 'index' => [ ['billpkgnum'], ['classnum'], ['pkgnum', 'invnum'] ],
+ 'foreign_keys' => [
+ { columns => [ 'billpkgnum' ],
+ table => 'cust_bill_pkg_void',
+ },
+ #{ columns => [ 'pkgnum' ],
+ # table => 'cust_pkg',
+ #},
+ #{ columns => [ 'invnum' ],
+ # table => 'cust_bill',
+ #},
+ { columns => [ 'classnum' ],
+ table => 'usage_class',
+ },
+ ],
},
'cust_bill_pkg_display_void' => {
'type', 'char', 'NULL', 1, '', '',
'summary', 'char', 'NULL', 1, '', '',
],
- 'primary_key' => 'billpkgdisplaynum',
- 'unique' => [],
- 'index' => [ ['billpkgnum'], ],
+ 'primary_key' => 'billpkgdisplaynum',
+ 'unique' => [],
+ 'index' => [ ['billpkgnum'], ],
+ 'foreign_keys' => [
+ { columns => [ 'billpkgnum' ],
+ table => 'cust_bill_pkg_void',
+ },
+ ],
},
'cust_bill_pkg_tax_location_void' => {
'columns' => [
- 'billpkgtaxlocationnum', 'int', '', '', '', '',
- 'billpkgnum', 'int', '', '', '', '',
- 'taxnum', 'int', '', '', '', '',
- 'taxtype', 'varchar', '', $char_d, '', '',
- 'pkgnum', 'int', '', '', '', '',
- 'locationnum', 'int', '', '', '', '', #redundant?
- 'amount', @money_type, '', '',
- ],
- 'primary_key' => 'billpkgtaxlocationnum',
- 'unique' => [],
- 'index' => [ [ 'billpkgnum' ], [ 'taxnum' ], [ 'pkgnum' ], [ 'locationnum' ] ],
+ 'billpkgtaxlocationnum', 'int', '', '', '', '',
+ 'billpkgnum', 'int', '', '', '', '',
+ 'taxnum', 'int', '', '', '', '',
+ 'taxtype', 'varchar', '', $char_d, '', '',
+ 'pkgnum', 'int', '', '', '', '',
+ 'locationnum', 'int', '', '', '', '', #redundant?
+ 'amount', @money_type, '', '',
+ 'currency', 'char', 'NULL', 3, '', '',
+ 'taxable_billpkgnum', 'int', 'NULL', '', '', '',
+ ],
+ 'primary_key' => 'billpkgtaxlocationnum',
+ 'unique' => [],
+ 'index' => [ ['billpkgnum'], ['taxnum'], ['pkgnum'],
+ ['locationnum'],
+ ],
+ 'foreign_keys' => [
+ { columns => [ 'billpkgnum' ],
+ table => 'cust_bill_pkg_void',
+ },
+ { columns => [ 'pkgnum' ],
+ table => 'cust_pkg',
+ },
+ { columns => [ 'locationnum' ],
+ table => 'cust_location',
+ },
+ { columns => [ 'taxable_billpkgnum' ],
+ table => 'cust_bill_pkg_void',
+ references => [ 'billpkgnum' ],
+ },
+ ],
},
'cust_bill_pkg_tax_rate_location_void' => {
'columns' => [
- 'billpkgtaxratelocationnum', 'int', '', '', '', '',
- 'billpkgnum', 'int', '', '', '', '',
- 'taxnum', 'int', '', '', '', '',
- 'taxtype', 'varchar', '', $char_d, '', '',
- 'locationtaxid', 'varchar', 'NULL', $char_d, '', '',
- 'taxratelocationnum', 'int', '', '', '', '',
- 'amount', @money_type, '', '',
- ],
- 'primary_key' => 'billpkgtaxratelocationnum',
- 'unique' => [],
- 'index' => [ [ 'billpkgnum' ], [ 'taxnum' ], [ 'taxratelocationnum' ] ],
+ 'billpkgtaxratelocationnum', 'int', '', '', '', '',
+ 'billpkgnum', 'int', '', '', '', '',
+ 'taxnum', 'int', '', '', '', '',
+ 'taxtype', 'varchar', '', $char_d, '', '',
+ 'locationtaxid', 'varchar', 'NULL', $char_d, '', '',
+ 'taxratelocationnum', 'int', '', '', '', '',
+ 'amount', @money_type, '', '',
+ 'currency', 'char', 'NULL', 3, '', '',
+ ],
+ 'primary_key' => 'billpkgtaxratelocationnum',
+ 'unique' => [],
+ 'index' => [ ['billpkgnum'], ['taxnum'], ['taxratelocationnum'] ],
+ 'foreign_keys' => [
+ { columns => [ 'billpkgnum' ],
+ table => 'cust_bill_pkg_void',
+ },
+ { columns => [ 'taxratelocationnum' ],
+ table => 'tax_rate_location',
+ },
+ ],
},
'cust_credit' => {
'columns' => [
- 'crednum', 'serial', '', '', '', '',
- 'custnum', 'int', '', '', '', '',
- '_date', @date_type, '', '',
- 'amount', @money_type, '', '',
- 'otaker', 'varchar', 'NULL', 32, '', '',
- 'usernum', 'int', 'NULL', '', '', '',
- 'reason', 'text', 'NULL', '', '', '',
- 'reasonnum', 'int', 'NULL', '', '', '',
- 'addlinfo', 'text', 'NULL', '', '', '',
- 'closed', 'char', 'NULL', 1, '', '',
- 'pkgnum', 'int', 'NULL', '', '', '', #desired pkgnum for pkg-balances
- 'eventnum', 'int', 'NULL', '', '', '', #triggering event for commission
- #'commission_agentnum', 'int', 'NULL', '', '', '', #
- ],
- 'primary_key' => 'crednum',
- 'unique' => [],
- 'index' => [ ['custnum'], ['_date'], ['usernum'], ['eventnum'] ],
+ 'crednum', 'serial', '', '', '', '',
+ 'custnum', 'int', '', '', '', '',
+ '_date', @date_type, '', '',
+ 'amount',@money_type, '', '',
+ 'currency', 'char', 'NULL', 3, '', '',
+ 'otaker', 'varchar', 'NULL', 32, '', '',
+ 'usernum', 'int', 'NULL', '', '', '',
+ 'reason', 'text', 'NULL', '', '', '',
+ 'reasonnum', 'int', 'NULL', '', '', '',
+ 'addlinfo', 'text', 'NULL', '', '', '',
+ 'closed', 'char', 'NULL', 1, '', '',
+ 'pkgnum', 'int', 'NULL', '', '','',#desired pkgnum for pkg-balances
+ 'eventnum', 'int', 'NULL', '', '','',#triggering event for commission
+ 'commission_agentnum', 'int', 'NULL', '', '', '', #
+ 'commission_salesnum', 'int', 'NULL', '', '', '', #
+ 'commission_pkgnum', 'int', 'NULL', '', '', '', #
+ 'credbatch', 'varchar', 'NULL', $char_d, '', '',
+ ],
+ 'primary_key' => 'crednum',
+ 'unique' => [],
+ 'index' => [ ['custnum'], ['_date'], ['usernum'], ['eventnum'],
+ ['commission_salesnum'], ['credbatch'],
+ ],
+ 'foreign_keys' => [
+ { columns => [ 'custnum' ],
+ table => 'cust_main',
+ },
+ { columns => [ 'usernum' ],
+ table => 'access_user',
+ },
+ { columns => [ 'reasonnum' ],
+ table => 'reason',
+ },
+ { columns => [ 'pkgnum' ],
+ table => 'cust_pkg',
+ },
+ { columns => [ 'eventnum' ],
+ table => 'cust_event',
+ },
+ { columns => [ 'commission_agentnum' ],
+ table => 'agent',
+ references => [ 'agentnum' ],
+ },
+ { columns => [ 'commission_salesnum' ],
+ table => 'sales',
+ references => [ 'salesnum' ],
+ },
+ { columns => [ 'commission_pkgnum' ],
+ table => 'cust_pkg',
+ references => [ 'pkgnum' ],
+ },
+ ],
+ },
+
+ 'cust_credit_void' => {
+ 'columns' => [
+ 'crednum', 'serial', '', '', '', '',
+ 'custnum', 'int', '', '', '', '',
+ '_date', @date_type, '', '',
+ 'amount',@money_type, '', '',
+ 'currency', 'char', 'NULL', 3, '', '',
+ 'otaker', 'varchar', 'NULL', 32, '', '',
+ 'usernum', 'int', 'NULL', '', '', '',
+ 'reason', 'text', 'NULL', '', '', '',
+ 'reasonnum', 'int', 'NULL', '', '', '',
+ 'addlinfo', 'text', 'NULL', '', '', '',
+ 'closed', 'char', 'NULL', 1, '', '',
+ 'pkgnum', 'int', 'NULL', '', '','',
+ 'eventnum', 'int', 'NULL', '', '','',
+ 'commission_agentnum', 'int', 'NULL', '', '', '',
+ 'commission_salesnum', 'int', 'NULL', '', '', '',
+ 'commission_pkgnum', 'int', 'NULL', '', '', '',
+ #void fields
+ 'void_date', @date_type, '', '',
+ 'void_reason', 'varchar', 'NULL', $char_d, '', '',
+ 'void_usernum', 'int', 'NULL', '', '', '',
+ ],
+ 'primary_key' => 'crednum',
+ 'unique' => [],
+ 'index' => [ ['custnum'], ['_date'], ['usernum'], ['eventnum'],
+ ['commission_salesnum'],
+ ],
+ 'foreign_keys' => [
+ { columns => [ 'custnum' ],
+ table => 'cust_main',
+ },
+ { columns => [ 'usernum' ],
+ table => 'access_user',
+ },
+ { columns => [ 'reasonnum' ],
+ table => 'reason',
+ },
+ { columns => [ 'pkgnum' ],
+ table => 'cust_pkg',
+ },
+ { columns => [ 'eventnum' ],
+ table => 'cust_event',
+ },
+ { columns => [ 'commission_agentnum' ],
+ table => 'agent',
+ references => [ 'agentnum' ],
+ },
+ { columns => [ 'commission_salesnum' ],
+ table => 'sales',
+ references => [ 'salesnum' ],
+ },
+ { columns => [ 'commission_pkgnum' ],
+ table => 'cust_pkg',
+ references => [ 'pkgnum' ],
+ },
+ { columns => [ 'void_usernum' ],
+ table => 'access_user',
+ references => [ 'usernum' ],
+ },
+ ],
},
+
'cust_credit_bill' => {
'columns' => [
'creditbillnum', 'serial', '', '', '', '',
'amount', @money_type, '', '',
'pkgnum', 'int', 'NULL', '', '', '', #desired pkgnum for pkg-balances
],
- 'primary_key' => 'creditbillnum',
- 'unique' => [],
- 'index' => [ ['crednum'], ['invnum'] ],
+ 'primary_key' => 'creditbillnum',
+ 'unique' => [],
+ 'index' => [ ['crednum'], ['invnum'] ],
+ 'foreign_keys' => [
+ { columns => [ 'crednum' ],
+ table => 'cust_credit',
+ },
+ { columns => [ 'invnum' ],
+ table => 'cust_bill',
+ },
+ { columns => [ 'pkgnum' ],
+ table => 'cust_pkg',
+ },
+ ],
},
'cust_credit_bill_pkg' => {
'sdate', @date_type, '', '',
'edate', @date_type, '', '',
],
- 'primary_key' => 'creditbillpkgnum',
- 'unique' => [],
- 'index' => [ [ 'creditbillnum' ],
- [ 'billpkgnum' ],
- [ 'billpkgtaxlocationnum' ],
- [ 'billpkgtaxratelocationnum' ],
- ],
+ 'primary_key' => 'creditbillpkgnum',
+ 'unique' => [],
+ 'index' => [ [ 'creditbillnum' ],
+ [ 'billpkgnum' ],
+ [ 'billpkgtaxlocationnum' ],
+ [ 'billpkgtaxratelocationnum' ],
+ ],
+ 'foreign_keys' => [
+ { columns => [ 'creditbillnum' ],
+ table => 'cust_credit_bill',
+ },
+ { columns => [ 'billpkgnum' ],
+ table => 'cust_bill_pkg',
+ },
+ { columns => [ 'billpkgtaxlocationnum' ],
+ table => 'cust_bill_pkg_tax_location',
+ },
+ { columns => [ 'billpkgtaxratelocationnum' ],
+ table => 'cust_bill_pkg_tax_rate_location',
+ },
+ ],
},
'cust_main' => {
'columns' => [
'custnum', 'serial', '', '', '', '',
'agentnum', 'int', '', '', '', '',
+ 'salesnum', 'int', 'NULL', '', '', '',
'agent_custid', 'varchar', 'NULL', $char_d, '', '',
'classnum', 'int', 'NULL', '', '', '',
'custbatch', 'varchar', 'NULL', $char_d, '', '',
'stateid_state', 'varchar', 'NULL', $char_d, '', '',
'national_id', 'varchar', 'NULL', $char_d, '', '',
'birthdate' ,@date_type, '', '',
- 'spouse_birthdate' ,@date_type, '', '',
- 'anniversary_date' ,@date_type, '', '',
+ 'spouse_last', 'varchar', 'NULL', 2*$char_d, '', '',
+ 'spouse_first', 'varchar', 'NULL', $char_d, '', '',
+ 'spouse_birthdate', @date_type, '', '',
+ 'anniversary_date', @date_type, '', '',
'signupdate',@date_type, '', '',
'dundate', @date_type, '', '',
'company', 'varchar', 'NULL', $char_d, '', '',
'ship_night', 'varchar', 'NULL', 20, '', '',
'ship_fax', 'varchar', 'NULL', 12, '', '',
'ship_mobile', 'varchar', 'NULL', 12, '', '',
- 'payby', 'char', '', 4, '', '',
+ 'currency', 'char', 'NULL', 3, '', '',
+
+ #deprecated, info moved to cust_payby
+ 'payby', 'char', 'NULL', 4, '', '',
'payinfo', 'varchar', 'NULL', 512, '', '',
'paycvv', 'varchar', 'NULL', 512, '', '',
'paymask', 'varchar', 'NULL', $char_d, '', '',
'paystate', 'varchar', 'NULL', $char_d, '', '',
'paytype', 'varchar', 'NULL', $char_d, '', '',
'payip', 'varchar', 'NULL', 15, '', '',
+
'geocode', 'varchar', 'NULL', 20, '', '',
'censustract', 'varchar', 'NULL', 20, '', '', # 7 to save space?
'censusyear', 'char', 'NULL', 4, '', '',
'cdr_termination_percentage', 'decimal', 'NULL', '7,4', '', '',
'invoice_terms', 'varchar', 'NULL', $char_d, '', '',
'credit_limit', @money_typen, '', '',
+ 'credit_limit_currency', 'char', 'NULL', 3, '', '',
'archived', 'char', 'NULL', 1, '', '',
'email_csv_cdr', 'char', 'NULL', 1, '', '',
'accountcode_cdr', 'char', 'NULL', 1, '', '',
'message_noemail', 'char', 'NULL', 1, '', '',
'bill_locationnum', 'int', 'NULL', '', '', '',
'ship_locationnum', 'int', 'NULL', '', '', '',
- ],
- 'primary_key' => 'custnum',
- 'unique' => [ [ 'agentnum', 'agent_custid' ] ],
- #'index' => [ ['last'], ['company'] ],
- 'index' => [
- [ 'agentnum' ], [ 'refnum' ], [ 'classnum' ], [ 'usernum' ],
- [ 'custbatch' ],
- [ 'referral_custnum' ],
- [ 'payby' ], [ 'paydate' ],
- [ 'archived' ],
- ],
+ 'taxstatusnum', 'char', 'NULL', 32, '', '',
+ ],
+ 'primary_key' => 'custnum',
+ 'unique' => [ [ 'agentnum', 'agent_custid' ] ],
+ #'index' => [ ['last'], ['company'] ],
+ 'index' => [
+ ['agentnum'], ['refnum'], ['classnum'], ['usernum'],
+ [ 'custbatch' ],
+ [ 'referral_custnum' ],
+ [ 'payby' ], [ 'paydate' ],
+ [ 'archived' ],
+ [ 'ship_locationnum' ],
+ [ 'bill_locationnum' ],
+ ],
+ 'foreign_keys' => [
+ { columns => [ 'agentnum' ],
+ table => 'agent',
+ },
+ { columns => [ 'salesnum' ],
+ table => 'sales',
+ },
+ { columns => [ 'refnum' ],
+ table => 'part_referral',
+ },
+ { columns => [ 'classnum' ],
+ table => 'cust_class',
+ },
+ { columns => [ 'usernum' ],
+ table => 'access_user',
+ },
+ { columns => [ 'referral_custnum' ],
+ table => 'cust_main',
+ references => [ 'custnum' ],
+ },
+ { columns => [ 'bill_locationnum' ],
+ table => 'cust_location',
+ references => [ 'locationnum' ],
+ },
+ { columns => [ 'ship_locationnum' ],
+ table => 'cust_location',
+ references => [ 'locationnum' ],
+ },
+ ],
},
- 'cust_recon' => { # (some sort of not-well understood thing for OnPac)
- 'columns' => [
- 'reconid', 'serial', '', '', '', '',
- 'recondate', @date_type, '', '',
- 'custnum', 'int' , '', '', '', '',
- 'agentnum', 'int', '', '', '', '',
- 'last', 'varchar', '', $char_d, '', '',
- 'first', 'varchar', '', $char_d, '', '',
- 'address1', 'varchar', '', $char_d, '', '',
- 'address2', 'varchar', 'NULL', $char_d, '', '',
- 'city', 'varchar', '', $char_d, '', '',
- 'state', 'varchar', 'NULL', $char_d, '', '',
- 'zip', 'varchar', 'NULL', 10, '', '',
- 'pkg', 'varchar', 'NULL', $char_d, '', '',
- 'adjourn', @date_type, '', '',
- 'status', 'varchar', 'NULL', 10, '', '',
- 'agent_custid', 'varchar', '', $char_d, '', '',
- 'agent_pkg', 'varchar', 'NULL', $char_d, '', '',
- 'agent_adjourn', @date_type, '', '',
- 'comments', 'text', 'NULL', '', '', '',
- ],
- 'primary_key' => 'reconid',
- 'unique' => [],
- 'index' => [],
+ 'cust_payby' => {
+ 'columns' => [
+ 'custpaybynum', 'serial', '', '', '', '',
+ 'custnum', 'int', '', '', '', '',
+ 'weight', 'int', '', '', '', '',
+ 'payby', 'char', '', 4, '', '',
+ 'payinfo', 'varchar', 'NULL', 512, '', '',
+ 'paycvv', 'varchar', 'NULL', 512, '', '',
+ 'paymask', 'varchar', 'NULL', $char_d, '', '',
+ #'paydate', @date_type, '', '',
+ 'paydate', 'varchar', 'NULL', 10, '', '',
+ 'paystart_month', 'int', 'NULL', '', '', '',
+ 'paystart_year', 'int', 'NULL', '', '', '',
+ 'payissue', 'varchar', 'NULL', 2, '', '',
+ 'payname', 'varchar', 'NULL', 2*$char_d, '', '',
+ 'paystate', 'varchar', 'NULL', $char_d, '', '',
+ 'paytype', 'varchar', 'NULL', $char_d, '', '',
+ 'payip', 'varchar', 'NULL', 15, '', '',
+ 'locationnum', 'int', 'NULL', '', '', '',
+ ],
+ 'primary_key' => 'custpaybynum',
+ 'unique' => [],
+ 'index' => [ [ 'custnum' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'custnum' ],
+ table => 'cust_main',
+ },
+ { columns => [ 'locationnum' ],
+ table => 'cust_location',
+ },
+ ],
},
'contact_class' => {
'first', 'varchar', '', $char_d, '', '',
'title', 'varchar', 'NULL', $char_d, '', '', #eg Head Bottle Washer
'comment', 'varchar', 'NULL', 255, '', '',
- 'disabled', 'char', 'NULL', 1, '', '',
+ 'selfservice_access', 'char', 'NULL', 1, '', '',
+ '_password', 'varchar', 'NULL', $char_d, '', '',
+ '_password_encoding', 'varchar', 'NULL', $char_d, '', '',
+ 'disabled', 'char', 'NULL', 1, '', '',
],
- 'primary_key' => 'contactnum',
- 'unique' => [],
- 'index' => [ [ 'prospectnum' ], [ 'custnum' ], [ 'locationnum' ],
- [ 'last' ], [ 'first' ],
- ],
+ 'primary_key' => 'contactnum',
+ 'unique' => [],
+ 'index' => [ [ 'prospectnum' ], [ 'custnum' ], [ 'locationnum' ],
+ [ 'last' ], [ 'first' ],
+ ],
+ 'foreign_keys' => [
+ { columns => [ 'prospectnum' ],
+ table => 'prospect_main',
+ },
+ { columns => [ 'custnum' ],
+ table => 'cust_main',
+ },
+ { columns => [ 'locationnum' ],
+ table => 'cust_location',
+ },
+ { columns => [ 'classnum' ],
+ table => 'contact_class',
+ },
+ ],
},
'contact_phone' => {
'extension', 'varchar', 'NULL', 7, '', '',
#?#'comment', 'varchar', '', $char_d, '', '',
],
- 'primary_key' => 'contactphonenum',
- 'unique' => [],
- 'index' => [],
+ 'primary_key' => 'contactphonenum',
+ 'unique' => [],
+ 'index' => [],
+ 'foreign_keys' => [
+ { columns => [ 'contactnum' ],
+ table => 'contact',
+ },
+ { columns => [ 'phonetypenum' ],
+ table => 'phone_type',
+ },
+ ],
},
'phone_type' => {
'contactnum', 'int', '', '', '', '',
'emailaddress', 'varchar', '', $char_d, '', '',
],
- 'primary_key' => 'contactemailnum',
- 'unique' => [ [ 'emailaddress' ], ],
- 'index' => [],
+ 'primary_key' => 'contactemailnum',
+ #'unique' => [ [ 'contactnum', 'emailaddress' ], ],
+ 'unique' => [ [ 'emailaddress' ], ],
+ 'index' => [],
+ 'foreign_keys' => [
+ { columns => [ 'contactnum' ],
+ table => 'contact',
+ },
+ ],
},
'prospect_main' => {
'add_date', @date_type, '', '',
'disabled', 'char', 'NULL', 1, '', '',
'custnum', 'int', 'NULL', '', '', '',
- ],
- 'primary_key' => 'prospectnum',
- 'unique' => [],
- 'index' => [ [ 'company' ], [ 'agentnum' ], [ 'disabled' ] ],
+ 'refnum', 'int', 'NULL', '', '', '',
+ ],
+ 'primary_key' => 'prospectnum',
+ 'unique' => [],
+ 'index' => [ ['company'], ['agentnum'], ['disabled'], ['refnum'] ],
+ 'foreign_keys' => [
+ { columns => [ 'agentnum' ],
+ table => 'agent',
+ },
+ { columns => [ 'custnum' ],
+ table => 'cust_main',
+ },
+ { columns => [ 'refnum' ],
+ table => 'part_referral',
+ },
+ ],
},
'quotation' => {
#'total', @money_type, '', '',
#'quotation_term', 'varchar', 'NULL', $char_d, '', '',
],
- 'primary_key' => 'quotationnum',
- 'unique' => [],
- 'index' => [ [ 'prospectnum' ], ['custnum'], ],
+ 'primary_key' => 'quotationnum',
+ 'unique' => [],
+ 'index' => [ [ 'prospectnum' ], ['custnum'], ],
+ 'foreign_keys' => [
+ { columns => [ 'prospectnum' ],
+ table => 'prospect_main',
+ },
+ { columns => [ 'custnum' ],
+ table => 'cust_main',
+ },
+ { columns => [ 'usernum' ],
+ table => 'access_user',
+ },
+ ],
},
'quotation_pkg' => {
'quantity', 'int', 'NULL', '', '', '',
'waive_setup', 'char', 'NULL', 1, '', '',
],
- 'primary_key' => 'quotationpkgnum',
- 'unique' => [],
- 'index' => [ ['pkgpart'], ],
+ 'primary_key' => 'quotationpkgnum',
+ 'unique' => [],
+ 'index' => [ ['pkgpart'], ],
+ 'foreign_keys' => [
+ { columns => [ 'quotationnum' ],
+ table => 'quotation',
+ },
+ { columns => [ 'pkgpart' ],
+ table => 'part_pkg',
+ },
+ { columns => [ 'locationnum' ],
+ table => 'cust_location',
+ },
+ ],
},
'quotation_pkg_discount' => {
'discountnum', 'int', '', '', '', '',
#'end_date', @date_type, '', '',
],
- 'primary_key' => 'quotationpkgdiscountnum',
- 'unique' => [],
- 'index' => [ [ 'quotationpkgnum' ], ], #[ 'discountnum' ] ],
+ 'primary_key' => 'quotationpkgdiscountnum',
+ 'unique' => [],
+ 'index' => [ [ 'quotationpkgnum' ], ], #[ 'discountnum' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'quotationpkgnum' ],
+ table => 'quotation_pkg',
+ },
+ { columns => [ 'discountnum' ],
+ table => 'discount',
+ },
+ ],
},
'cust_location' => { #'location' now that its prospects too, but...
'locationnum', 'serial', '', '', '', '',
'prospectnum', 'int', 'NULL', '', '', '',
'custnum', 'int', 'NULL', '', '', '',
+ 'locationname', 'varchar', 'NULL', $char_d, '', '',
'address1', 'varchar', '', $char_d, '', '',
'address2', 'varchar', 'NULL', $char_d, '', '',
'city', 'varchar', '', $char_d, '', '',
'location_type', 'varchar', 'NULL', 20, '', '',
'location_number', 'varchar', 'NULL', 20, '', '',
'location_kind', 'char', 'NULL', 1, '', '',
+ 'incorporated', 'char', 'NULL', 1, '', '',
'disabled', 'char', 'NULL', 1, '', '',
],
- 'primary_key' => 'locationnum',
- 'unique' => [],
- 'index' => [ [ 'prospectnum' ], [ 'custnum' ],
- [ 'county' ], [ 'state' ], [ 'country' ], [ 'zip' ],
- [ 'city' ], [ 'district' ]
- ],
+ 'primary_key' => 'locationnum',
+ 'unique' => [],
+ 'index' => [ [ 'prospectnum' ], [ 'custnum' ],
+ [ 'county' ], [ 'state' ], [ 'country' ], [ 'zip' ],
+ [ 'city' ], [ 'district' ]
+ ],
+ 'foreign_keys' => [
+ { columns => [ 'prospectnum' ],
+ table => 'prospect_main',
+ },
+ { columns => [ 'custnum' ],
+ table => 'cust_main',
+ },
+ ],
},
'cust_main_invoice' => {
'custnum', 'int', '', '', '', '',
'dest', 'varchar', '', $char_d, '', '',
],
- 'primary_key' => 'destnum',
- 'unique' => [],
- 'index' => [ ['custnum'], ],
+ 'primary_key' => 'destnum',
+ 'unique' => [],
+ 'index' => [ ['custnum'], ],
+ 'foreign_keys' => [
+ { columns => [ 'custnum' ],
+ table => 'cust_main',
+ },
+ ],
+ },
+
+ 'cust_main_credit_limit' => {
+ 'columns' => [
+ 'creditlimitnum', 'serial', '', '', '', '',
+ 'custnum', 'int', '', '', '', '',
+ '_date', @date_type, '', '',
+ 'amount', @money_typen, '', '',
+ #'amount_currency', 'char', 'NULL', 3, '', '',
+ 'credit_limit', @money_typen, '', '',
+ #'credit_limit_currency', 'char', 'NULL', 3, '', '',
+ ],
+ 'primary_key' => 'creditlimitnum',
+ 'unique' => [],
+ 'index' => [ ['custnum'], ],
+ 'foreign_keys' => [
+ { columns => [ 'custnum' ],
+ table => 'cust_main',
+ },
+ ],
},
'cust_main_note' => {
'usernum', 'int', 'NULL', '', '', '',
'comments', 'text', 'NULL', '', '', '',
],
- 'primary_key' => 'notenum',
- 'unique' => [],
- 'index' => [ [ 'custnum' ], [ '_date' ], [ 'usernum' ], ],
+ 'primary_key' => 'notenum',
+ 'unique' => [],
+ 'index' => [ [ 'custnum' ], [ '_date' ], [ 'usernum' ], ],
+ 'foreign_keys' => [
+ { columns => [ 'custnum' ],
+ table => 'cust_main',
+ },
+ { columns => [ 'classnum' ],
+ table => 'cust_note_class',
+ },
+ { columns => [ 'usernum' ],
+ table => 'access_user',
+ },
+ ],
},
-
+
'cust_note_class' => {
'columns' => [
'classnum', 'serial', '', '', '', '',
'tax', 'char', 'NULL', 1, '', '',
'disabled', 'char', 'NULL', 1, '', '',
],
- 'primary_key' => 'classnum',
- 'unique' => [],
- 'index' => [ ['disabled'] ],
+ 'primary_key' => 'classnum',
+ 'unique' => [],
+ 'index' => [ ['disabled'] ],
+ 'foreign_keys' => [
+ { columns => [ 'categorynum' ],
+ table => 'cust_category',
+ },
+ ],
},
'cust_tag' => {
'custnum', 'int', '', '', '', '',
'tagnum', 'int', '', '', '', '',
],
- 'primary_key' => 'custtagnum',
- 'unique' => [ [ 'custnum', 'tagnum' ] ],
- 'index' => [ [ 'custnum' ] ],
+ 'primary_key' => 'custtagnum',
+ 'unique' => [ [ 'custnum', 'tagnum' ] ],
+ 'index' => [ [ 'custnum' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'custnum' ],
+ table => 'cust_main',
+ },
+ { columns => [ 'tagnum' ],
+ table => 'part_tag',
+ },
+ ],
},
'part_tag' => {
'exempt_number', 'varchar', 'NULL', $char_d, '', '',
#start/end dates? for reporting?
],
- 'primary_key' => 'exemptionnum',
- 'unique' => [],
- 'index' => [ [ 'custnum' ] ],
+ 'primary_key' => 'exemptionnum',
+ 'unique' => [],
+ 'index' => [ [ 'custnum' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'custnum' ],
+ table => 'cust_main',
+ },
+ ],
},
'cust_tax_adjustment' => {
'adjustmentnum', 'serial', '', '', '', '',
'custnum', 'int', '', '', '', '',
'taxname', 'varchar', '', $char_d, '', '',
- 'amount', @money_type, '', '',
- 'comment', 'varchar', 'NULL', $char_d, '', '',
+ 'amount', @money_type, '', '',
+ 'currency', 'char', 'NULL', 3, '', '',
+ 'comment', 'varchar', 'NULL', $char_d, '', '',
'billpkgnum', 'int', 'NULL', '', '', '',
#more? no cust_bill_pkg_tax_location?
],
- 'primary_key' => 'adjustmentnum',
- 'unique' => [],
- 'index' => [ [ 'custnum' ], [ 'billpkgnum' ] ],
+ 'primary_key' => 'adjustmentnum',
+ 'unique' => [],
+ 'index' => [ [ 'custnum' ], [ 'billpkgnum' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'custnum' ],
+ table => 'cust_main',
+ },
+ { columns => [ 'billpkgnum' ],
+ table => 'cust_bill_pkg',
+ },
+ ],
},
'cust_main_county' => { #district+city+county+state+country are checked
#off the cust_main_county for validation and to
#provide a tax rate.
'columns' => [
- 'taxnum', 'serial', '', '', '', '',
- 'district', 'varchar', 'NULL', 20, '', '',
- 'city', 'varchar', 'NULL', $char_d, '', '',
- 'county', 'varchar', 'NULL', $char_d, '', '',
- 'state', 'varchar', 'NULL', $char_d, '', '',
- 'country', 'char', '', 2, '', '',
- 'taxclass', 'varchar', 'NULL', $char_d, '', '',
- 'exempt_amount', @money_type, '', '',
- 'tax', 'real', '', '', '', '', #tax %
- 'taxname', 'varchar', 'NULL', $char_d, '', '',
- 'setuptax', 'char', 'NULL', 1, '', '', # Y = setup tax exempt
- 'recurtax', 'char', 'NULL', 1, '', '', # Y = recur tax exempt
+ 'taxnum', 'serial', '', '', '', '',
+ 'district', 'varchar', 'NULL', 20, '', '',
+ 'city', 'varchar', 'NULL', $char_d, '', '',
+ 'county', 'varchar', 'NULL', $char_d, '', '',
+ 'state', 'varchar', 'NULL', $char_d, '', '',
+ 'country', 'char', '', 2, '', '',
+ 'taxclass', 'varchar', 'NULL', $char_d, '', '',
+ 'exempt_amount', @money_type, '', '',
+ 'exempt_amount_currency', 'char', 'NULL', 3, '', '',
+ 'tax', 'real', '', '', '', '', #tax %
+ 'taxname', 'varchar', 'NULL', $char_d, '', '',
+ 'setuptax', 'char', 'NULL', 1, '', '', # Y = setup tax exempt
+ 'recurtax', 'char', 'NULL', 1, '', '', # Y = recur tax exempt
],
'primary_key' => 'taxnum',
'unique' => [],
'geocode', 'varchar', 'NULL', $char_d, '', '',#cch provides 10 char
'data_vendor', 'varchar', 'NULL', $char_d, '', '',#auto update source
'location', 'varchar', 'NULL', $char_d, '', '',#provided by tax authority
- 'taxclassnum', 'int', '', '', '', '',
+ 'taxclassnum', 'int', 'NULL', '', '', '',
'effective_date', @date_type, '', '',
'tax', @taxrate_type, '', '', # tax %
'excessrate', @taxrate_typen, '', '', # second tax %
'manual', 'char', 'NULL', 1, '', '', # Y = manually edited
'disabled', 'char', 'NULL', 1, '', '', # Y = tax disabled
],
- 'primary_key' => 'taxnum',
- 'unique' => [],
- 'index' => [ ['taxclassnum'], ['data_vendor', 'geocode'] ],
+ 'primary_key' => 'taxnum',
+ 'unique' => [],
+ 'index' => [ ['taxclassnum'], ['data_vendor', 'geocode'] ],
+ 'foreign_keys' => [
+ { columns => [ 'taxclassnum' ],
+ table => 'tax_class',
+ },
+ ],
},
'tax_rate_location' => {
'city', 'varchar', 'NULL', $char_d, '', '',
'county', 'varchar', 'NULL', $char_d, '', '',
'state', 'char', 'NULL', 2, '', '',
+ 'country', 'char', 'NULL', 2, '', '',
'disabled', 'char', 'NULL', 1, '', '',
],
'primary_key' => 'taxratelocationnum',
'city', 'varchar', 'NULL', $char_d, '', '',
'postalcity', 'varchar', 'NULL', $char_d, '', '',
'county', 'varchar', 'NULL', $char_d, '', '',
- 'zip', 'char', '', 5, '', '',
+ 'zip', 'char', 'NULL', 5, '', '',
'state', 'char', '', 2, '', '',
+ 'country', 'char', 'NULL', 2, '', '', # should not actually be NULL, but cch...
+ 'ziphi', 'char', 'NULL', 10, '', '',
+ 'ziplo', 'char', 'NULL', 10, '', '',
'plus4hi', 'char', 'NULL', 4, '', '',
'plus4lo', 'char', 'NULL', 4, '', '',
'default_location','char', 'NULL', 1, '', '', # Y = default for zip
],
'primary_key' => 'custlocationnum',
'unique' => [],
- 'index' => [ [ 'zip', 'plus4lo', 'plus4hi' ] ],
+ 'index' => [ [ 'zip', 'plus4lo', 'plus4hi', 'ziphi', 'ziplo' ] ],
},
'tax_class' => {
'index' => [],
},
+ 'tax_status' => {
+ 'columns' => [
+ 'taxstatusnum', 'serial', '', '', '', '',
+ 'data_vendor', 'varchar', 'NULL', $char_d, '', '',
+ 'taxstatus', 'varchar', '', $char_d, '', '',
+ 'description', 'varchar', '', $char_d, '', '',
+ ],
+ 'primary_key' => 'taxstatusnum',
+ 'unique' => [ [ 'data_vendor', 'taxstatus' ] ],
+ 'index' => [],
+ },
+
'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, '', '',
+ 'paypendingnum', 'serial', '', '', '', '',
+ 'custnum', 'int', '', '', '', '',
+ 'paid', @money_type, '', '',
+ 'currency', 'char', 'NULL', 3, '', '',
+ '_date', @date_type, '', '',
+ 'payby', 'char', '', 4, '', '',
+ 'payinfo', 'varchar', 'NULL', 512, '', '',
+ 'paymask', 'varchar', 'NULL', $char_d, '', '',
+ 'paydate', 'varchar', 'NULL', 10, '', '',
'recurring_billing', 'varchar', 'NULL', $char_d, '', '',
- #'paybatch', 'varchar', 'NULL', $char_d, '', '', #for auditing purposes.
- 'payunique', 'varchar', 'NULL', $char_d, '', '', #separate paybatch "unique" functions from current usage
+ 'payunique', 'varchar', 'NULL', $char_d, '', '', #separate paybatch "unique" functions from current usage
'pkgnum', 'int', 'NULL', '', '', '', #desired pkgnum for pkg-balances
'status', 'varchar', '', $char_d, '', '',
- 'session_id', 'varchar', 'NULL', $char_d, '', '', #only need 32
+ 'session_id', 'varchar', 'NULL', 1024, '', '', # SHA-512-hex
'statustext', 'text', 'NULL', '', '', '',
'gatewaynum', 'int', 'NULL', '', '', '',
#'cust_balance', @money_type, '', '',
'paynum', 'int', 'NULL', '', '', '',
- 'jobnum', 'int', 'NULL', '', '', '',
- ],
- 'primary_key' => 'paypendingnum',
- 'unique' => [ [ 'payunique' ] ],
- 'index' => [ [ 'custnum' ], [ 'status' ], ],
+ 'void_paynum', 'int', 'NULL', '', '', '',
+ 'jobnum', 'bigint', 'NULL', '', '', '',
+ 'invnum', 'int', 'NULL', '', '', '',
+ 'manual', 'char', 'NULL', 1, '', '',
+ 'discount_term','int', 'NULL', '', '', '',
+ 'failure_status','varchar','NULL', 16, '', '',
+ ],
+ 'primary_key' => 'paypendingnum',
+ 'unique' => [ [ 'payunique' ] ],
+ 'index' => [ [ 'custnum' ], [ 'status' ],
+ ['paynum'], ['void_paynum'], ['jobnum'], ['invnum'],
+ ],
+ 'foreign_keys' => [
+ { columns => [ 'custnum' ],
+ table => 'cust_main',
+ },
+ { columns => [ 'pkgnum' ],
+ table => 'cust_pkg',
+ },
+ { columns => [ 'gatewaynum' ],
+ table => 'payment_gateway',
+ },
+ { columns => [ 'paynum' ],
+ table => 'cust_pay',
+ },
+ { columns => [ 'void_paynum' ],
+ table => 'cust_pay_void',
+ references => [ 'paynum' ],
+ },
+ { columns => [ 'jobnum' ],
+ table => 'queue',
+ },
+ { columns => [ 'invnum' ],
+ table => 'cust_bill',
+ },
+ ],
},
'cust_pay' => {
'columns' => [
- 'paynum', 'serial', '', '', '', '',
- 'custnum', 'int', '', '', '', '',
- '_date', @date_type, '', '',
- 'paid', @money_type, '', '',
- 'otaker', 'varchar', 'NULL', 32, '', '',
- 'usernum', 'int', 'NULL', '', '', '',
- '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
- 'closed', 'char', 'NULL', 1, '', '',
+ 'paynum', 'serial', '', '', '', '',
+ 'custnum', 'int', '', '', '', '',
+ '_date', @date_type, '', '',
+ 'paid', @money_type, '', '',
+ 'currency', 'char', 'NULL', 3, '', '',
+ 'otaker', 'varchar', 'NULL', 32, '', '',
+ 'usernum', 'int', 'NULL', '', '', '',
+ 'payby', 'char', '', 4, '', '',
+ 'payinfo', 'varchar', 'NULL', 512, '', '',
+ '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
+ 'closed', 'char', 'NULL', 1, '', '',
'pkgnum', 'int', 'NULL', '', '', '', #desired pkgnum for pkg-balances
+
# cash/check deposit info fields
- 'bank', 'varchar', 'NULL', $char_d, '', '',
- 'depositor', 'varchar', 'NULL', $char_d, '', '',
- 'account', 'varchar', 'NULL', 20, '', '',
- 'teller', 'varchar', 'NULL', 20, '', '',
+ 'bank', 'varchar', 'NULL', $char_d, '', '',
+ 'depositor', 'varchar', 'NULL', $char_d, '', '',
+ 'account', 'varchar', 'NULL', 20, '', '',
+ 'teller', 'varchar', 'NULL', 20, '', '',
- 'batchnum', 'int', 'NULL', '', '', '', #pay_batch foreign key
+ 'batchnum', 'int', 'NULL', '', '', '',#pay_batch foreign key
# credit card/EFT fields (formerly in paybatch)
- 'gatewaynum', 'int', 'NULL', '', '', '', # payment_gateway FK
- 'processor', 'varchar', 'NULL', $char_d, '', '', # module name
- 'auth', 'varchar','NULL',16, '', '', # CC auth number
- 'order_number','varchar','NULL',$char_d, '', '', # transaction number
+ 'gatewaynum', 'int', 'NULL', '', '', '', # payment_gateway FK
+ 'processor', 'varchar', 'NULL', $char_d, '', '', # module name
+ 'auth', 'varchar', 'NULL', 16, '', '', # CC auth number
+ 'order_number','varchar', 'NULL', $char_d, '', '', # transaction number
],
- 'primary_key' => 'paynum',
+ 'primary_key' => 'paynum',
#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' ], [ 'usernum' ] ],
+ 'index' => [ ['custnum'], ['paybatch'], ['payby'], ['_date'],
+ ['usernum'],
+ ],
+ 'foreign_keys' => [
+ { columns => [ 'custnum' ],
+ table => 'cust_main',
+ },
+ { columns => [ 'usernum' ],
+ table => 'access_user',
+ },
+ { columns => [ 'pkgnum' ],
+ table => 'cust_pkg',
+ },
+ { columns => [ 'batchnum' ],
+ table => 'pay_batch',
+ },
+ { columns => [ 'gatewaynum' ],
+ table => 'payment_gateway',
+ },
+ ],
},
'cust_pay_void' => {
'columns' => [
- 'paynum', 'int', '', '', '', '',
- 'custnum', 'int', '', '', '', '',
- '_date', @date_type, '', '',
- 'paid', @money_type, '', '',
- 'otaker', 'varchar', 'NULL', 32, '', '',
- 'usernum', 'int', 'NULL', '', '', '',
- '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, '', '',
+ 'paynum', 'int', '', '', '', '',
+ 'custnum', 'int', '', '', '', '',
+ '_date', @date_type, '', '',
+ 'paid', @money_type, '', '',
+ 'currency', 'char', 'NULL', 3, '', '',
+ 'otaker', 'varchar', 'NULL', 32, '', '',
+ 'usernum', 'int', 'NULL', '', '', '',
+ 'payby', 'char', '', 4, '', '',
+ 'payinfo', 'varchar', 'NULL', 512, '', '',
+ 'paymask', 'varchar', 'NULL', $char_d, '', '',
#'paydate' ?
- 'paybatch', 'varchar', 'NULL', $char_d, '', '', #for auditing purposes.
- 'closed', 'char', 'NULL', 1, '', '',
- 'pkgnum', 'int', 'NULL', '', '', '', #desired pkgnum for pkg-balances
+ 'paybatch', 'varchar', 'NULL', $char_d, '', '', #for auditing purposes.
+ 'closed', 'char', 'NULL', 1, '', '',
+ 'pkgnum', 'int', 'NULL', '', '', '', #desired pkgnum for pkg-balances
+
# cash/check deposit info fields
'bank', 'varchar', 'NULL', $char_d, '', '',
'depositor', 'varchar', 'NULL', $char_d, '', '',
- 'account', 'varchar', 'NULL', 20, '', '',
- 'teller', 'varchar', 'NULL', 20, '', '',
- 'batchnum', 'int', 'NULL', '', '', '', #pay_batch foreign key
+ 'account', 'varchar', 'NULL', 20, '', '',
+ 'teller', 'varchar', 'NULL', 20, '', '',
+ 'batchnum', 'int', 'NULL', '', '', '', #pay_batch foreign key
# credit card/EFT fields (formerly in paybatch)
- 'gatewaynum', 'int', 'NULL', '', '', '', # payment_gateway FK
- 'processor', 'varchar', 'NULL', $char_d, '', '', # module name
- 'auth', 'varchar','NULL',16, '', '', # CC auth number
- 'order_number', 'varchar','NULL',$char_d, '', '', # transaction number
+ 'gatewaynum', 'int', 'NULL', '', '', '', # payment_gateway FK
+ 'processor', 'varchar', 'NULL', $char_d, '', '', # module name
+ 'auth', 'varchar', 'NULL', 16, '', '', # CC auth number
+ 'order_number','varchar', 'NULL', $char_d, '', '', # transaction number
#void fields
- 'void_date', @date_type, '', '',
- 'reason', 'varchar', 'NULL', $char_d, '', '',
- 'void_usernum', 'int', 'NULL', '', '', '',
- ],
- 'primary_key' => 'paynum',
- 'unique' => [],
- 'index' => [ [ 'custnum' ], [ 'usernum' ], [ 'void_usernum' ] ],
+ 'void_date', @date_type, '', '',
+ 'reason', 'varchar', 'NULL', $char_d, '', '',
+ 'void_usernum', 'int', 'NULL', '', '', '',
+ ],
+ 'primary_key' => 'paynum',
+ 'unique' => [],
+ 'index' => [ ['custnum'], ['usernum'], ['void_usernum'] ],
+ 'foreign_keys' => [
+ { columns => [ 'custnum' ],
+ table => 'cust_main',
+ },
+ { columns => [ 'usernum' ],
+ table => 'access_user',
+ },
+ { columns => [ 'pkgnum' ],
+ table => 'cust_pkg',
+ },
+ { columns => [ 'batchnum' ],
+ table => 'pay_batch',
+ },
+ { columns => [ 'gatewaynum' ],
+ table => 'payment_gateway',
+ },
+ { columns => [ 'void_usernum' ],
+ table => 'access_user',
+ references => [ 'usernum' ],
+ },
+ ],
},
'cust_bill_pay' => {
'_date', @date_type, '', '',
'pkgnum', 'int', 'NULL', '', '', '', #desired pkgnum for pkg-balances
],
- 'primary_key' => 'billpaynum',
- 'unique' => [],
- 'index' => [ [ 'paynum' ], [ 'invnum' ] ],
+ 'primary_key' => 'billpaynum',
+ 'unique' => [],
+ 'index' => [ [ 'paynum' ], [ 'invnum' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'invnum' ],
+ table => 'cust_bill',
+ },
+ { columns => [ 'paynum' ],
+ table => 'cust_pay',
+ },
+ { columns => [ 'pkgnum' ],
+ table => 'cust_pkg',
+ },
+ ],
},
'cust_bill_pay_batch' => {
'amount', @money_type, '', '',
'_date', @date_type, '', '',
],
- 'primary_key' => 'billpaynum',
- 'unique' => [],
- 'index' => [ [ 'paybatchnum' ], [ 'invnum' ] ],
+ 'primary_key' => 'billpaynum',
+ 'unique' => [],
+ 'index' => [ [ 'paybatchnum' ], [ 'invnum' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'invnum' ],
+ table => 'cust_bill',
+ },
+ { columns => [ 'paybatchnum' ],
+ table => 'cust_pay_batch',
+ },
+ ],
},
'cust_bill_pay_pkg' => {
'sdate', @date_type, '', '',
'edate', @date_type, '', '',
],
- 'primary_key' => 'billpaypkgnum',
- 'unique' => [],
- 'index' => [ [ 'billpaynum' ], [ 'billpkgnum' ], ],
+ 'primary_key' => 'billpaypkgnum',
+ 'unique' => [],
+ 'index' => [ [ 'billpaynum' ], [ 'billpkgnum' ], ],
+ 'foreign_keys' => [
+ { columns => [ 'billpaynum' ],
+ table => 'cust_bill_pay',
+ },
+ { columns => [ 'billpkgnum' ],
+ table => 'cust_bill_pkg',
+ },
+ { columns => [ 'billpkgtaxlocationnum' ],
+ table => 'cust_bill_pkg_tax_location',
+ },
+ { columns => [ 'billpkgtaxratelocationnum' ],
+ table => 'cust_bill_pkg_tax_rate_location',
+ },
+ ],
},
'pay_batch' => { #batches of payments to an external processor
'upload', @date_type, '', '',
'title', 'varchar', 'NULL',255, '', '',
],
- 'primary_key' => 'batchnum',
- 'unique' => [],
- 'index' => [],
+ 'primary_key' => 'batchnum',
+ 'unique' => [],
+ 'index' => [],
+ 'foreign_keys' => [
+ { columns => [ 'agentnum' ],
+ table => 'agent',
+ },
+ ],
},
'cust_pay_batch' => { #list of customers in current CARD/CHEK batch
'columns' => [
- 'paybatchnum', 'serial', '', '', '', '',
- 'batchnum', 'int', '', '', '', '',
- 'invnum', 'int', '', '', '', '',
- 'custnum', 'int', '', '', '', '',
- 'last', 'varchar', '', $char_d, '', '',
- 'first', 'varchar', '', $char_d, '', '',
- 'address1', 'varchar', '', $char_d, '', '',
- 'address2', 'varchar', 'NULL', $char_d, '', '',
- 'city', 'varchar', '', $char_d, '', '',
- 'state', 'varchar', 'NULL', $char_d, '', '',
- 'zip', 'varchar', 'NULL', 10, '', '',
- 'country', 'char', '', 2, '', '',
- # 'trancode', 'int', '', '', '', ''
- 'payby', 'char', '', 4, '', '',
- 'payinfo', 'varchar', 'NULL', 512, '', '',
- #'exp', @date_type, '', ''
- 'exp', 'varchar', 'NULL', 11, '', '',
- 'payname', 'varchar', 'NULL', $char_d, '', '',
- 'amount', @money_type, '', '',
- 'status', 'varchar', 'NULL', $char_d, '', '',
- 'error_message', 'varchar', 'NULL', $char_d, '', '',
- ],
- 'primary_key' => 'paybatchnum',
- 'unique' => [],
- 'index' => [ ['batchnum'], ['invnum'], ['custnum'] ],
+ 'paybatchnum', 'serial', '', '', '', '',
+ 'batchnum', 'int', '', '', '', '',
+ 'invnum', 'int', '', '', '', '',
+ 'custnum', 'int', '', '', '', '',
+ 'last', 'varchar', '', $char_d, '', '',
+ 'first', 'varchar', '', $char_d, '', '',
+ 'address1', 'varchar', '', $char_d, '', '',
+ 'address2', 'varchar', 'NULL', $char_d, '', '',
+ 'city', 'varchar', '', $char_d, '', '',
+ 'state', 'varchar', 'NULL', $char_d, '', '',
+ 'zip', 'varchar', 'NULL', 10, '', '',
+ 'country', 'char', '', 2, '', '',
+ 'payby', 'char', '', 4, '', '',
+ 'payinfo', 'varchar', 'NULL', 512, '', '',
+ #'exp', @date_type, '', '',
+ 'exp', 'varchar', 'NULL', 11, '', '',
+ 'payname', 'varchar', 'NULL', $char_d, '', '',
+ 'amount', @money_type, '', '',
+ 'currency', 'char', 'NULL', 3, '', '',
+ 'status', 'varchar', 'NULL', $char_d, '', '',
+ 'failure_status','varchar', 'NULL', 16, '', '',
+ 'error_message', 'varchar', 'NULL', $char_d, '', '',
+ ],
+ 'primary_key' => 'paybatchnum',
+ 'unique' => [],
+ 'index' => [ ['batchnum'], ['invnum'], ['custnum'] ],
+ 'foreign_keys' => [
+ { columns => [ 'batchnum' ],
+ table => 'pay_batch',
+ },
+ { columns => [ 'invnum' ],
+ table => 'cust_bill',
+ },
+ { columns => [ 'custnum' ],
+ table => 'cust_main',
+ },
+ ],
},
'fcc477map' => {
'locationnum', 'int', 'NULL', '', '', '',
'otaker', 'varchar', 'NULL', 32, '', '',
'usernum', 'int', 'NULL', '', '', '',
+ 'salesnum', 'int', 'NULL', '', '', '',
'order_date', @date_type, '', '',
'start_date', @date_type, '', '',
'setup', @date_type, '', '',
'manual_flag', 'char', 'NULL', 1, '', '',
'no_auto', 'char', 'NULL', 1, '', '',
'quantity', 'int', 'NULL', '', '', '',
- 'agent_pkgid', 'int', 'NULL', '', '', '',
+ 'agent_pkgid', 'varchar', 'NULL', $char_d, '', '',
'waive_setup', 'char', 'NULL', 1, '', '',
'recur_show_zero', 'char', 'NULL', 1, '', '',
'setup_show_zero', 'char', 'NULL', 1, '', '',
- ],
- 'primary_key' => 'pkgnum',
- 'unique' => [],
- 'index' => [ ['custnum'], ['pkgpart'], [ 'pkgbatch' ], [ 'locationnum' ],
- [ 'usernum' ], [ 'agent_pkgid' ],
- ['order_date'], [ 'start_date' ], ['setup'], ['bill'],
- ['last_bill'], ['susp'], ['adjourn'], ['cancel'],
- ['expire'], ['contract_end'], ['change_date'], ['no_auto'],
- ],
- },
+ 'change_to_pkgnum', 'int', 'NULL', '', '', '',
+ ],
+ 'primary_key' => 'pkgnum',
+ 'unique' => [],
+ 'index' => [ ['custnum'], ['pkgpart'], ['pkgbatch'],
+ ['locationnum'], ['usernum'], ['agent_pkgid'],
+ ['order_date'], [ 'start_date' ], ['setup'], ['bill'],
+ ['last_bill'], ['susp'], ['adjourn'], ['resume'],
+ ['cancel'], ['expire'], ['contract_end'],
+ ['change_date'],
+ ['no_auto'],
+ #['contactnum'],
+ ['salesnum'],
+ #['uncancel_pkgnum'],
+ #['change_pkgnum'], ['change_locationnum'],
+ #['change_custnum'],
+ ['main_pkgnum'],
+ #['pkglinknum'], ['change_to_pkgnum'],
+ ],
+ 'foreign_keys' => [
+ { columns => [ 'custnum' ],
+ table => 'cust_main',
+ },
+ { columns => [ 'pkgpart' ],
+ table => 'part_pkg',
+ },
+ { columns => [ 'contactnum' ],
+ table => 'contact',
+ },
+ { columns => [ 'locationnum' ],
+ table => 'cust_location',
+ },
+ { columns => [ 'usernum' ],
+ table => 'access_user',
+ },
+ { columns => [ 'salesnum' ],
+ table => 'sales',
+ },
+ { columns => [ 'uncancel_pkgnum' ],
+ table => 'cust_pkg',
+ references => [ 'pkgnum' ],
+ },
+ { columns => [ 'change_pkgnum' ],
+ table => 'cust_pkg',
+ references => [ 'pkgnum' ],
+ },
+ { columns => [ 'change_pkgpart' ],
+ table => 'part_pkg',
+ references => [ 'pkgpart' ],
+ },
+ { columns => [ 'change_locationnum' ],
+ table => 'cust_location',
+ references => [ 'locationnum' ],
+ },
+ { columns => [ 'change_custnum' ],
+ table => 'cust_main',
+ references => [ 'custnum' ],
+ },
+ { columns => [ 'main_pkgnum' ],
+ table => 'cust_pkg',
+ references => [ 'pkgnum' ],
+ },
+ { columns => [ 'pkglinknum' ],
+ table => 'part_pkg_link',
+ },
+ { columns => [ 'change_to_pkgnum' ],
+ table => 'cust_pkg',
+ references => [ 'pkgnum' ],
+ },
+ ],
+ },
'cust_pkg_option' => {
'columns' => [
'optionname', 'varchar', '', $char_d, '', '',
'optionvalue', 'text', 'NULL', '', '', '',
],
- 'primary_key' => 'optionnum',
- 'unique' => [],
- 'index' => [ [ 'pkgnum' ], [ 'optionname' ] ],
+ 'primary_key' => 'optionnum',
+ 'unique' => [],
+ 'index' => [ [ 'pkgnum' ], [ 'optionname' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'pkgnum' ],
+ table => 'cust_pkg',
+ },
+ ],
},
'cust_pkg_detail' => {
'detailtype', 'char', '', 1, '', '', # "I"nvoice or "C"omment
'weight', 'int', '', '', '', '',
],
- 'primary_key' => 'pkgdetailnum',
- 'unique' => [],
- 'index' => [ [ 'pkgnum', 'detailtype' ] ],
+ 'primary_key' => 'pkgdetailnum',
+ 'unique' => [],
+ 'index' => [ [ 'pkgnum', 'detailtype' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'pkgnum' ],
+ table => 'cust_pkg',
+ },
+ ],
},
'cust_pkg_reason' => {
'usernum', 'int', 'NULL', '', '', '',
'date', @date_type, '', '',
],
- 'primary_key' => 'num',
- 'unique' => [],
- 'index' => [ [ 'pkgnum' ], [ 'reasonnum' ], ['action'], [ 'usernum' ], ],
+ 'primary_key' => 'num',
+ 'unique' => [],
+ 'index' => [ ['pkgnum'], ['reasonnum'], ['action'], ['usernum'], ],
+ 'foreign_keys' => [
+ { columns => [ 'pkgnum' ],
+ table => 'cust_pkg',
+ },
+ { columns => [ 'reasonnum' ],
+ table => 'reason',
+ },
+ { columns => [ 'usernum' ],
+ table => 'access_user',
+ },
+ ],
},
'cust_pkg_discount' => {
'usernum', 'int', 'NULL', '', '', '',
'disabled', 'char', 'NULL', 1, '', '',
],
- 'primary_key' => 'pkgdiscountnum',
- 'unique' => [],
- 'index' => [ [ 'pkgnum' ], [ 'discountnum' ], [ 'usernum' ], ],
+ 'primary_key' => 'pkgdiscountnum',
+ 'unique' => [],
+ 'index' => [ [ 'pkgnum' ], [ 'discountnum' ], [ 'usernum' ], ],
+ 'foreign_keys' => [
+ { columns => [ 'pkgnum' ],
+ table => 'cust_pkg',
+ },
+ { columns => [ 'discountnum' ],
+ table => 'discount',
+ },
+ { columns => [ 'usernum' ],
+ table => 'access_user',
+ },
+ ],
},
'cust_pkg_usage' => {
'columns' => [
'pkgusagenum', 'serial', '', '', '', '',
'pkgnum', 'int', '', '', '', '',
- 'minutes', 'int', '', '', '', '',
+ 'minutes', 'double precision', '', '', '', '',
'pkgusagepart', 'int', '', '', '', '',
],
- 'primary_key' => 'pkgusagenum',
- 'unique' => [],
- 'index' => [ [ 'pkgnum' ], [ 'pkgusagepart' ] ],
+ 'primary_key' => 'pkgusagenum',
+ 'unique' => [],
+ 'index' => [ [ 'pkgnum' ], [ 'pkgusagepart' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'pkgnum' ],
+ table => 'cust_pkg',
+ },
+ { columns => [ 'pkgusagepart' ],
+ table => 'part_pkg_usage',
+ },
+ ],
},
'cdr_cust_pkg_usage' => {
'cdrusagenum', 'bigserial', '', '', '', '',
'acctid', 'bigint', '', '', '', '',
'pkgusagenum', 'int', '', '', '', '',
- 'minutes', 'int', '', '', '', '',
- ],
- 'primary_key' => 'cdrusagenum',
- 'unique' => [],
- 'index' => [ [ 'pkgusagenum' ], [ 'acctid' ] ],
+ 'minutes', 'double precision', '', '', '', '',
+ ],
+ 'primary_key' => 'cdrusagenum',
+ 'unique' => [],
+ 'index' => [ [ 'pkgusagenum' ], [ 'acctid' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'acctid' ],
+ table => 'cdr',
+ },
+ { columns => [ 'pkgusagenum' ],
+ table => 'cust_pkg_usage',
+ },
+ ],
},
'cust_bill_pkg_discount' => {
'amount', @money_type, '', '',
'months', 'decimal', 'NULL', '7,4', '', '',
],
- 'primary_key' => 'billpkgdiscountnum',
- 'unique' => [],
- 'index' => [ [ 'billpkgnum' ], [ 'pkgdiscountnum' ] ],
+ 'primary_key' => 'billpkgdiscountnum',
+ 'unique' => [],
+ 'index' => [ [ 'billpkgnum' ], [ 'pkgdiscountnum' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'billpkgnum' ],
+ table => 'cust_bill_pkg',
+ },
+ { columns => [ 'pkgdiscountnum' ],
+ table => 'cust_pkg_discount',
+ },
+ ],
},
'cust_bill_pkg_discount_void' => {
'amount', @money_type, '', '',
'months', 'decimal', 'NULL', '7,4', '', '',
],
- 'primary_key' => 'billpkgdiscountnum',
- 'unique' => [],
- 'index' => [ [ 'billpkgnum' ], [ 'pkgdiscountnum' ] ],
+ 'primary_key' => 'billpkgdiscountnum',
+ 'unique' => [],
+ 'index' => [ [ 'billpkgnum' ], [ 'pkgdiscountnum' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'billpkgnum' ],
+ table => 'cust_bill_pkg_void',
+ },
+ { columns => [ 'pkgdiscountnum' ],
+ table => 'cust_pkg_discount',
+ },
+ ],
},
'discount' => {
'columns' => [
'discountnum', 'serial', '', '', '', '',
#'agentnum', 'int', 'NULL', '', '', '',
+ 'classnum', 'int', 'NULL', '', '', '',
'name', 'varchar', 'NULL', $char_d, '', '',
'amount', @money_type, '', '',
'percent', 'decimal', '', '7,4', '', '',
'setup', 'char', 'NULL', 1, '', '',
#'linked', 'char', 'NULL', 1, '', '',
],
- 'primary_key' => 'discountnum',
+ 'primary_key' => 'discountnum',
+ 'unique' => [],
+ 'index' => [], # [ 'agentnum' ], ],
+ 'foreign_keys' => [
+ { columns => [ 'classnum' ],
+ table => 'discount_class',
+ },
+ ],
+ },
+
+ 'discount_class' => {
+ 'columns' => [
+ 'classnum', 'serial', '', '', '', '',
+ 'classname', 'varchar', '', $char_d, '', '',
+ #'categorynum', 'int', 'NULL', '', '', '',
+ 'disabled', 'char', 'NULL', 1, '', '',
+ ],
+ 'primary_key' => 'classnum',
'unique' => [],
- 'index' => [], # [ 'agentnum' ], ],
+ 'index' => [ ['disabled'] ],
},
'cust_refund' => {
'custnum', 'int', '', '', '', '',
'_date', @date_type, '', '',
'refund', @money_type, '', '',
+ 'currency', 'char', 'NULL', 3, '', '',
'otaker', 'varchar', 'NULL', 32, '', '',
'usernum', 'int', 'NULL', '', '', '',
- 'reason', 'varchar', '', $char_d, '', '',
+ 'reason', 'varchar', 'NULL', $char_d, '', '',
+ 'reasonnum', 'int', 'NULL', '', '', '',
'payby', 'char', '', 4, '', '', # CARD/BILL/COMP, should
# be index into payby
# table eventually
'auth', 'varchar','NULL',16, '', '', # CC auth number
'order_number', 'varchar','NULL',$char_d, '', '', # transaction number
],
- 'primary_key' => 'refundnum',
- 'unique' => [],
- 'index' => [ ['custnum'], ['_date'], [ 'usernum' ], ],
+ 'primary_key' => 'refundnum',
+ 'unique' => [],
+ 'index' => [ ['custnum'], ['_date'], [ 'usernum' ], ],
+ 'foreign_keys' => [
+ { columns => [ 'custnum' ],
+ table => 'cust_main',
+ },
+ { columns => [ 'usernum' ],
+ table => 'access_user',
+ },
+ { columns => [ 'reasonnum' ],
+ table => 'reason',
+ },
+ { columns => [ 'gatewaynum' ],
+ table => 'payment_gateway',
+ },
+ ],
},
'cust_credit_refund' => {
'amount', @money_type, '', '',
'_date', @date_type, '', '',
],
- 'primary_key' => 'creditrefundnum',
- 'unique' => [],
- 'index' => [ ['crednum'], ['refundnum'] ],
+ 'primary_key' => 'creditrefundnum',
+ 'unique' => [],
+ 'index' => [ ['crednum'], ['refundnum'] ],
+ 'foreign_keys' => [
+ { columns => [ 'crednum' ],
+ table => 'cust_credit',
+ },
+ { columns => [ 'refundnum' ],
+ table => 'cust_refund',
+ },
+ ],
},
'agent_svcid', 'int', 'NULL', '', '', '',
'overlimit', @date_type, '', '',
],
- 'primary_key' => 'svcnum',
- 'unique' => [],
- 'index' => [ ['svcnum'], ['pkgnum'], ['svcpart'], [ 'agent_svcid' ] ],
+ 'primary_key' => 'svcnum',
+ 'unique' => [],
+ 'index' => [ ['svcnum'], ['pkgnum'], ['svcpart'],
+ ['agent_svcid'],
+ ],
+ 'foreign_keys' => [
+ { columns => [ 'pkgnum' ],
+ table => 'cust_pkg',
+ },
+ { columns => [ 'svcpart' ],
+ table => 'part_svc',
+ },
+ ],
},
'cust_svc_option' => {
'optionname', 'varchar', '', $char_d, '', '',
'optionvalue', 'text', 'NULL', '', '', '',
],
- 'primary_key' => 'optionnum',
- 'unique' => [],
- 'index' => [ [ 'svcnum' ], [ 'optionname' ] ],
+ 'primary_key' => 'optionnum',
+ 'unique' => [],
+ 'index' => [ [ 'svcnum' ], [ 'optionname' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'svcnum' ],
+ table => 'cust_svc',
+ },
+ ],
},
'svc_export_machine' => {
'exportnum', 'int', '', '', '', '',
'machinenum', 'int', '', '', '', '',
],
- 'primary_key' => 'svcexportmachinenum',
- 'unique' => [ ['svcnum', 'exportnum'] ],
- 'index' => [],
+ 'primary_key' => 'svcexportmachinenum',
+ 'unique' => [ ['svcnum', 'exportnum'] ],
+ 'index' => [],
+ 'foreign_keys' => [
+ { columns => [ 'svcnum' ],
+ table => 'cust_svc',
+ },
+ { columns => [ 'exportnum' ],
+ table => 'part_export',
+ },
+ { columns => [ 'machinenum' ],
+ table => 'part_export_machine',
+ },
+ ],
},
'part_export_machine' => {
'machine', 'varchar', 'NULL', $char_d, '', '',
'disabled', 'char', 'NULL', 1, '', '',
],
- 'primary_key' => 'machinenum',
- 'unique' => [ [ 'exportnum', 'machine' ] ],
- 'index' => [ [ 'exportnum' ] ],
+ 'primary_key' => 'machinenum',
+ 'unique' => [ [ 'exportnum', 'machine' ] ],
+ 'index' => [ [ 'exportnum' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'exportnum' ],
+ table => 'part_export',
+ },
+ ],
},
- 'part_pkg' => {
+ 'part_pkg' => {
'columns' => [
'pkgpart', 'serial', '', '', '', '',
'pkg', 'varchar', '', $char_d, '', '',
- 'comment', 'varchar', '', 2*$char_d, '', '',
+ 'comment', 'varchar', 'NULL', 2*$char_d, '', '',
'promo_code', 'varchar', 'NULL', $char_d, '', '',
'freq', 'varchar', '', $char_d, '', '', #billing frequency
'setuptax', 'char', 'NULL', 1, '', '',
'setup_show_zero', 'char', 'NULL', 1, '', '',
'successor', 'int', 'NULL', '', '', '',
'family_pkgpart','int', 'NULL', '', '', '',
- ],
- 'primary_key' => 'pkgpart',
- 'unique' => [],
- 'index' => [ [ 'promo_code' ], [ 'disabled' ], [ 'classnum' ],
- [ 'agentnum' ], ['no_auto'],
- ],
+ 'delay_start', 'int', 'NULL', '', '', '',
+ 'start_on_hold', 'char', 'NULL', 1, '', '',
+ 'agent_pkgpartid', 'varchar', 'NULL', 20, '', '',
+ ],
+ 'primary_key' => 'pkgpart',
+ 'unique' => [],
+ 'index' => [ [ 'promo_code' ], [ 'disabled' ], [ 'classnum' ],
+ [ 'agentnum' ], ['no_auto'], ['agent_pkgpartid'],
+ ],
+ 'foreign_keys' => [
+ { columns => [ 'classnum' ],
+ table => 'pkg_class',
+ },
+ { columns => [ 'addon_classnum' ],
+ table => 'pkg_class',
+ references => [ 'classnum' ],
+ },
+ { columns => [ 'taxproductnum' ],
+ table => 'part_pkg_taxproduct',
+ },
+ { columns => [ 'agentnum' ],
+ table => 'agent',
+ },
+ { columns => [ 'successor' ],
+ table => 'part_pkg',
+ references => [ 'pkgpart' ],
+ },
+ { columns => [ 'family_pkgpart' ],
+ table => 'part_pkg',
+ references => [ 'pkgpart' ],
+ },
+ ],
},
'part_pkg_msgcat' => {
'pkg', 'varchar', '', $char_d, '', '', #longer/no limit?
'comment', 'varchar', 'NULL', 2*$char_d, '', '', #longer/no limit?
],
- 'primary_key' => 'pkgpartmsgnum',
- 'unique' => [ [ 'pkgpart', 'locale' ] ],
+ 'primary_key' => 'pkgpartmsgnum',
+ 'unique' => [ [ 'pkgpart', 'locale' ] ],
+ 'index' => [],
+ 'foreign_keys' => [
+ { columns => [ 'pkgpart' ],
+ table => 'part_pkg',
+ },
+ ],
+ },
+
+ 'part_pkg_currency' => {
+ 'columns' => [
+ 'pkgcurrencynum', 'serial', '', '', '', '',
+ 'pkgpart', 'int', '', '', '', '',
+ 'currency', 'char', '', 3, '', '',
+ 'optionname', 'varchar', '', $char_d, '', '',
+ 'optionvalue', 'text', '', '', '', '',
+ ],
+ 'primary_key' => 'pkgcurrencynum',
+ 'unique' => [ [ 'pkgpart', 'currency', 'optionname' ] ],
+ 'index' => [ ['pkgpart'] ],
+ 'foreign_keys' => [
+ { columns => [ 'pkgpart' ],
+ table => 'part_pkg',
+ },
+ ],
+ },
+
+ 'currency_exchange' => {
+ 'columns' => [
+ 'currencyratenum', 'serial', '', '', '', '',
+ 'from_currency', 'char', '', 3, '', '',
+ 'to_currency', 'char', '', 3, '', '',
+ 'rate', 'decimal', '', '7,6', '', '',
+ ],
+ 'primary_key' => 'currencyratenum',
+ 'unique' => [ [ 'from_currency', 'to_currency' ] ],
'index' => [],
},
+ 'part_pkg_usageprice' => {
+ 'columns' => [
+ 'usagepricepart', 'serial', '', '', '', '',
+ 'pkgpart', 'int', '', '', '', '',
+ 'price', @money_type, '', '',
+ 'currency', 'char', 'NULL', 3, '', '',
+ 'action', 'varchar', '', $char_d, '', '',
+ 'target', 'varchar', '', $char_d, '', '',
+ 'amount', 'varchar', '', $char_d, '', '',
+ ],
+ 'primary_key' => 'usagepricepart',
+ 'unique' => [ [ 'pkgpart', 'currency', 'target' ] ],
+ 'index' => [ [ 'pkgpart' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'pkgpart' ],
+ table => 'part_pkg',
+ },
+ ],
+ },
+
+ 'cust_pkg_usageprice' => {
+ 'columns' => [
+ 'usagepricenum', 'serial', '', '', '', '',
+ 'pkgnum', 'int', '', '', '', '',
+ 'usagepricepart', 'int', '', '', '', '',
+ 'quantity', 'int', '', '', '', '',
+ ],
+ 'primary_key' => 'usagepricenum',
+ 'unique' => [ [ 'pkgnum', 'usagepricepart' ] ],
+ 'index' => [ [ 'pkgnum' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'pkgnum' ],
+ table => 'cust_pkg',
+ },
+ { columns => [ 'usagepricepart' ],
+ table => 'part_pkg_usageprice',
+ },
+ ],
+ },
+
+ 'part_fee' => {
+ 'columns' => [
+ 'feepart', 'serial', '', '', '', '',
+ 'itemdesc', 'varchar', '', $char_d, '', '',
+ 'comment', 'varchar', 'NULL', 2*$char_d, '', '',
+ 'disabled', 'char', 'NULL', 1, '', '',
+ 'classnum', 'int', 'NULL', '', '', '',
+ 'taxclass', 'varchar', 'NULL', $char_d, '', '',
+ 'taxproductnum', 'int', 'NULL', '', '', '',
+ 'pay_weight', 'real', 'NULL', '', '', '',
+ 'credit_weight', 'real', 'NULL', '', '', '',
+ 'agentnum', 'int', 'NULL', '', '', '',
+ 'amount', @money_type, '', '',
+ 'percent', 'decimal', '', '7,4', '', '',
+ 'basis', 'varchar', '', 16, '', '',
+ 'minimum', @money_typen, '', '',
+ 'maximum', @money_typen, '', '',
+ 'limit_credit', 'char', 'NULL', 1, '', '',
+ 'setuprecur', 'char', '', 5, '', '',
+ 'taxable', 'char', 'NULL', 1, '', '',
+ ],
+ 'primary_key' => 'feepart',
+ 'unique' => [],
+ 'index' => [ [ 'disabled' ], [ 'classnum' ], [ 'agentnum' ]
+ ],
+ 'foreign_keys' => [
+ { columns => [ 'classnum' ],
+ table => 'pkg_class',
+ },
+ { columns => [ 'taxproductnum' ],
+ table => 'part_pkg_taxproduct',
+ },
+ { columns => [ 'agentnum' ],
+ table => 'agent',
+ },
+ ],
+ },
+
+ 'part_fee_msgcat' => {
+ 'columns' => [
+ 'feepartmsgnum', 'serial', '', '', '', '',
+ 'feepart', 'int', '', '', '', '',
+ 'locale', 'varchar', '', 16, '', '',
+ 'itemdesc', 'varchar', '', $char_d, '', '', #longer/no limit?
+ 'comment', 'varchar', 'NULL', 2*$char_d, '', '', #longer/no limit?
+ ],
+ 'primary_key' => 'feepartmsgnum',
+ 'unique' => [ [ 'feepart', 'locale' ] ],
+ 'index' => [],
+ 'foreign_keys' => [
+ { columns => [ 'feepart' ],
+ table => 'part_fee',
+ },
+ ],
+ },
+
+ 'part_fee_usage' => {
+ 'columns' => [
+ 'feepartusagenum','serial', '', '', '', '',
+ 'feepart', 'int', '', '', '', '',
+ 'classnum', 'int', '', '', '', '',
+ 'amount', @money_type, '', '',
+ 'percent', 'decimal', '', '7,4', '', '',
+ ],
+ 'primary_key' => 'feepartusagenum',
+ 'unique' => [ [ 'feepart', 'classnum' ] ],
+ 'index' => [],
+ 'foreign_keys' => [
+ { columns => [ 'feepart' ],
+ table => 'part_fee',
+ },
+ { columns => [ 'classnum' ],
+ table => 'usage_class',
+ },
+ ],
+ },
+
'part_pkg_link' => {
'columns' => [
'pkglinknum', 'serial', '', '', '', '',
'link_type', 'varchar', '', $char_d, '', '',
'hidden', 'char', 'NULL', 1, '', '',
],
- 'primary_key' => 'pkglinknum',
- 'unique' => [ [ 'src_pkgpart', 'dst_pkgpart', 'link_type', 'hidden' ] ],
- 'index' => [ [ 'src_pkgpart' ] ],
+ 'primary_key' => 'pkglinknum',
+ 'unique' => [ ['src_pkgpart','dst_pkgpart','link_type','hidden'] ],
+ 'index' => [ [ 'src_pkgpart' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'src_pkgpart' ],
+ table => 'part_pkg',
+ references => [ 'pkgpart' ]
+ },
+ { columns => [ 'dst_pkgpart' ],
+ table => 'part_pkg',
+ references => [ 'pkgpart' ]
+ },
+ ],
},
# XXX somewhat borked unique: we don't really want a hidden and unhidden
# it turns out we'd prefer to use svc, bill, and invisibill (or something)
'pkgpart', 'int', '', '', '', '',
'discountnum', 'int', '', '', '', '',
],
- 'primary_key' => 'pkgdiscountnum',
- 'unique' => [ [ 'pkgpart', 'discountnum' ] ],
- 'index' => [],
+ 'primary_key' => 'pkgdiscountnum',
+ 'unique' => [ [ 'pkgpart', 'discountnum' ] ],
+ 'index' => [],
+ 'foreign_keys' => [
+ { columns => [ 'pkgpart' ],
+ table => 'part_pkg',
+ },
+ { columns => [ 'discountnum' ],
+ table => 'discount',
+ },
+ ],
},
'part_pkg_taxclass' => {
'data_vendor', 'varchar', 'NULL', $char_d, '', '',
'taxproduct', 'varchar', '', $char_d, '', '',
'description', 'varchar', '', 3*$char_d, '', '',
+ 'note', 'text', 'NULL', '', '', '',
],
'primary_key' => 'taxproductnum',
'unique' => [ [ 'data_vendor', 'taxproduct' ] ],
'effdate', @date_type, '', '',
'taxable', 'char', 'NULL', 1, '', '',
],
- 'primary_key' => 'pkgtaxratenum',
- 'unique' => [],
- 'index' => [ [ 'data_vendor', 'geocode', 'taxproductnum' ] ],
+ 'primary_key' => 'pkgtaxratenum',
+ 'unique' => [],
+ 'index' => [ [ 'data_vendor', 'geocode', 'taxproductnum' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'taxproductnum' ],
+ table => 'part_pkg_taxproduct',
+ },
+ { columns => [ 'taxclassnumtaxed' ],
+ table => 'tax_class',
+ references => [ 'taxclassnum' ],
+ },
+ { columns => [ 'taxclassnum' ],
+ table => 'tax_class',
+ },
+ ],
},
'part_pkg_taxoverride' => {
'taxclassnum', 'int', '', '', '', '',
'usage_class', 'varchar', 'NULL', $char_d, '', '',
],
- 'primary_key' => 'taxoverridenum',
- 'unique' => [],
- 'index' => [ [ 'pkgpart' ], [ 'taxclassnum' ] ],
+ 'primary_key' => 'taxoverridenum',
+ 'unique' => [],
+ 'index' => [ [ 'pkgpart' ], [ 'taxclassnum' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'pkgpart' ],
+ table => 'part_pkg',
+ },
+ { columns => [ 'taxclassnum' ],
+ table => 'tax_class',
+ },
+ ],
},
# 'part_title' => {
'pkg_svc' => {
'columns' => [
- 'pkgsvcnum', 'serial', '', '', '', '',
- 'pkgpart', 'int', '', '', '', '',
- 'svcpart', 'int', '', '', '', '',
- 'quantity', 'int', '', '', '', '',
- 'primary_svc','char', 'NULL', 1, '', '',
- 'hidden', 'char', 'NULL', 1, '', '',
- ],
- 'primary_key' => 'pkgsvcnum',
- 'unique' => [ ['pkgpart', 'svcpart'] ],
- 'index' => [ ['pkgpart'], ['quantity'] ],
+ 'pkgsvcnum', 'serial', '', '', '', '',
+ 'pkgpart', 'int', '', '', '', '',
+ 'svcpart', 'int', '', '', '', '',
+ 'quantity', 'int', '', '', '', '',
+ 'primary_svc', 'char', 'NULL', 1, '', '',
+ 'hidden', 'char', 'NULL', 1, '', '',
+ 'bulk_skip', 'char', 'NULL', 1, '', '',
+ ],
+ 'primary_key' => 'pkgsvcnum',
+ 'unique' => [ ['pkgpart', 'svcpart'] ],
+ 'index' => [ ['pkgpart'], ['quantity'] ],
+ 'foreign_keys' => [
+ { columns => [ 'pkgpart' ],
+ table => 'part_pkg',
+ },
+ { columns => [ 'svcpart' ],
+ table => 'part_svc',
+ },
+ ],
},
'part_referral' => {
'disabled', 'char', 'NULL', 1, '', '',
'agentnum', 'int', 'NULL', '', '', '',
],
- 'primary_key' => 'refnum',
- 'unique' => [],
- 'index' => [ ['disabled'], ['agentnum'], ],
+ 'primary_key' => 'refnum',
+ 'unique' => [],
+ 'index' => [ ['disabled'], ['agentnum'], ],
+ 'foreign_keys' => [
+ { columns => [ 'agentnum' ],
+ table => 'agent',
+ },
+ ],
},
'part_svc' => {
'selfservice_access', 'varchar', 'NULL', $char_d, '', '',
'classnum', 'int', 'NULL', '', '', '',
'restrict_edit_password','char', 'NULL', 1, '', '',
+ 'has_router', 'char', 'NULL', 1, '', '',
],
- 'primary_key' => 'svcpart',
- 'unique' => [],
- 'index' => [ [ 'disabled' ] ],
+ 'primary_key' => 'svcpart',
+ 'unique' => [],
+ 'index' => [ [ 'disabled' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'classnum' ],
+ table => 'part_svc_class',
+ },
+ ],
},
'part_svc_column' => {
'columnvalue', 'varchar', 'NULL', 512, '', '',
'columnflag', 'char', 'NULL', 1, '', '',
],
- 'primary_key' => 'columnnum',
- 'unique' => [ [ 'svcpart', 'columnname' ] ],
- 'index' => [ [ 'svcpart' ] ],
+ 'primary_key' => 'columnnum',
+ 'unique' => [ [ 'svcpart', 'columnname' ] ],
+ 'index' => [ [ 'svcpart' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'svcpart' ],
+ table => 'part_svc',
+ },
+ ],
},
'part_svc_class' => {
'npa', 'char', '', 3, '', '',
'nxx', 'char', '', 3, '', '',
],
- 'primary_key' => 'localnum',
- 'unique' => [],
- 'index' => [ [ 'npa', 'nxx' ], [ 'popnum' ] ],
+ 'primary_key' => 'localnum',
+ 'unique' => [],
+ 'index' => [ [ 'npa', 'nxx' ], [ 'popnum' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'popnum' ],
+ table => 'svc_acct_pop',
+ },
+ ],
},
-
+
'qual' => {
'columns' => [
'qualnum', 'serial', '', '', '', '',
'vendor_qual_id', 'varchar', 'NULL', $char_d, '', '',
'status', 'char', '', 1, '', '',
],
- 'primary_key' => 'qualnum',
- 'unique' => [],
- 'index' => [ [ 'locationnum' ], ['custnum'], ['prospectnum'],
- ['phonenum'], ['vendor_qual_id'] ],
+ 'primary_key' => 'qualnum',
+ 'unique' => [],
+ 'index' => [ ['locationnum'], ['custnum'], ['prospectnum'],
+ ['phonenum'], ['vendor_qual_id'],
+ ],
+ 'foreign_keys' => [
+ { columns => [ 'custnum' ],
+ table => 'cust_main',
+ },
+ { columns => [ 'prospectnum' ],
+ table => 'prospect_main',
+ },
+ { columns => [ 'locationnum' ],
+ table => 'cust_location',
+ },
+ { columns => [ 'exportnum' ],
+ table => 'part_export',
+ },
+ ],
},
-
+
'qual_option' => {
'columns' => [
'optionnum', 'serial', '', '', '', '',
'optionname', 'varchar', '', $char_d, '', '',
'optionvalue', 'text', 'NULL', '', '', '',
],
- 'primary_key' => 'optionnum',
- 'unique' => [],
- 'index' => [],
+ 'primary_key' => 'optionnum',
+ 'unique' => [],
+ 'index' => [],
+ 'foreign_keys' => [
+ { columns => [ 'qualnum' ],
+ table => 'qual',
+ },
+ ],
},
'svc_acct' => {
#XXX RPOP settings
#
],
- 'primary_key' => 'svcnum',
- #'unique' => [ [ 'username', 'domsvc' ] ],
- 'unique' => [],
- 'index' => [ ['username'], ['domsvc'], ['pbxsvc'] ],
+ 'primary_key' => 'svcnum',
+ #'unique' => [ [ 'username', 'domsvc' ] ],
+ 'unique' => [],
+ 'index' => [ ['username'], ['domsvc'], ['pbxsvc'] ],
+ 'foreign_keys' => [
+ { columns => [ 'svcnum' ],
+ table => 'cust_svc',
+ },
+ { columns => [ 'popnum' ],
+ table => 'svc_acct_pop',
+ },
+ { columns => [ 'sectornum' ],
+ table => 'tower_sector',
+ },
+ { columns => [ 'routernum' ],
+ table => 'router',
+ },
+ { columns => [ 'blocknum' ],
+ table => 'addr_block',
+ },
+ { columns => [ 'domsvc' ],
+ table => 'svc_domain', #'cust_svc',
+ references => [ 'svcnum' ],
+ },
+ { columns => [ 'pbxsvc' ],
+ table => 'svc_pbx', #'cust_svc',
+ references => [ 'svcnum' ],
+ },
+ ],
},
'acct_rt_transaction' => {
'columns' => [
- 'svcrtid', 'int', '', '', '', '',
+ 'svcrtid', 'int', '', '', '', '', #why am i not a serial
'svcnum', 'int', '', '', '', '',
'transaction_id', 'int', '', '', '', '',
'_date', @date_type, '', '',
'seconds', 'int', '', '', '', '', #uhhhh
'support', 'int', '', '', '', '',
],
- 'primary_key' => 'svcrtid',
- 'unique' => [],
- 'index' => [ ['svcnum', 'transaction_id'] ],
+ 'primary_key' => 'svcrtid',
+ 'unique' => [],
+ 'index' => [ ['svcnum', 'transaction_id'] ],
+ 'foreign_keys' => [
+ { columns => [ 'svcnum' ],
+ table => 'svc_acct', #'cust_svc',
+ },
+ # 1. RT tables aren't part of our data structure, so
+ # we can't make sure Queue is created already
+ # 2. This is our internal hack for time tracking, not
+ # a user-facing feature
+ #{ columns => [ 'transaction_id' ],
+ # table => 'Transaction',
+ # references => [ 'id' ],
+ #},
+ ],
},
#'svc_charge' => {
'suffix', 'varchar', 'NULL', $char_d, '', '',
'catchall', 'int', 'NULL', '', '', '',
'parent_svcnum', 'int', 'NULL', '', '', '',
+ 'quota', 'varchar', 'NULL', $char_d, '', '',
+
+ #registration info
'registrarnum', 'int', 'NULL', '', '', '',
'registrarkey', 'varchar', 'NULL', 512, '', '',
'setup_date', @date_type, '', '',
'renewal_interval', 'int', 'NULL', '', '', '',
'expiration_date', @date_type, '', '',
+
+ #some weird shit australia-specific shit? yuck.. seems totally unused
'au_registrant_name', 'varchar', 'NULL', $char_d, '', '',
'au_eligibility_type', 'varchar', 'NULL', $char_d, '', '',
+
#communigate pro fields (quota = MaxAccountSize)
'max_accounts', 'int', 'NULL', '', '', '',
'trailer', 'text', 'NULL', '', '', '',
'cgp_aliases', 'varchar', 'NULL', 255, '', '',
'cgp_accessmodes','varchar','NULL', 255, '', '', #DomainAccessModes
'cgp_certificatetype','varchar','NULL', $char_d, '', '',
- #settings
+
+ #(account default) settings
'acct_def_password_selfchange', 'char', 'NULL', 1, '', '',
'acct_def_password_recover', 'char', 'NULL', 1, 'Y', '',
'acct_def_cgp_accessmodes', 'varchar', 'NULL', 255, '', '',
'acct_def_cgp_mailtoall', 'char', 'NULL', 1, '', '',
'acct_def_cgp_addmailtrailer', 'char', 'NULL', 1, '', '',
'acct_def_cgp_archiveafter', 'int', 'NULL', '', '', '',
- #preferences
+
+ #(account default) preferences
'acct_def_cgp_deletemode', 'varchar', 'NULL', $char_d, '', '',
'acct_def_cgp_emptytrash', 'varchar', 'NULL', $char_d, '', '',
'acct_def_cgp_language', 'varchar', 'NULL', $char_d, '', '',
'acct_def_cgp_prontoskinname', 'varchar', 'NULL', $char_d, '', '',
'acct_def_cgp_sendmdnmode', 'varchar', 'NULL', $char_d, '', '',
],
- 'primary_key' => 'svcnum',
- 'unique' => [ ],
- 'index' => [ ['domain'] ],
+ 'primary_key' => 'svcnum',
+ 'unique' => [],
+ 'index' => [ ['domain'] ],
+ 'foreign_keys' => [
+ { columns => [ 'svcnum' ],
+ table => 'cust_svc',
+ },
+ { columns => [ 'catchall' ],
+ table => 'svc_acct',
+ references => [ 'svcnum' ],
+ },
+ { columns => [ 'parent_svcnum' ],
+ table => 'cust_svc',
+ references => [ 'svcnum' ],
+ },
+ { columns => [ 'registrarnum' ],
+ table => 'registrar',
+ },
+ ],
},
-
+
'svc_dsl' => {
'columns' => [
'svcnum', 'int', '', '', '', '',
'monitored', 'char', 'NULL', 1, '', '',
'last_pull', 'int', 'NULL', '', '', '',
],
- 'primary_key' => 'svcnum',
- 'unique' => [ ],
- 'index' => [ ['phonenum'], ['vendor_order_id'] ],
+ 'primary_key' => 'svcnum',
+ 'unique' => [ ],
+ 'index' => [ ['phonenum'], ['vendor_order_id'] ],
+ 'foreign_keys' => [
+ { columns => [ 'svcnum' ],
+ table => 'cust_svc',
+ },
+ ],
},
'dsl_device' => {
'svcnum', 'int', '', '', '', '',
'mac_addr', 'varchar', '', 12, '', '',
],
- 'primary_key' => 'devicenum',
- 'unique' => [ [ 'mac_addr' ], ],
- 'index' => [ [ 'svcnum' ], ], # [ 'devicepart' ] ],
+ 'primary_key' => 'devicenum',
+ 'unique' => [ [ 'mac_addr' ], ],
+ 'index' => [ [ 'svcnum' ], ], # [ 'devicepart' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'svcnum' ],
+ table => 'svc_dsl',
+ },
+ ],
},
-
+
'dsl_note' => {
'columns' => [
'notenum', 'serial', '', '', '', '',
'_date', 'int', 'NULL', '', '', '',
'note', 'text', '', '', '', '',
],
- 'primary_key' => 'notenum',
- 'unique' => [ ],
- 'index' => [ ['svcnum'] ],
+ 'primary_key' => 'notenum',
+ 'unique' => [],
+ 'index' => [ ['svcnum'] ],
+ 'foreign_keys' => [
+ { columns => [ 'svcnum' ],
+ table => 'svc_dsl',
+ },
+ ],
},
'svc_dish' => {
'installdate', @date_type, '', '',
'note', 'text', 'NULL', '', '', '',
],
- 'primary_key' => 'svcnum',
- 'unique' => [ ],
- 'index' => [ ],
+ 'primary_key' => 'svcnum',
+ 'unique' => [],
+ 'index' => [],
+ 'foreign_keys' => [
+ { columns => [ 'svcnum' ],
+ table => 'cust_svc',
+ },
+ ],
},
'svc_hardware' => {
'statusnum','int', 'NULL', '', '', '',
'note', 'text', 'NULL', '', '', '',
],
- 'primary_key' => 'svcnum',
- 'unique' => [ ],
- 'index' => [ ],
+ 'primary_key' => 'svcnum',
+ 'unique' => [],
+ 'index' => [],
+ 'foreign_keys' => [
+ { columns => [ 'svcnum' ],
+ table => 'cust_svc',
+ },
+ { columns => [ 'typenum' ],
+ table => 'hardware_type',
+ },
+ { columns => [ 'statusnum' ],
+ table => 'hardware_status',
+ },
+ ],
},
'hardware_class' => {
'classname', 'varchar', '', $char_d, '', '',
],
'primary_key' => 'classnum',
- 'unique' => [ ],
- 'index' => [ ],
+ 'unique' => [],
+ 'index' => [],
},
'hardware_type' => {
'model', 'varchar', '', $char_d, '', '',
'revision','varchar', 'NULL', $char_d, '', '',
],
- 'primary_key' => 'typenum',
- 'unique' => [ [ 'classnum', 'model', 'revision' ] ],
- 'index' => [ ],
+ 'primary_key' => 'typenum',
+ 'unique' => [ [ 'classnum', 'model', 'revision' ] ],
+ 'index' => [],
+ 'foreign_keys' => [
+ { columns => [ 'classnum' ],
+ table => 'hardware_class',
+ },
+ ],
},
'hardware_status' => {
'disabled', 'char', 'NULL', 1, '', '',
],
'primary_key' => 'statusnum',
- 'unique' => [ ],
- 'index' => [ ],
+ 'unique' => [],
+ 'index' => [],
},
'domain_record' => {
'recdata', 'varchar', '', 255, '', '',
'ttl', 'int', 'NULL', '', '', '',
],
- 'primary_key' => 'recnum',
- 'unique' => [],
- 'index' => [ ['svcnum'] ],
+ 'primary_key' => 'recnum',
+ 'unique' => [],
+ 'index' => [ ['svcnum'] ],
+ 'foreign_keys' => [
+ { columns => [ 'svcnum' ],
+ table => 'svc_domain',
+ },
+ ],
},
'registrar' => {
'primary_key' => 'rulenum',
'unique' => [ [ 'svcnum', 'name' ] ],
'index' => [ [ 'svcnum' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'svcnum' ],
+ table => 'cust_svc', #svc_acct / svc_domain
+ },
+ ],
},
'cgp_rule_condition' => {
'params', 'varchar', 'NULL', 255, '', '',
'rulenum', 'int', '', '', '', '',
],
- 'primary_key' => 'ruleconditionnum',
- 'unique' => [],
- 'index' => [ [ 'rulenum' ] ],
+ 'primary_key' => 'ruleconditionnum',
+ 'unique' => [],
+ 'index' => [ [ 'rulenum' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'rulenum' ],
+ table => 'cgp_rule',
+ },
+ ],
},
'cgp_rule_action' => {
'params', 'varchar', 'NULL', 255, '', '',
'rulenum', 'int', '', '', '', '',
],
- 'primary_key' => 'ruleactionnum',
- 'unique' => [],
- 'index' => [ [ 'rulenum' ] ],
+ 'primary_key' => 'ruleactionnum',
+ 'unique' => [],
+ 'index' => [ [ 'rulenum' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'rulenum' ],
+ table => 'cgp_rule',
+ },
+ ],
},
'svc_forward' => {
'dstsvc', 'int', 'NULL', '', '', '',
'dst', 'varchar', 'NULL', 255, '', '',
],
- 'primary_key' => 'svcnum',
- 'unique' => [],
- 'index' => [ ['srcsvc'], ['dstsvc'] ],
+ 'primary_key' => 'svcnum',
+ 'unique' => [],
+ 'index' => [ ['srcsvc'], ['dstsvc'] ],
+ 'foreign_keys' => [
+ { columns => [ 'svcnum' ],
+ table => 'cust_svc',
+ },
+ { columns => [ 'srcsvc' ],
+ table => 'svc_acct',
+ references => [ 'svcnum' ]
+ },
+ { columns => [ 'dstsvc' ],
+ table => 'svc_acct',
+ references => [ 'svcnum' ]
+ },
+ ],
},
'svc_www' => {
'primary_key' => 'svcnum',
'unique' => [],
'index' => [],
+ 'foreign_keys' => [
+ { columns => [ 'svcnum' ],
+ table => 'cust_svc',
+ },
+ { columns => [ 'recnum' ],
+ table => 'domain_record',
+ },
+ { columns => [ 'usersvc' ],
+ table => 'svc_acct',
+ references => [ 'svcnum' ]
+ },
+ ],
},
#'svc_wo' => {
'totalbytes', 'bigint', 'NULL', '', '', '',
'agentnum', 'int', 'NULL', '', '', '',
],
- 'primary_key' => 'prepaynum',
- 'unique' => [ ['identifier'] ],
- 'index' => [],
+ 'primary_key' => 'prepaynum',
+ 'unique' => [ ['identifier'] ],
+ 'index' => [ ['agentnum'] ],
+ 'foreign_keys' => [
+ { columns => [ 'agentnum' ],
+ table => 'agent',
+ },
+ ],
},
'port' => {
'nasport', 'int', 'NULL', '', '', '',
'nasnum', 'int', '', '', '', '',
],
- 'primary_key' => 'portnum',
- 'unique' => [],
- 'index' => [],
+ 'primary_key' => 'portnum',
+ 'unique' => [],
+ 'index' => [],
+ 'foreign_keys' => [
+ { columns => [ 'nasnum' ],
+ table => 'nas',
+ },
+ ],
},
'nas' => {
'description', 'varchar', '', 200, 'RADIUS Client', '',
'svcnum', 'int', 'NULL', '', '', '',
],
- 'primary_key' => 'nasnum',
- 'unique' => [ [ 'nasname' ], ],
- 'index' => [],
+ 'primary_key' => 'nasnum',
+ 'unique' => [ [ 'nasname' ], ],
+ 'index' => [],
+ 'foreign_keys' => [
+ { columns => [ 'svcnum' ],
+ table => 'svc_broadband',#no? could be _acct?
+ #remove or cust_svc?
+ },
+ ],
},
'export_nas' => {
'exportnum', 'int', '', '', '', '',
'nasnum', 'int', '', '', '', '',
],
- 'primary_key' => 'exportnasnum',
- 'unique' => [ [ 'exportnum', 'nasnum' ] ],
- 'index' => [ [ 'exportnum' ], [ 'nasnum' ] ],
+ 'primary_key' => 'exportnasnum',
+ 'unique' => [ [ 'exportnum', 'nasnum' ] ],
+ 'index' => [ [ 'exportnum' ], [ 'nasnum' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'exportnum' ],
+ table => 'part_export',
+ },
+ { columns => [ 'nasnum' ],
+ table => 'nas',
+ },
+ ],
},
'queue' => {
'columns' => [
- 'jobnum', 'serial', '', '', '', '',
+ 'jobnum', 'bigserial', '', '', '', '',
'job', 'varchar', '', 512, '', '',
'_date', 'int', '', '', '', '',
'status', 'varchar', '', $char_d, '', '',
'secure', 'char', 'NULL', 1, '', '',
'priority', 'int', 'NULL', '', '', '',
],
- 'primary_key' => 'jobnum',
- 'unique' => [],
- 'index' => [ [ 'secure' ], [ 'priority' ],
- [ 'job' ], [ 'svcnum' ], [ 'custnum' ], [ 'status' ],
- ],
+ 'primary_key' => 'jobnum',
+ 'unique' => [],
+ 'index' => [ [ 'secure' ], [ 'priority' ],
+ [ 'job' ], [ 'svcnum' ], [ 'custnum' ], [ 'status' ],
+ ],
+ 'foreign_keys' => [
+# { columns => [ 'svcnum' ],
+# table => 'cust_svc',
+# },
+ { columns => [ 'custnum' ],
+ table => 'cust_main',
+ },
+ ],
},
'queue_arg' => {
'columns' => [
- 'argnum', 'serial', '', '', '', '',
- 'jobnum', 'int', '', '', '', '',
- 'frozen', 'char', 'NULL', 1, '', '',
- 'arg', 'text', 'NULL', '', '', '',
- ],
- 'primary_key' => 'argnum',
- 'unique' => [],
- 'index' => [ [ 'jobnum' ] ],
+ 'argnum', 'bigserial', '', '', '', '',
+ 'jobnum', 'bigint', '', '', '', '',
+ 'frozen', 'char', 'NULL', 1, '', '',
+ 'arg', 'text', 'NULL', '', '', '',
+ ],
+ 'primary_key' => 'argnum',
+ 'unique' => [],
+ 'index' => [ [ 'jobnum' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'jobnum' ],
+ table => 'queue',
+ on_delete => 'CASCADE',
+ },
+ ],
},
'queue_depend' => {
'columns' => [
- 'dependnum', 'serial', '', '', '', '',
- 'jobnum', 'int', '', '', '', '',
- 'depend_jobnum', 'int', '', '', '', '',
+ 'dependnum', 'bigserial', '', '', '', '',
+ 'jobnum', 'bigint', '', '', '', '',
+ 'depend_jobnum', 'bigint', '', '', '', '',
+ ],
+ 'primary_key' => 'dependnum',
+ 'unique' => [],
+ 'index' => [ [ 'jobnum' ], [ 'depend_jobnum' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'jobnum' ],
+ table => 'queue',
+ },
+ { columns => [ 'depend_jobnum' ],
+ table => 'queue',
+ references => [ 'jobnum' ],
+ on_delete => 'CASCADE',
+ },
+ ],
+ },
+
+ 'queue_stat' => {
+ 'columns' => [
+ 'statnum', 'bigserial', '', '', '', '',
+ 'jobnum', 'bigint', '', '', '', '',
+ 'job', 'varchar', '', 512, '', '',
+ 'custnum', 'int', 'NULL', '', '', '',
+ 'insert_date', @date_type, '', '',
+ 'start_date', @date_type, '', '',
+ 'end_date', @date_type, '', '',
],
- 'primary_key' => 'dependnum',
- 'unique' => [],
- 'index' => [ [ 'jobnum' ], [ 'depend_jobnum' ] ],
+ 'primary_key' => 'statnum',
+ 'unique' => [], #[ ['jobnum'] ],
+ 'index' => [],
},
'export_svc' => {
'exportsvcnum' => 'serial', '', '', '', '',
'exportnum' => 'int', '', '', '', '',
'svcpart' => 'int', '', '', '', '',
- ],
- 'primary_key' => 'exportsvcnum',
- 'unique' => [ [ 'exportnum', 'svcpart' ] ],
- 'index' => [ [ 'exportnum' ], [ 'svcpart' ] ],
+ 'role' => 'varchar', 'NULL', 16, '', '',
+ ],
+ 'primary_key' => 'exportsvcnum',
+ 'unique' => [ [ 'exportnum', 'svcpart' ] ],
+ 'index' => [ [ 'exportnum' ], [ 'svcpart' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'exportnum' ],
+ table => 'part_export',
+ },
+ { columns => [ 'svcpart' ],
+ table => 'part_svc',
+ },
+ ],
},
'export_device' => {
'columns' => [
'exportdevicenum' => 'serial', '', '', '', '',
- 'exportnum' => 'int', '', '', '', '',
+ 'exportnum' => 'int', '', '', '', '',
'devicepart' => 'int', '', '', '', '',
],
- 'primary_key' => 'exportdevicenum',
- 'unique' => [ [ 'exportnum', 'devicepart' ] ],
- 'index' => [ [ 'exportnum' ], [ 'devicepart' ] ],
+ 'primary_key' => 'exportdevicenum',
+ 'unique' => [ [ 'exportnum', 'devicepart' ] ],
+ 'index' => [ [ 'exportnum' ], [ 'devicepart' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'exportnum' ],
+ table => 'part_export',
+ },
+ { columns => [ 'devicepart' ],
+ table => 'part_device',
+ },
+ ],
},
'part_export' => {
'nodomain', 'char', 'NULL', 1, '', '',
'default_machine','int', 'NULL', '', '', '',
],
- 'primary_key' => 'exportnum',
- 'unique' => [],
- 'index' => [ [ 'machine' ], [ 'exporttype' ] ],
+ 'primary_key' => 'exportnum',
+ 'unique' => [],
+ 'index' => [ [ 'machine' ], [ 'exporttype' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'default_machine' ],
+ table => 'part_export_machine',
+ references => [ 'machinenum' ]
+ },
+ ],
},
'part_export_option' => {
'optionname', 'varchar', '', $char_d, '', '',
'optionvalue', 'text', 'NULL', '', '', '',
],
- 'primary_key' => 'optionnum',
- 'unique' => [],
- 'index' => [ [ 'exportnum' ], [ 'optionname' ] ],
+ 'primary_key' => 'optionnum',
+ 'unique' => [],
+ 'index' => [ [ 'exportnum' ], [ 'optionname' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'exportnum' ],
+ table => 'part_export',
+ },
+ ],
},
'radius_usergroup' => {
'columns' => [
'usergroupnum', 'serial', '', '', '', '',
'svcnum', 'int', '', '', '', '',
- 'groupname', 'varchar', 'NULL', $char_d, '', '',
+ 'groupname', 'varchar', 'NULL', $char_d, '', '', #deprecated
'groupnum', 'int', 'NULL', '', '', '',
],
- 'primary_key' => 'usergroupnum',
- 'unique' => [],
- 'index' => [ [ 'svcnum' ], [ 'groupname' ] ],
+ 'primary_key' => 'usergroupnum',
+ 'unique' => [],
+ 'index' => [ [ 'svcnum' ], [ 'groupname' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'svcnum' ],
+ table => 'cust_svc', #svc_acct / svc_broadband
+ },
+ { columns => [ 'groupnum' ],
+ table => 'radius_group',
+ },
+ ],
},
-
+
'radius_group' => {
'columns' => [
'groupnum', 'serial', '', '', '', '',
'attrtype', 'char', '', 1, '', '',
'op', 'char', '', 2, '', '',
],
- 'primary_key' => 'attrnum',
- 'unique' => [],
- 'index' => [ ['groupnum'], ],
+ 'primary_key' => 'attrnum',
+ 'unique' => [],
+ 'index' => [ ['groupnum'], ],
+ 'foreign_keys' => [
+ { columns => [ 'groupnum' ],
+ table => 'radius_group',
+ },
+ ],
},
'msgcat' => {
'month', 'int', '', '', '', '',
'amount', @money_type, '', '',
],
- 'primary_key' => 'exemptnum',
- 'unique' => [ [ 'custnum', 'taxnum', 'year', 'month' ] ],
- 'index' => [],
+ 'primary_key' => 'exemptnum',
+ 'unique' => [ [ 'custnum', 'taxnum', 'year', 'month' ] ],
+ 'index' => [],
+ 'foreign_keys' => [
+ { columns => [ 'custnum' ],
+ table => 'cust_main',
+ },
+ { columns => [ 'taxnum' ],
+ table => 'cust_main_county',
+ },
+ ],
},
'cust_tax_exempt_pkg' => {
'exempt_cust_taxname', 'char', 'NULL', 1, '', '',
'exempt_monthly', 'char', 'NULL', 1, '', '',
],
- 'primary_key' => 'exemptpkgnum',
- 'unique' => [],
- 'index' => [ [ 'taxnum', 'year', 'month' ],
- [ 'billpkgnum' ],
- [ 'taxnum' ],
- [ 'creditbillpkgnum' ],
- ],
+ 'primary_key' => 'exemptpkgnum',
+ 'unique' => [],
+ 'index' => [ [ 'taxnum', 'year', 'month' ],
+ [ 'billpkgnum' ],
+ [ 'taxnum' ],
+ [ 'creditbillpkgnum' ],
+ ],
+ 'foreign_keys' => [
+ { columns => [ 'billpkgnum' ],
+ table => 'cust_bill_pkg',
+ },
+ { columns => [ 'taxnum' ],
+ table => 'cust_main_county',
+ },
+ { columns => [ 'creditbillpkgnum' ],
+ table => 'cust_credit_bill_pkg',
+ },
+ ],
},
'cust_tax_exempt_pkg_void' => {
'exempt_cust_taxname', 'char', 'NULL', 1, '', '',
'exempt_monthly', 'char', 'NULL', 1, '', '',
],
- 'primary_key' => 'exemptpkgnum',
- 'unique' => [],
- 'index' => [ [ 'taxnum', 'year', 'month' ],
- [ 'billpkgnum' ],
- [ 'taxnum' ],
- [ 'creditbillpkgnum' ],
- ],
+ 'primary_key' => 'exemptpkgnum',
+ 'unique' => [],
+ 'index' => [ [ 'taxnum', 'year', 'month' ],
+ [ 'billpkgnum' ],
+ [ 'taxnum' ],
+ [ 'creditbillpkgnum' ],
+ ],
+ 'foreign_keys' => [
+ { columns => [ 'billpkgnum' ],
+ table => 'cust_bill_pkg_void',
+ },
+ { columns => [ 'taxnum' ],
+ table => 'cust_main_county',
+ },
+ { columns => [ 'creditbillpkgnum' ],
+ table => 'cust_credit_bill_pkg',
+ },
+ ],
},
'router' => {
'agentnum', 'int', 'NULL', '', '', '',
'manual_addr', 'char', 'NULL', 1, '', '',
],
- 'primary_key' => 'routernum',
- 'unique' => [],
- 'index' => [],
+ 'primary_key' => 'routernum',
+ 'unique' => [],
+ 'index' => [],
+ 'foreign_keys' => [
+ { columns => [ 'svcnum' ],
+ table => 'cust_svc', #svc_acct / svc_broadband
+ },
+ { columns => [ 'agentnum' ],
+ table => 'agent',
+ },
+ ],
},
'part_svc_router' => {
'svcpart', 'int', '', '', '', '',
'routernum', 'int', '', '', '', '',
],
- 'primary_key' => 'svcrouternum',
- 'unique' => [],
- 'index' => [],
+ 'primary_key' => 'svcrouternum',
+ 'unique' => [],
+ 'index' => [],
+ 'foreign_keys' => [
+ { columns => [ 'svcpart' ],
+ table => 'part_svc',
+ },
+ { columns => [ 'routernum' ],
+ table => 'router',
+ },
+ ],
},
'addr_block' => {
'agentnum', 'int', 'NULL', '', '', '',
'manual_flag', 'char', 'NULL', 1, '', '',
],
- 'primary_key' => 'blocknum',
- 'unique' => [ [ 'blocknum', 'routernum' ] ],
+ 'primary_key' => 'blocknum',
+ 'unique' => [ [ 'blocknum', 'routernum' ] ],
+ 'index' => [],
+ 'foreign_keys' => [
+ #{ columns => [ 'routernum' ],
+ # table => 'router',
+ #},
+ { columns => [ 'agentnum' ],
+ table => 'agent',
+ },
+ ],
+ },
+
+ 'addr_range' => {
+ 'columns' => [
+ 'rangenum', 'serial', '', '', '', '',
+ 'start', 'varchar', '', 15, '', '',
+ 'length', 'int', '', '', '', '',
+ 'status', 'varchar', 'NULL', 32, '', '',
+ ],
+ 'primary_key' => 'rangenum',
+ 'unique' => [],
'index' => [],
},
'rssi', 'int', 'NULL', '', '', '',
'suid', 'int', 'NULL', '', '', '',
'shared_svcnum', 'int', 'NULL', '', '', '',
- ],
- 'primary_key' => 'svcnum',
- 'unique' => [ [ 'ip_addr' ], [ 'mac_addr' ] ],
- 'index' => [],
+ 'serviceid', 'varchar', 'NULL', 64, '', '',#srvexport/reportfields
+ ],
+ 'primary_key' => 'svcnum',
+ 'unique' => [ [ 'ip_addr' ], [ 'mac_addr' ] ],
+ 'index' => [],
+ 'foreign_keys' => [
+ { columns => [ 'svcnum' ],
+ table => 'cust_svc',
+ },
+ { columns => [ 'routernum' ],
+ table => 'router',
+ },
+ { columns => [ 'blocknum' ],
+ table => 'addr_block',
+ },
+ { columns => [ 'sectornum' ],
+ table => 'tower_sector',
+ },
+ { columns => [ 'shared_svcnum' ],
+ table => 'svc_broadband',
+ references => [ 'svcnum' ],
+ },
+ ],
},
'tower' => {
'columns' => [
- 'towernum', 'serial', '', '', '', '',
- #'agentnum', 'int', 'NULL', '', '', '',
- 'towername', 'varchar', '', $char_d, '', '',
- 'disabled', 'char', 'NULL', 1, '', '',
- 'latitude', 'decimal', 'NULL', '10,7', '', '',
- 'longitude','decimal', 'NULL', '10,7', '', '',
- 'altitude', 'decimal', 'NULL', '', '', '',
- 'coord_auto', 'char', 'NULL', 1, '', '',
+ 'towernum', 'serial', '', '', '', '',
+ #'agentnum', 'int', 'NULL', '', '', '',
+ 'towername', 'varchar', '', $char_d, '', '',
+ 'disabled', 'char', 'NULL', 1, '', '',
+ 'latitude', 'decimal', 'NULL', '10,7', '', '',
+ 'longitude', 'decimal', 'NULL', '10,7', '', '',
+ 'coord_auto', 'char', 'NULL', 1, '', '',
+ 'altitude', 'decimal', 'NULL', '', '', '',
+ 'height', 'decimal', 'NULL', '', '', '',
+ 'veg_height', 'decimal', 'NULL', '', '', '',
+ 'color', 'varchar', 'NULL', 6, '', '',
],
'primary_key' => 'towernum',
'unique' => [ [ 'towername' ] ], # , 'agentnum' ] ],
'tower_sector' => {
'columns' => [
- 'sectornum', 'serial', '', '', '', '',
- 'towernum', 'int', '', '', '', '',
- 'sectorname', 'varchar', '', $char_d, '', '',
- 'ip_addr', 'varchar', 'NULL', 15, '', '',
- ],
- 'primary_key' => 'sectornum',
- 'unique' => [ [ 'towernum', 'sectorname' ], [ 'ip_addr' ], ],
- 'index' => [ [ 'towernum' ] ],
+ 'sectornum', 'serial', '', '', '', '',
+ 'towernum', 'int', '', '', '', '',
+ 'sectorname', 'varchar', '', $char_d, '', '',
+ 'ip_addr', 'varchar', 'NULL', 15, '', '',
+ 'height', 'decimal', 'NULL', '', '', '',
+ 'freq_mhz', 'int', 'NULL', '', '', '',
+ 'direction', 'int', 'NULL', '', '', '',
+ 'width', 'int', 'NULL', '', '', '',
+ #downtilt etc? rfpath has profile files for devices/antennas you upload?
+ 'sector_range', 'decimal', 'NULL', '', '', '', #?
+ ],
+ 'primary_key' => 'sectornum',
+ 'unique' => [ [ 'towernum', 'sectorname' ], [ 'ip_addr' ], ],
+ 'index' => [ [ 'towernum' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'towernum' ],
+ table => 'tower',
+ },
+ ],
},
'part_virtual_field' => {
'vfieldpart', 'int', '', '', '', '',
'value', 'varchar', '', 128, '', '',
],
- 'primary_key' => 'vfieldnum',
- 'unique' => [ [ 'vfieldpart', 'recnum' ] ],
- 'index' => [],
+ 'primary_key' => 'vfieldnum',
+ 'unique' => [ [ 'vfieldpart', 'recnum' ] ],
+ 'index' => [],
+ 'foreign_keys' => [
+ { columns => [ 'vfieldpart' ],
+ table => 'part_virtual_field',
+ },
+ ],
},
'acct_snarf' => {
'tls', 'char', 'NULL', 1, '', '',
'mailbox', 'varchar', 'NULL', $char_d, '', '',
],
- 'primary_key' => 'snarfnum',
- 'unique' => [],
- 'index' => [ [ 'svcnum' ] ],
+ 'primary_key' => 'snarfnum',
+ 'unique' => [],
+ 'index' => [ [ 'svcnum' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'svcnum' ],
+ table => 'svc_acct',
+ },
+ ],
},
'svc_external' => {
'id', 'bigint', 'NULL', '', '', '',
'title', 'varchar', 'NULL', $char_d, '', '',
],
- 'primary_key' => 'svcnum',
- 'unique' => [],
- 'index' => [],
+ 'primary_key' => 'svcnum',
+ 'unique' => [],
+ 'index' => [],
+ 'foreign_keys' => [
+ { columns => [ 'svcnum' ],
+ table => 'cust_svc',
+ },
+ ],
},
'cust_pay_refund' => {
'_date', @date_type, '', '',
'amount', @money_type, '', '',
],
- 'primary_key' => 'payrefundnum',
- 'unique' => [],
- 'index' => [ ['paynum'], ['refundnum'] ],
+ 'primary_key' => 'payrefundnum',
+ 'unique' => [],
+ 'index' => [ ['paynum'], ['refundnum'] ],
+ 'foreign_keys' => [
+ { columns => [ 'paynum' ],
+ table => 'cust_pay',
+ },
+ { columns => [ 'refundnum' ],
+ table => 'cust_refund',
+ },
+ ],
},
'part_pkg_option' => {
'optionname', 'varchar', '', $char_d, '', '',
'optionvalue', 'text', 'NULL', '', '', '',
],
- 'primary_key' => 'optionnum',
- 'unique' => [],
- 'index' => [ [ 'pkgpart' ], [ 'optionname' ] ],
+ 'primary_key' => 'optionnum',
+ 'unique' => [],
+ 'index' => [ [ 'pkgpart' ], [ 'optionname' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'pkgpart' ],
+ table => 'part_pkg',
+ },
+ ],
},
'part_pkg_vendor' => {
'exportnum', 'int', '', '', '', '',
'vendor_pkg_id', 'varchar', '', $char_d, '', '',
],
- 'primary_key' => 'num',
- 'unique' => [ [ 'pkgpart', 'exportnum' ] ],
- 'index' => [ [ 'pkgpart' ] ],
+ 'primary_key' => 'num',
+ 'unique' => [ [ 'pkgpart', 'exportnum' ] ],
+ 'index' => [ [ 'pkgpart' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'pkgpart' ],
+ table => 'part_pkg',
+ },
+ { columns => [ 'exportnum' ],
+ table => 'part_export',
+ },
+ ],
},
-
+
'part_pkg_report_option' => {
'columns' => [
'num', 'serial', '', '', '', '',
'columns' => [
'pkgusagepart', 'serial', '', '', '', '',
'pkgpart', 'int', '', '', '', '',
- 'minutes', 'int', '', '', '', '',
+ 'minutes', 'double precision', '', '', '', '',
'priority', 'int', 'NULL', '', '', '',
'shared', 'char', 'NULL', 1, '', '',
'rollover', 'char', 'NULL', 1, '', '',
'description', 'varchar', 'NULL', $char_d, '', '',
],
- 'primary_key' => 'pkgusagepart',
- 'unique' => [],
- 'index' => [ [ 'pkgpart' ] ],
+ 'primary_key' => 'pkgusagepart',
+ 'unique' => [],
+ 'index' => [ [ 'pkgpart' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'pkgpart' ],
+ table => 'part_pkg',
+ },
+ ],
},
'part_pkg_usage_class' => {
'pkgusagepart', 'int', '', '', '', '',
'classnum', 'int','NULL', '', '', '',
],
+ 'primary_key' => 'num',
+ 'unique' => [ [ 'pkgusagepart', 'classnum' ] ],
+ 'index' => [],
+ 'foreign_keys' => [
+ { columns => [ 'pkgusagepart' ],
+ table => 'part_pkg_usage',
+ },
+ { columns => [ 'classnum' ],
+ table => 'usage_class',
+ },
+ ],
+ },
+
+ 'part_pkg_fcc_option' => {
+ 'columns' => [
+ 'num', 'serial', '', '', '', '',
+ 'fccoptionname', 'varchar', '', $char_d, '', '',
+ 'pkgpart', 'int', '', '', '', '',
+ 'optionvalue', 'varchar', 'NULL', $char_d, '', '',
+ ],
'primary_key' => 'num',
- 'unique' => [ [ 'pkgusagepart', 'classnum' ] ],
+ 'unique' => [ [ 'fccoptionname', 'pkgpart' ] ],
'index' => [],
},
'rate' => {
'columns' => [
- 'ratenum', 'serial', '', '', '', '',
- 'ratename', 'varchar', '', $char_d, '', '',
+ 'ratenum', 'serial', '', '', '', '',
+ 'ratename', 'varchar', '',$char_d, '', '',
+ 'agentnum', 'int', 'NULL', '', '', '',
+ 'default_detailnum', 'int', 'NULL', '', '', '',
],
'primary_key' => 'ratenum',
'unique' => [],
'index' => [],
+ 'foreign_keys' => [
+ { columns => [ 'agentnum' ],
+ table => 'agent',
+ },
+ ],
},
'rate_detail' => {
'ratedetailnum', 'serial', '', '', '', '',
'ratenum', 'int', '', '', '', '',
'orig_regionnum', 'int', 'NULL', '', '', '',
- 'dest_regionnum', 'int', '', '', '', '',
+ 'dest_regionnum', 'int', 'NULL', '', '', '',
'min_included', 'int', '', '', '', '',
'conn_charge', 'decimal', '', '10,4', '0.0000', '',
+ 'conn_cost', 'decimal', '', '10,4', '0.0000', '',
'conn_sec', 'int', '', '', '0', '',
'min_charge', 'decimal', '', '10,5', '', '',
+ 'min_cost', 'decimal', '', '10,5','0.00000', '',
'sec_granularity', 'int', '', '', '', '',
'ratetimenum', 'int', 'NULL', '', '', '',
'classnum', 'int', 'NULL', '', '', '',
'cdrtypenum', 'int', 'NULL', '', '', '',
- 'region_group', 'char', 'NULL', 1, '', '',
- ],
- 'primary_key' => 'ratedetailnum',
- 'unique' => [ [ 'ratenum', 'orig_regionnum', 'dest_regionnum' ] ],
- 'index' => [ [ 'ratenum', 'dest_regionnum' ],
- [ 'ratenum', 'ratetimenum' ]
- ],
+ 'region_group', 'char', 'NULL', 1, '', '',
+ 'upstream_mult_charge', 'decimal', '', '10,4', '0.0000', '',
+ 'upstream_mult_cost', 'decimal', '', '10,4', '0.0000', '',
+ ],
+ 'primary_key' => 'ratedetailnum',
+ 'unique' => [ [ 'ratenum', 'orig_regionnum', 'dest_regionnum' ] ],
+ 'index' => [ [ 'ratenum', 'dest_regionnum' ],
+ [ 'ratenum', 'ratetimenum' ]
+ ],
+ 'foreign_keys' => [
+ { columns => [ 'ratenum' ],
+ table => 'rate',
+ },
+ { columns => [ 'orig_regionnum' ],
+ table => 'rate_region',
+ references => [ 'regionnum' ],
+ },
+ { columns => [ 'dest_regionnum' ],
+ table => 'rate_region',
+ references => [ 'regionnum' ],
+ },
+ { columns => [ 'ratetimenum' ],
+ table => 'rate_time',
+ },
+ { columns => [ 'classnum' ],
+ table => 'usage_class',
+ },
+ { columns => [ 'cdrtypenum' ],
+ table => 'cdr_type',
+ },
+ ],
},
'rate_region' => {
'state', 'char', 'NULL', 2, '', '',
'ocn', 'char', 'NULL', 4, '', '',
],
- 'primary_key' => 'prefixnum',
- 'unique' => [],
- 'index' => [ [ 'countrycode' ], [ 'npa' ], [ 'regionnum' ] ],
+ 'primary_key' => 'prefixnum',
+ 'unique' => [],
+ 'index' => [ [ 'countrycode' ], [ 'npa' ], [ 'regionnum' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'regionnum' ],
+ table => 'rate_region',
+ },
+ { columns => [ 'latanum' ],
+ table => 'lata',
+ },
+ ],
},
'rate_time' => {
'etime', 'int', '', '', '', '',
'ratetimenum', 'int', '', '', '', '',
],
- 'primary_key' => 'intervalnum',
- 'unique' => [],
- 'index' => [],
- },
+ 'primary_key' => 'intervalnum',
+ 'unique' => [],
+ 'index' => [],
+ 'foreign_keys' => [
+ { columns => [ 'ratetimenum' ],
+ table => 'rate_time',
+ },
+ ],
+ },
#not really part of the above rate_ stuff (used with flat rate rather than
# rated billing), but could be eventually, and its a rate
'min_quan', 'int', '', '', '', '',
'min_charge', 'decimal', '', '10,4', '', '',
],
- 'primary_key' => 'tierdetailnum',
- 'unique' => [],
- 'index' => [ ['tiernum'], ],
+ 'primary_key' => 'tierdetailnum',
+ 'unique' => [],
+ 'index' => [ ['tiernum'], ],
+ 'foreign_keys' => [
+ { columns => [ 'tiernum' ],
+ table => 'rate_tier',
+ },
+ ],
},
'usage_class' => {
'code', 'varchar', '', $char_d, '', '',
'agentnum', 'int', '', '', '', '',
],
- 'primary_key' => 'codenum',
- 'unique' => [ [ 'agentnum', 'code' ] ],
- 'index' => [ [ 'agentnum' ] ],
- },
+ 'primary_key' => 'codenum',
+ 'unique' => [ [ 'agentnum', 'code' ] ],
+ 'index' => [ [ 'agentnum' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'agentnum' ],
+ table => 'agent',
+ },
+ ],
+ },
'reg_code_pkg' => {
'columns' => [
'codenum', 'int', '', '', '', '',
'pkgpart', 'int', '', '', '', '',
],
- 'primary_key' => 'codepkgnum',
- 'unique' => [ [ 'codenum', 'pkgpart' ] ],
- 'index' => [ [ 'codenum' ] ],
+ 'primary_key' => 'codepkgnum',
+ 'unique' => [ [ 'codenum', 'pkgpart' ] ],
+ 'index' => [ [ 'codenum' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'codenum' ],
+ table => 'reg_code',
+ },
+ { columns => [ 'pkgpart' ],
+ table => 'part_pkg',
+ },
+ ],
},
'clientapi_session' => {
'fieldname', 'varchar', '', $char_d, '', '',
'fieldvalue', 'text', 'NULL', '', '', '',
],
- 'primary_key' => 'fieldnum',
- 'unique' => [ [ 'sessionnum', 'fieldname' ] ],
- 'index' => [],
+ 'primary_key' => 'fieldnum',
+ 'unique' => [ [ 'sessionnum', 'fieldname' ] ],
+ 'index' => [],
+ 'foreign_keys' => [
+ { columns => [ 'sessionnum' ],
+ table => 'clientapi_session',
+ },
+ ],
},
'payment_gateway' => {
'optionname', 'varchar', '', $char_d, '', '',
'optionvalue', 'text', 'NULL', '', '', '',
],
- 'primary_key' => 'optionnum',
- 'unique' => [],
- 'index' => [ [ 'gatewaynum' ], [ 'optionname' ] ],
+ 'primary_key' => 'optionnum',
+ 'unique' => [],
+ 'index' => [ [ 'gatewaynum' ], [ 'optionname' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'gatewaynum' ],
+ table => 'payment_gateway',
+ },
+ ],
},
'agent_payment_gateway' => {
'cardtype', 'varchar', 'NULL', $char_d, '', '',
'taxclass', 'varchar', 'NULL', $char_d, '', '',
],
- 'primary_key' => 'agentgatewaynum',
- 'unique' => [],
- 'index' => [ [ 'agentnum', 'cardtype' ], ],
+ 'primary_key' => 'agentgatewaynum',
+ 'unique' => [],
+ 'index' => [ [ 'agentnum', 'cardtype' ], ],
+
+ 'foreign_keys' => [
+
+ { columns => [ 'agentnum' ],
+ table => 'agent',
+ },
+ { columns => [ 'gatewaynum' ],
+ table => 'payment_gateway',
+ },
+ ],
},
'banned_pay' => {
'bantype', 'varchar', 'NULL', $char_d, '', '',
'reason', 'varchar', 'NULL', $char_d, '', '',
],
- 'primary_key' => 'bannum',
- 'unique' => [],
- 'index' => [ [ 'payby', 'payinfo' ], [ 'usernum' ], ],
+ 'primary_key' => 'bannum',
+ 'unique' => [],
+ 'index' => [ [ 'payby', 'payinfo' ], [ 'usernum' ], ],
+ 'foreign_keys' => [
+ { columns => [ 'usernum' ],
+ table => 'access_user',
+ },
+ ],
},
'pkg_category' => {
'columns' => [
- 'categorynum', 'serial', '', '', '', '',
- 'categoryname', 'varchar', '', $char_d, '', '',
- 'weight', 'int', 'NULL', '', '', '',
- 'condense', 'char', 'NULL', 1, '', '',
- 'disabled', 'char', 'NULL', 1, '', '',
+ 'categorynum', 'serial', '', '', '', '',
+ 'categoryname', 'varchar', '', $char_d, '', '',
+ 'weight', 'int', 'NULL', '', '', '',
+ 'ticketing_queueid', 'int', 'NULL', '', '', '',
+ 'condense', 'char', 'NULL', 1, '', '',
+ 'disabled', 'char', 'NULL', 1, '', '',
],
'primary_key' => 'categorynum',
'unique' => [],
'disabled', 'char', 'NULL', 1, '', '',
'fcc_ds0s', 'int', 'NULL', '', '', '',
],
- 'primary_key' => 'classnum',
- 'unique' => [],
- 'index' => [ ['disabled'] ],
+ 'primary_key' => 'classnum',
+ 'unique' => [],
+ 'index' => [ ['disabled'] ],
+ 'foreign_keys' => [
+ { columns => [ 'categorynum' ],
+ table => 'pkg_category',
+ },
+ ],
},
'cdr' => {
'lastapp', 'varchar', '', $char_d, \"''", '',
'lastdata', 'varchar', '', 255, \"''", '',
- #currently only opensips
+ #currently only opensips & voipswitch
'src_ip_addr', 'varchar', 'NULL', 15, '', '',
+
+ #currently only opensips
'dst_ip_addr', 'varchar', 'NULL', 15, '', '',
+ #currently only u4:
+ # terminating number (as opposed to dialed destination)
+ 'dst_term', 'varchar', 'NULL', $char_d, '', '',
+
#these don't seem to be logged by most of the SQL cdr_* modules
#except tds under sql-illegal names, so;
# ... don't rely on them for rating?
###
'servicecode', 'int', 'NULL', '', '', '',
'quantity_able', 'int', 'NULL', '', '', '',
-
+
###
#and now for our own fields
###
'charged_party_imsi', 'varchar', 'NULL', $char_d, '', '',
'upstream_price', 'decimal', 'NULL', '10,5', '', '',
+
+ #currently only voipswitch
+ #'upstream_rate', 'decimal', 'NULL', '10,5', '', '',
+
'upstream_src_regionname', 'varchar', 'NULL', $char_d, '', '',
'upstream_dst_regionname', 'varchar', 'NULL', $char_d, '', '',
#new
'cdrbatchnum', 'int', 'NULL', '', '', '',
+ # FK to cust_bill_pkg_detail; having a value here absolutely means
+ # that the CDR appears on an invoice
+ 'detailnum', 'bigint', 'NULL', '', '', '',
],
'primary_key' => 'acctid',
'unique' => [],
[ 'sessionnum' ], [ 'subscriber' ],
[ 'freesidestatus' ], [ 'freesiderewritestatus' ],
[ 'cdrbatch' ], [ 'cdrbatchnum' ],
- [ 'src_ip_addr' ], [ 'dst_ip_addr' ],
+ [ 'src_ip_addr' ], [ 'dst_ip_addr' ], [ 'dst_term' ],
],
+ #no FKs on cdr table... choosing not to throw errors no matter what's
+ # thrown in here. better to have the data.
},
'cdr_batch' => {
'status', 'varchar', 'NULL', 32, '', '',
'svcnum', 'int', 'NULL', '', '', '',
],
- 'primary_key' => 'cdrtermnum',
- 'unique' => [ [ 'acctid', 'termpart' ] ],
- 'index' => [ [ 'acctid' ], [ 'status' ], ],
+ 'primary_key' => 'cdrtermnum',
+ 'unique' => [ [ 'acctid', 'termpart' ] ],
+ 'index' => [ [ 'acctid' ], [ 'status' ], ],
+ 'foreign_keys' => [
+ { columns => [ 'acctid' ],
+ table => 'cdr',
+ },
+ { columns => [ 'svcnum' ],
+ table => 'cust_svc',
+ },
+ ],
},
#to handle multiple termination/settlement passes...
'cdr_carrier' => {
'columns' => [
- 'carrierid' => 'serial', '', '', '', '',
- 'carriername' => 'varchar', '', $char_d, '', '',
+ 'carrierid' => 'serial', '', '', '', '',
+ 'carriername' => 'varchar', '', $char_d, '', '',
+ 'disabled' => 'char', 'NULL', 1, '', '',
],
'primary_key' => 'carrierid',
'unique' => [],
'svcnum', 'int', 'NULL', '', '', '',
'svc_field', 'varchar', 'NULL', $char_d, '', '',
],
- 'primary_key' => 'itemnum',
- 'unique' => [ [ 'classnum', 'item' ] ],
- 'index' => [ [ 'classnum' ], [ 'agentnum' ], [ 'svcnum' ] ],
+ 'primary_key' => 'itemnum',
+ 'unique' => [ [ 'classnum', 'item' ] ],
+ 'index' => [ [ 'classnum' ], [ 'agentnum' ], [ 'svcnum' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'classnum' ],
+ table => 'inventory_class',
+ },
+ { columns => [ 'agentnum' ],
+ table => 'agent',
+ },
+ { columns => [ 'svcnum' ],
+ table => 'cust_svc',
+ },
+ ],
},
'inventory_class' => {
'index' => [],
},
- 'access_user' => {
+ 'access_user_session' => {
'columns' => [
- 'usernum', 'serial', '', '', '', '',
- 'username', 'varchar', '', $char_d, '', '',
- '_password', 'varchar', '', $char_d, '', '',
- 'last', 'varchar', '', $char_d, '', '',
- 'first', 'varchar', '', $char_d, '', '',
- 'user_custnum', 'int', 'NULL', '', '', '',
- 'disabled', 'char', 'NULL', 1, '', '',
+ 'sessionnum', 'serial', '', '', '', '',
+ 'sessionkey', 'varchar', '', $char_d, '', '',
+ 'usernum', 'int', '', '', '', '',
+ 'start_date', @date_type, '', '',
+ 'last_date', @date_type, '', '',
],
- 'primary_key' => 'usernum',
- 'unique' => [ [ 'username' ] ],
- 'index' => [ [ 'user_custnum' ] ],
+ 'primary_key' => 'sessionnum',
+ 'unique' => [ [ 'sessionkey' ] ],
+ 'index' => [],
+ 'foreign_keys' => [
+ { columns => [ 'usernum' ],
+ table => 'access_user',
+ },
+ ],
+ },
+
+ 'access_user' => {
+ 'columns' => [
+ 'usernum', 'serial', '', '', '', '',
+ 'username', 'varchar', '', $char_d, '', '',
+ '_password', 'varchar', 'NULL', $char_d, '', '',
+ '_password_encoding', 'varchar', 'NULL', $char_d, '', '',
+ 'last', 'varchar', 'NULL', $char_d, '', '',
+ 'first', 'varchar', 'NULL', $char_d, '', '',
+ 'user_custnum', 'int', 'NULL', '', '', '',
+ 'report_salesnum', 'int', 'NULL', '', '', '',
+ 'disabled', 'char', 'NULL', 1, '', '',
+ ],
+ 'primary_key' => 'usernum',
+ 'unique' => [ [ 'username' ] ],
+ 'index' => [ [ 'user_custnum' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'user_custnum' ],
+ table => 'cust_main',
+ references => [ 'custnum' ],
+ },
+ { columns => [ 'report_salesnum' ],
+ table => 'sales',
+ references => [ 'salesnum' ],
+ },
+ ],
},
'access_user_pref' => {
'prefvalue', 'text', 'NULL', '', '', '',
'expiration', @date_type, '', '',
],
- 'primary_key' => 'prefnum',
- 'unique' => [],
- 'index' => [ [ 'usernum' ] ],
+ 'primary_key' => 'prefnum',
+ 'unique' => [],
+ 'index' => [ [ 'usernum' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'usernum' ],
+ table => 'access_user',
+ },
+ ],
},
'access_group' => {
'usernum', 'int', '', '', '', '',
'groupnum', 'int', '', '', '', '',
],
- 'primary_key' => 'usergroupnum',
- 'unique' => [ [ 'usernum', 'groupnum' ] ],
- 'index' => [ [ 'usernum' ] ],
- },
+ 'primary_key' => 'usergroupnum',
+ 'unique' => [ [ 'usernum', 'groupnum' ] ],
+ 'index' => [ [ 'usernum' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'usernum' ],
+ table => 'access_user',
+ },
+ { columns => [ 'groupnum' ],
+ table => 'access_group',
+ },
+ ],
+ },
'access_groupagent' => {
'columns' => [
'groupnum', 'int', '', '', '', '',
'agentnum', 'int', '', '', '', '',
],
- 'primary_key' => 'groupagentnum',
- 'unique' => [ [ 'groupnum', 'agentnum' ] ],
- 'index' => [ [ 'groupnum' ] ],
- },
-
- 'access_groupsales' => {
- 'columns' => [
- 'groupsalesnum', 'serial', '', '', '', '',
- 'groupnum', 'int', '', '', '', '',
- 'salesnum', 'int', '', '', '', '',
- ],
- 'primary_key' => 'groupsalesnum',
- 'unique' => [ [ 'groupnum', 'salesnum' ] ],
- 'index' => [ [ 'groupnum' ] ],
+ 'primary_key' => 'groupagentnum',
+ 'unique' => [ [ 'groupnum', 'agentnum' ] ],
+ 'index' => [ [ 'groupnum' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'groupnum' ],
+ table => 'access_group',
+ },
+ { columns => [ 'agentnum' ],
+ table => 'agent',
+ },
+ ],
},
'access_right' => {
'index' => [],
},
- 'svc_phone' => {
+ 'sched_item' => {
'columns' => [
- 'svcnum', 'int', '', '', '', '',
- 'countrycode', 'varchar', '', 3, '', '',
- 'phonenum', 'varchar', '', 25, '', '', #12 ?
- 'sim_imsi', 'varchar', 'NULL', 15, '', '',
- 'pin', 'varchar', 'NULL', $char_d, '', '',
- 'sip_password', 'varchar', 'NULL', $char_d, '', '',
- 'phone_name', 'varchar', 'NULL', $char_d, '', '',
- 'pbxsvc', 'int', 'NULL', '', '', '',
- 'domsvc', 'int', 'NULL', '', '', '',
- 'locationnum', 'int', 'NULL', '', '', '',
- 'forwarddst', 'varchar', 'NULL', 15, '', '',
- 'email', 'varchar', 'NULL', 255, '', '',
- 'lnp_status', 'varchar', 'NULL', $char_d, '', '',
- 'portable', 'char', 'NULL', 1, '', '',
- 'lrn', 'char', 'NULL', 10, '', '',
- 'lnp_desired_due_date', 'int', 'NULL', '', '', '',
- 'lnp_due_date', 'int', 'NULL', '', '', '',
- 'lnp_other_provider', 'varchar', 'NULL', $char_d, '', '',
- 'lnp_other_provider_account', 'varchar', 'NULL', $char_d, '', '',
- 'lnp_reject_reason', 'varchar', 'NULL', $char_d, '', '',
+ 'itemnum', 'serial', '', '', '', '',
+ 'usernum', 'int', 'NULL', '', '', '',
+ #'itemname', 'varchar', $char_d, '', '', '',
+ 'disabled', 'char', 'NULL', 1, '', '',
],
- 'primary_key' => 'svcnum',
- 'unique' => [],
- 'index' => [ ['countrycode', 'phonenum'], ['pbxsvc'], ['domsvc'],
- ['locationnum'],
- ],
+ 'primary_key' => 'itemnum',
+ 'unique' => [ [ 'usernum' ] ],
+ 'index' => [],
+ 'foreign_keys' => [
+ { columns => [ 'usernum' ],
+ table => 'access_user',
+ },
+ ],
+ },
+
+ #'sched_item_class'
+
+ 'sched_avail' => {
+ 'columns' => [
+ 'availnum', 'serial', '', '', '', '',
+ 'itemnum', 'int', '', '', '', '',
+ 'wday', 'int', '', '', '', '',
+ 'stime', 'int', '', '', '', '',
+ 'etime', 'int', '', '', '', '',
+ 'override_date', @date_type, '', '',
+ ],
+ 'primary_key' => 'availnum',
+ 'unique' => [],
+ 'index' => [],
+ 'foreign_keys' => [
+ { columns => [ 'itemnum' ],
+ table => 'sched_item',
+ },
+ ],
+ },
+
+ 'svc_phone' => {
+ 'columns' => [
+ 'svcnum', 'int', '', '', '', '',
+ 'countrycode', 'varchar', '', 3, '', '',
+ 'phonenum', 'varchar', '', 25, '', '', #12 ?
+ 'sim_imsi', 'varchar', 'NULL', 15, '', '',
+ 'pin', 'varchar', 'NULL', $char_d, '', '',
+ 'sip_password', 'varchar', 'NULL', $char_d, '', '',
+ 'phone_name', 'varchar', 'NULL', $char_d, '', '',
+ 'pbxsvc', 'int', 'NULL', '', '', '',
+ 'domsvc', 'int', 'NULL', '', '', '',
+ 'locationnum', 'int', 'NULL', '', '', '',
+ 'forwarddst', 'varchar', 'NULL', 15, '', '',
+ 'email', 'varchar', 'NULL', 255, '', '',
+ 'lnp_status', 'varchar', 'NULL', $char_d, '', '',
+ 'portable', 'char', 'NULL', 1, '', '',
+ 'lrn', 'char', 'NULL', 10, '', '',
+ 'lnp_desired_due_date', 'int', 'NULL', '', '', '',
+ 'lnp_due_date', 'int', 'NULL', '', '', '',
+ 'lnp_other_provider', 'varchar', 'NULL', $char_d, '', '',
+ 'lnp_other_provider_account', 'varchar', 'NULL', $char_d, '', '',
+ 'lnp_reject_reason', 'varchar', 'NULL', $char_d, '', '',
+ 'sms_carrierid', 'int', 'NULL', '', '', '',
+ 'sms_account', 'varchar', 'NULL', $char_d, '', '',
+ 'max_simultaneous', 'int', 'NULL', '', '', '',
+ 'e911_class', 'char', 'NULL', 1, '', '',
+ 'e911_type', 'char', 'NULL', 1, '', '',
+ 'circuit_svcnum', 'int', 'NULL', '', '', '',
+ 'sip_server', 'varchar', 'NULL', $char_d, '', '',
+ ],
+ 'primary_key' => 'svcnum',
+ 'unique' => [ [ 'sms_carrierid', 'sms_account'] ],
+ 'index' => [ ['countrycode', 'phonenum'], ['pbxsvc'], ['domsvc'],
+ ['locationnum'], ['sms_carrierid'],
+ ],
+ 'foreign_keys' => [
+ { columns => [ 'svcnum' ],
+ table => 'cust_svc',
+ },
+ { columns => [ 'pbxsvc' ],
+ table => 'svc_pbx', #'cust_svc',
+ references => [ 'svcnum' ],
+ },
+ { columns => [ 'domsvc' ],
+ table => 'svc_domain', #'cust_svc',
+ references => [ 'svcnum' ],
+ },
+ { columns => [ 'locationnum' ],
+ table => 'cust_location',
+ },
+ { columns => [ 'sms_carrierid' ],
+ table => 'cdr_carrier',
+ references => [ 'carrierid' ],
+ },
+ { columns => [ 'circuit_svcnum' ],
+ table => 'svc_circuit',
+ references => [ 'svcnum' ],
+ },
+ ],
},
'phone_device' => {
'svcnum', 'int', '', '', '', '',
'mac_addr', 'varchar', 'NULL', 12, '', '',
],
- 'primary_key' => 'devicenum',
- 'unique' => [ [ 'mac_addr' ], ],
- 'index' => [ [ 'devicepart' ], [ 'svcnum' ], ],
+ 'primary_key' => 'devicenum',
+ 'unique' => [ [ 'mac_addr' ], ],
+ 'index' => [ [ 'devicepart' ], [ 'svcnum' ], ],
+ 'foreign_keys' => [
+ { columns => [ 'devicepart' ],
+ table => 'part_device',
+ },
+ { columns => [ 'svcnum' ],
+ table => 'svc_phone',
+ },
+ ],
},
'part_device' => {
'devicename', 'varchar', '', $char_d, '', '',
'inventory_classnum', 'int', 'NULL', '', '', '',
],
- 'primary_key' => 'devicepart',
- 'unique' => [ [ 'devicename' ] ], #?
- 'index' => [],
+ 'primary_key' => 'devicepart',
+ 'unique' => [ [ 'devicename' ] ], #?
+ 'index' => [],
+ 'foreign_keys' => [
+ { columns => [ 'inventory_classnum' ],
+ table => 'inventory_class',
+ references => [ 'classnum' ],
+ },
+ ],
},
'phone_avail' => {
'svcnum', 'int', 'NULL', '', '', '',
'availbatch', 'varchar', 'NULL', $char_d, '', '',
],
- 'primary_key' => 'availnum',
- 'unique' => [],
- 'index' => [ [ 'exportnum', 'countrycode', 'state' ], #npa search
- [ 'exportnum', 'countrycode', 'npa' ], #nxx search
- [ 'exportnum', 'countrycode', 'npa', 'nxx' ],#station search
- [ 'exportnum', 'countrycode', 'npa', 'nxx', 'station' ], # #
- [ 'svcnum' ],
- [ 'availbatch' ],
- [ 'latanum' ],
- ],
+ 'primary_key' => 'availnum',
+ 'unique' => [],
+ 'index' => [ ['exportnum','countrycode','state'], #npa search
+ ['exportnum','countrycode','npa'], #nxx search
+ ['exportnum','countrycode','npa','nxx'],#station srch
+ [ 'exportnum','countrycode','npa','nxx','station'], #
+ [ 'svcnum' ],
+ [ 'availbatch' ],
+ [ 'latanum' ],
+ ],
+ 'foreign_keys' => [
+ { columns => [ 'exportnum' ],
+ table => 'part_export',
+ },
+ { columns => [ 'latanum' ],
+ table => 'lata',
+ },
+ { columns => [ 'msanum' ],
+ table => 'msa',
+ },
+ { columns => [ 'ordernum' ],
+ table => 'did_order',
+ },
+ { columns => [ 'svcnum' ],
+ table => 'svc_phone',
+ },
+ ],
},
-
+
'lata' => {
'columns' => [
'latanum', 'int', '', '', '', '',
'unique' => [],
'index' => [],
},
-
+
'msa' => {
'columns' => [
'msanum', 'int', '', '', '', '',
'unique' => [],
'index' => [],
},
-
+
'rate_center' => {
'columns' => [
'ratecenternum', 'serial', '', '', '', '',
'unique' => [],
'index' => [],
},
-
+
'did_order_item' => {
'columns' => [
'orderitemnum', 'serial', '', '', '', '',
'quantity', 'int', '', '', '', '',
'custnum', 'int', 'NULL', '', '', '',
],
- 'primary_key' => 'orderitemnum',
- 'unique' => [],
- 'index' => [],
+ 'primary_key' => 'orderitemnum',
+ 'unique' => [],
+ 'index' => [],
+ 'foreign_keys' => [
+ { columns => [ 'ordernum' ],
+ table => 'did_order',
+ },
+ { columns => [ 'msanum' ],
+ table => 'msa',
+ },
+ { columns => [ 'latanum' ],
+ table => 'lata',
+ },
+ { columns => [ 'ratecenternum' ],
+ table => 'rate_center',
+ },
+ { columns => [ 'custnum' ],
+ table => 'cust_main',
+ },
+ ],
},
'did_order' => {
'confirmed', 'int', 'NULL', '', '', '',
'received', 'int', 'NULL', '', '', '',
],
- 'primary_key' => 'ordernum',
- 'unique' => [ [ 'vendornum', 'vendor_order_id' ] ],
- 'index' => [],
+ 'primary_key' => 'ordernum',
+ 'unique' => [ [ 'vendornum', 'vendor_order_id' ] ],
+ 'index' => [],
+ 'foreign_keys' => [
+ { columns => [ 'vendornum' ],
+ table => 'did_vendor',
+ },
+ { columns => [ 'custnum' ],
+ table => 'cust_main',
+ },
+ ],
},
'reason_type' => {
'disabled', 'char', 'NULL', 1, '', '',
'unsuspend_pkgpart', 'int', 'NULL', '', '', '',
'unsuspend_hold','char', 'NULL', 1, '', '',
- ],
- 'primary_key' => 'reasonnum',
- 'unique' => [],
- 'index' => [],
+ 'unused_credit', 'char', 'NULL', 1, '', '',
+ ],
+ 'primary_key' => 'reasonnum',
+ 'unique' => [],
+ 'index' => [],
+ 'foreign_keys' => [
+ { columns => [ 'reason_type' ],
+ table => 'reason_type',
+ references => [ 'typenum' ],
+ },
+ { columns => [ 'unsuspend_pkgpart' ],
+ table => 'part_pkg',
+ references => [ 'pkgpart' ],
+ },
+ ],
},
'conf' => {
'name', 'varchar', '', $char_d, '', '',
'value', 'text', 'NULL', '', '', '',
],
- 'primary_key' => 'confnum',
- 'unique' => [ [ 'agentnum', 'locale', 'name' ] ],
- 'index' => [],
+ 'primary_key' => 'confnum',
+ 'unique' => [ [ 'agentnum', 'locale', 'name' ] ],
+ 'index' => [],
+ 'foreign_keys' => [
+ { columns => [ 'agentnum' ],
+ table => 'agent',
+ },
+ ],
},
'pkg_referral' => {
'pkgnum', 'int', '', '', '', '',
'refnum', 'int', '', '', '', '',
],
- 'primary_key' => 'pkgrefnum',
- 'unique' => [ [ 'pkgnum', 'refnum' ] ],
- 'index' => [ [ 'pkgnum' ], [ 'refnum' ] ],
+ 'primary_key' => 'pkgrefnum',
+ 'unique' => [ [ 'pkgnum', 'refnum' ] ],
+ 'index' => [ [ 'pkgnum' ], [ 'refnum' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'pkgnum' ],
+ table => 'cust_pkg',
+ },
+ { columns => [ 'refnum' ],
+ table => 'part_referral',
+ },
+ ],
},
'svc_pbx' => {
'columns' => [
'svcnum', 'int', '', '', '', '',
'id', 'int', 'NULL', '', '', '',
+ 'uuid', 'char', 'NULL', 36, '', '',
'title', 'varchar', 'NULL', $char_d, '', '',
'max_extensions', 'int', 'NULL', '', '', '',
'max_simultaneous', 'int', 'NULL', '', '', '',
+ 'ip_addr', 'varchar', 'NULL', 40, '', '',
+ ],
+ 'primary_key' => 'svcnum',
+ 'unique' => [],
+ 'index' => [ [ 'id' ], [ 'uuid' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'svcnum' ],
+ table => 'cust_svc',
+ },
+ ],
+ },
+
+ 'pbx_extension' => {
+ 'columns' => [
+ 'extensionnum', 'serial', '', '', '', '',
+ 'svcnum', 'int', '', '', '', '',
+ 'extension', 'varchar', '', $char_d, '', '',
+ 'pin', 'varchar', 'NULL', $char_d, '', '',
+ 'sip_password', 'varchar', 'NULL', $char_d, '', '',
+ 'phone_name', 'varchar', 'NULL', $char_d, '', '',
],
- 'primary_key' => 'svcnum',
- 'unique' => [],
- 'index' => [ [ 'id' ] ],
+ 'primary_key' => 'extensionnum',
+ 'unique' => [ [ 'svcnum', 'extension' ] ],
+ 'index' => [ [ 'svcnum' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'svcnum' ],
+ table => 'svc_pbx',
+ },
+ ],
+ },
+
+ 'pbx_device' => {
+ 'columns' => [
+ 'devicenum', 'serial', '', '', '', '',
+ 'devicepart', 'int', '', '', '', '',
+ 'svcnum', 'int', '', '', '', '',
+ 'mac_addr', 'varchar', 'NULL', 12, '', '',
+ ],
+ 'primary_key' => 'devicenum',
+ 'unique' => [ [ 'mac_addr' ], ],
+ 'index' => [ [ 'devicepart' ], [ 'svcnum' ], ],
+ 'foreign_keys' => [
+ { columns => [ 'devicepart' ],
+ table => 'part_device',
+ },
+ { columns => [ 'svcnum' ],
+ table => 'svc_pbx',
+ },
+ ],
+ },
+
+ 'extension_device' => {
+ 'columns' => [
+ 'extensiondevicenum', 'serial', '', '', '', '',
+ 'extensionnum', 'int', '', '', '', '',
+ 'devicenum', 'int', '', '', '', '',
+ ],
+ 'primary_key' => 'extensiondevicenum',
+ 'unique' => [ [ 'extensionnum', 'devicenum' ] ],
+ 'index' => [],#both? which way do we need to query?
+ 'foreign_keys' => [
+ { columns => [ 'extensionnum' ],
+ table => 'pbx_extension',
+ },
+ { columns => [ 'devicenum' ],
+ table => 'pbx_device',
+ },
+ ],
},
'svc_mailinglist' => { #svc_group?
'reject_auto', 'char', 'NULL', 1, '', '',#RejectAuto
'remove_to_and_cc', 'char', 'NULL', 1, '', '',#RemoveToAndCc
],
- 'primary_key' => 'svcnum',
- 'unique' => [],
- 'index' => [ ['username'], ['domsvc'], ['listnum'] ],
+ 'primary_key' => 'svcnum',
+ 'unique' => [],
+ 'index' => [ ['username'], ['domsvc'], ['listnum'] ],
+ 'foreign_keys' => [
+ { columns => [ 'svcnum' ],
+ table => 'cust_svc',
+ },
+ { columns => [ 'domsvc' ],
+ table => 'svc_domain', #'cust_svc',
+ references => [ 'svcnum' ],
+ },
+ { columns => [ 'listnum' ],
+ table => 'mailinglist',
+ },
+ ],
},
'mailinglist' => {
'contactemailnum', 'int', 'NULL', '', '', '',
'email', 'varchar', 'NULL', 255, '', '',
],
- 'primary_key' => 'membernum',
- 'unique' => [],
- 'index' => [['listnum'],['svcnum'],['contactemailnum'],['email']],
+ 'primary_key' => 'membernum',
+ 'unique' => [],
+ 'index' => [['listnum'],['svcnum'],['contactemailnum'],['email']],
+ 'foreign_keys' => [
+ { columns => [ 'listnum' ],
+ table => 'mailinglist',
+ },
+ { columns => [ 'svcnum' ],
+ table => 'svc_acct',
+ },
+ { columns => [ 'contactemailnum' ],
+ table => 'contact_email',
+ },
+ ],
},
'bill_batch' => {
'status', 'char', 'NULL', '1', '', '',
'pdf', 'blob', 'NULL', '', '', '',
],
- 'primary_key' => 'batchnum',
- 'unique' => [],
- 'index' => [ ['agentnum'] ],
+ 'primary_key' => 'batchnum',
+ 'unique' => [],
+ 'index' => [ ['agentnum'] ],
+ 'foreign_keys' => [
+ { columns => [ 'agentnum' ],
+ table => 'agent',
+ },
+ ],
},
'cust_bill_batch' => {
'batchnum', 'int', '', '', '', '',
'invnum', 'int', '', '', '', '',
],
- 'primary_key' => 'billbatchnum',
- 'unique' => [],
- 'index' => [ [ 'batchnum' ], [ 'invnum' ] ],
+ 'primary_key' => 'billbatchnum',
+ 'unique' => [],
+ 'index' => [ [ 'batchnum' ], [ 'invnum' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'batchnum' ],
+ table => 'bill_batch',
+ },
+ { columns => [ 'invnum' ],
+ table => 'cust_bill',
+ },
+ ],
},
'cust_bill_batch_option' => {
'optionname', 'varchar', '', $char_d, '', '',
'optionvalue', 'text', 'NULL', '', '', '',
],
- 'primary_key' => 'optionnum',
- 'unique' => [],
- 'index' => [ [ 'billbatchnum' ], [ 'optionname' ] ],
- },
+ 'primary_key' => 'optionnum',
+ 'unique' => [],
+ 'index' => [ [ 'billbatchnum' ], [ 'optionname' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'billbatchnum' ],
+ table => 'cust_bill_batch',
+ },
+ ],
+ },
'msg_template' => {
'columns' => [
'from_addr', 'varchar', 'NULL', 255, '', '',
'bcc_addr', 'varchar', 'NULL', 255, '', '',
],
- 'primary_key' => 'msgnum',
- 'unique' => [ ],
- 'index' => [ ['agentnum'], ],
+ 'primary_key' => 'msgnum',
+ 'unique' => [ ],
+ 'index' => [ ['agentnum'], ],
+ 'foreign_keys' => [
+ { columns => [ 'agentnum' ],
+ table => 'agent',
+ },
+ ],
},
'template_content' => {
'subject', 'varchar', 'NULL', 512, '', '',
'body', 'text', 'NULL', '', '', '',
],
- 'primary_key' => 'contentnum',
- 'unique' => [ ['msgnum', 'locale'] ],
- 'index' => [ ],
+ 'primary_key' => 'contentnum',
+ 'unique' => [ ['msgnum', 'locale'] ],
+ 'index' => [ ],
+ 'foreign_keys' => [
+ { columns => [ 'msgnum' ],
+ table => 'msg_template',
+ },
+ ],
},
'cust_msg' => {
'columns' => [
'custmsgnum', 'serial', '', '', '', '',
- 'custnum', 'int', '', '', '', '',
+ 'custnum', 'int', 'NULL', '', '', '',
'msgnum', 'int', 'NULL', '', '', '',
'_date', @date_type, '', '',
'env_from', 'varchar', 'NULL', 255, '', '',
'body', 'blob', 'NULL', '', '', '',
'error', 'varchar', 'NULL', 255, '', '',
'status', 'varchar', '',$char_d, '', '',
- ],
- 'primary_key' => 'custmsgnum',
- 'unique' => [ ],
- 'index' => [ ['custnum'], ],
+ 'msgtype', 'varchar', 'NULL', 16, '', '',
+ ],
+ 'primary_key' => 'custmsgnum',
+ 'unique' => [ ],
+ 'index' => [ ['custnum'], ],
+ 'foreign_keys' => [
+ { columns => [ 'custnum' ],
+ table => 'cust_main',
+ },
+ { columns => [ 'msgnum' ],
+ table => 'msg_template',
+ },
+ ],
},
'svc_cert' => {
'country', 'char', 'NULL', 2, '', '',
'cert_contact', 'varchar', 'NULL', $char_d, '', '',
],
- 'primary_key' => 'svcnum',
- 'unique' => [],
- 'index' => [], #recnum
+ 'primary_key' => 'svcnum',
+ 'unique' => [],
+ 'index' => [], #recnum
+ 'foreign_keys' => [
+ { columns => [ 'svcnum' ],
+ table => 'cust_svc',
+ },
+ { columns => [ 'recnum' ],
+ table => 'domain_record',
+ },
+ ],
},
'svc_port' => {
'svcnum', 'int', '', '', '', '',
'serviceid', 'varchar', '', 64, '', '', #srvexport / reportfields
],
- 'primary_key' => 'svcnum',
- 'unique' => [],
- 'index' => [], #recnum
+ 'primary_key' => 'svcnum',
+ 'unique' => [],
+ 'index' => [], #recnum
+ 'foreign_keys' => [
+ { columns => [ 'svcnum' ],
+ table => 'cust_svc',
+ },
+ ],
},
'areacode' => {
'statustext', 'varchar', 'NULL', $char_d, '', '',
],
'primary_key' => 'upgradenum',
- 'unique' => [ [ 'upgradenum' ] ],
+ 'unique' => [],
'index' => [ [ 'upgrade' ] ],
},
'subject', 'varchar', 'NULL', '255', '', '',
'handling', 'varchar', 'NULL', $char_d, '', '',
],
- 'primary_key' => 'targetnum',
- 'unique' => [ [ 'targetnum' ] ],
- 'index' => [],
+ 'primary_key' => 'targetnum',
+ 'unique' => [ [ 'targetnum' ] ],
+ 'index' => [],
+ 'foreign_keys' => [
+ { columns => [ 'agentnum' ],
+ table => 'agent',
+ },
+ ],
},
'log' => {
'level', 'int', '', '', '', '',
'message', 'text', '', '', '', '',
],
- 'primary_key' => 'lognum',
- 'unique' => [],
- 'index' => [ ['_date'], ['level'] ],
+ 'primary_key' => 'lognum',
+ 'unique' => [],
+ 'index' => [ ['_date'], ['level'] ],
+ 'foreign_keys' => [
+ { columns => [ 'agentnum' ],
+ table => 'agent',
+ },
+ ],
},
'log_context' => {
'columns' => [
'logcontextnum', 'serial', '', '', '', '',
'lognum', 'int', '', '', '', '',
- 'context', 'varchar', '', 32, '', '',
+ 'context', 'varchar', '', $char_d, '', '',
+ ],
+ 'primary_key' => 'logcontextnum',
+ 'unique' => [ [ 'lognum', 'context' ] ],
+ 'index' => [],
+ 'foreign_keys' => [
+ { columns => [ 'lognum' ],
+ table => 'log',
+ },
+ ],
+ },
+
+ 'svc_alarm' => {
+ 'columns' => [
+# name type null length default local
+ 'svcnum', 'int', '', '', '', '',
+ 'alarmsystemnum', 'int', '', '', '', '',
+ 'alarmtypenum', 'int', '', '', '', '',
+ 'alarmstationnum', 'int', '', '', '', '',
+ 'acctnum', 'varchar', '', $char_d, '', '',
+ '_password', 'varchar', '', $char_d, '', '',
+ 'location', 'varchar', 'NULL', $char_d, '', '',
+ 'cs_receiver', 'int', 'NULL', '', '', '',
+ 'cs_phonenum', 'varchar', 'NULL', $char_d, '', '',
+ 'serialnum', 'varchar', 'NULL', $char_d, '', '',
+ #installer (rep)
+ ],
+ 'primary_key' => 'svcnum',
+ 'unique' => [],
+ 'index' => [],
+ 'foreign_keys' => [
+ { columns => [ 'svcnum' ],
+ table => 'cust_svc',
+ },
+ { columns => [ 'alarmsystemnum' ],
+ table => 'alarm_system',
+ },
+ { columns => [ 'alarmtypenum' ],
+ table => 'alarm_type',
+ },
+ { columns => [ 'alarmstationnum' ],
+ table => 'alarm_station',
+ },
+ ],
+ },
+
+ 'alarm_system' => { #vendors
+ 'columns' => [
+ 'alarmsystemnum', 'serial', '', '', '', '',
+ 'agentnum', 'int', 'NULL', '', '', '',
+ 'systemname', 'varchar', '', $char_d, '', '',
+ 'disabled', 'char', 'NULL', 1, '', '',
+ ],
+ 'primary_key' => 'alarmsystemnum',
+ 'unique' => [ ['agentnum', 'systemname'] ],
+ 'index' => [ ['agentnum'], ['disabled'] ],
+ 'foreign_keys' => [
+ { columns => [ 'agentnum' ],
+ table => 'agent',
+ },
+ ],
+ },
+
+ 'alarm_type' => { #inputs and outputs
+ 'columns' => [
+ 'alarmtypenum', 'serial', '', '', '', '',
+ 'agentnum', 'int', 'NULL', '', '', '',
+ 'inputs', 'int', '', '', '', '',
+ 'outputs', 'int', '', '', '', '',
+ 'disabled', 'char', 'NULL', 1, '', '',
+ ],
+ 'primary_key' => 'alarmtypenum',
+ 'unique' => [ ['agentnum', 'inputs', 'outputs'] ],
+ 'index' => [ ['agentnum'], ['disabled'] ],
+ 'foreign_keys' => [
+ { columns => [ 'agentnum' ],
+ table => 'agent',
+ },
+ ],
+ },
+
+ 'alarm_station' => { #central station (where the alarm reports to)
+ 'columns' => [
+ 'alarmstationnum', 'serial', '', '', '', '',
+ 'agentnum', 'int', 'NULL', '', '', '',
+ 'stationname', 'varchar', '', $char_d, '', '',
+ 'disabled', 'char', 'NULL', 1, '', '',
+ ],
+ 'primary_key' => 'alarmstationnum',
+ 'unique' => [ ['agentnum', 'stationname'], ],
+ 'index' => [ ['agentnum'], ['disabled'] ],
+ 'foreign_keys' => [
+ { columns => [ 'agentnum' ],
+ table => 'agent',
+ },
+ ],
+ },
+
+ 'svc_cable' => {
+ 'columns' => [
+ 'svcnum', 'int', '', '', '', '',
+ 'providernum', 'int', 'NULL', '', '', '',
+ 'ordernum', 'varchar', 'NULL', $char_d, '', '',
+ 'modelnum', 'int', 'NULL', '', '', '',
+ 'serialnum', 'varchar', 'NULL', $char_d, '', '',
+ 'mac_addr', 'varchar', 'NULL', 12, '', '',
+ ],
+ 'primary_key' => 'svcnum',
+ 'unique' => [ ['serialnum'] , ['mac_addr'] ],
+ 'index' => [],
+ 'foreign_keys' => [
+ { columns => [ 'svcnum' ],
+ table => 'cust_svc',
+ },
+ { columns => [ 'providernum' ],
+ table => 'cable_provider',
+ },
+ { columns => [ 'modelnum' ],
+ table => 'cable_model',
+ },
+ ],
+ },
+
+ 'cable_model' => {
+ 'columns' => [
+ 'modelnum', 'serial', '', '', '', '',
+ 'model_name', 'varchar', '', $char_d, '', '',
+ 'disabled', 'char', 'NULL', 1, '', '',
+ ],
+ 'primary_key' => 'modelnum',
+ 'unique' => [ [ 'model_name' ], ],
+ 'index' => [],
+ },
+
+ 'cable_provider' => {
+ 'columns' => [
+ 'providernum', 'serial', '', '', '', '',
+ 'provider', 'varchar', '', $char_d, '', '',
+ 'disabled', 'char', 'NULL', 1, '', '',
+ ],
+ 'primary_key' => 'providernum',
+ 'unique' => [ [ 'provider' ], ],
+ 'index' => [],
+ },
+
+ 'svc_conferencing' => {
+ 'columns' => [
+ 'svcnum', 'int', '', '', '', '',
+ 'conf_id', 'int', 'NULL', '', '', '', #"system assigned"
+ 'conf_name', 'varchar', '', $char_d, '', '',
+ 'conf_password', 'varchar', '', $char_d, '', '',
+ 'access_code', 'varchar', '', 16, '', '',
+ 'duration', 'int', '', '', '', '',
+ 'participants', 'int', '', '', '', '',
+ 'conftypenum', 'int', '', '', '', '',
+ 'confqualitynum', 'int', '', '', '', '',
+ 'opt_recording', 'char', 'NULL', 1, '', '',
+ 'opt_sip', 'char', 'NULL', 1, '', '',
+ 'opt_phone', 'char', 'NULL', 1, '', '',
+ ],
+ 'primary_key' => 'svcnum',
+ 'unique' => [],
+ 'index' => [],
+ 'foreign_keys' => [
+ { columns => [ 'svcnum' ],
+ table => 'cust_svc',
+ },
+ { columns => [ 'conftypenum' ],
+ table => 'conferencing_type',
+ },
+ { columns => [ 'confqualitynum' ],
+ table => 'conferencing_quality',
+ },
+ ],
+ },
+
+ 'conferencing_type' => {
+ 'columns' => [
+ 'conftypenum', 'int', '', '', '', '',
+ 'typeid' , 'int', '', '', '', '',
+ 'typename', 'varchar', '', $char_d, '', '',
+ 'disabled', 'char', 'NULL', 1, '', '',
+ ],
+ 'primary_key' => 'conftypenum',
+ 'unique' => [ [ 'typeid', 'disabled' ], [ 'typename', 'disabled' ] ],
+ 'index' => [],
+ },
+
+ 'conferencing_quality' => {
+ 'columns' => [
+ 'confqualitynum', 'int', '', '', '', '',
+ 'qualityid' , 'int', '', '', '', '',
+ 'qualityname', 'varchar', '', $char_d, '', '',
+ 'disabled', 'char', 'NULL', 1, '', '',
+ ],
+ 'primary_key' => 'confqualitynum',
+ 'unique' => [ [ 'qualityid', 'disabled' ], [ 'qualityname', 'disabled' ] ],
+ 'index' => [],
+ },
+
+ 'svc_video' => {
+ 'columns' => [
+ 'svcnum', 'int', '', '', '', '',
+ 'smartcard_num', 'varchar', '', 16, '', '',
+ 'mac_addr', 'varchar', '', 12, '', '',
+ 'duration', 'int', '', '', '', '',
+ ],
+ 'primary_key' => 'svcnum',
+ 'unique' => [], # [ 'smartcard_num' ], [ 'mac_addr' ], ],
+ 'index' => [],
+ 'foreign_keys' => [
+ { columns => [ 'svcnum' ],
+ table => 'cust_svc',
+ },
+ ],
+ },
+
+ 'circuit_type' => {
+ 'columns' => [
+ 'typenum', 'serial', '', '', '', '',
+ 'typename', 'varchar', '', $char_d, '', '',
+ 'disabled', 'char', 'NULL', 1, '', '',
+ # speed? number of voice lines? anything else?
+ ],
+ 'primary_key' => 'typenum',
+ 'unique' => [ [ 'typename' ] ],
+ 'index' => [],
+ },
+
+ 'circuit_provider' => {
+ 'columns' => [
+ 'providernum', 'serial', '', '', '', '',
+ 'provider', 'varchar', '', $char_d, '', '',
+ 'disabled', 'char', 'NULL', 1, '', '',
+ ],
+ 'primary_key' => 'providernum',
+ 'unique' => [ [ 'provider' ], ],
+ 'index' => [],
+ },
+
+ 'circuit_termination' => {
+ 'columns' => [
+ 'termnum', 'serial', '', '', '', '',
+ 'termination','varchar', '', $char_d, '', '',
+ 'disabled', 'char', 'NULL', 1, '', '',
],
- 'primary_key' => 'logcontextnum',
- 'unique' => [ [ 'lognum', 'context' ] ],
+ 'primary_key' => 'termnum',
+ 'unique' => [ [ 'termination' ] ],
'index' => [],
},
+ 'svc_circuit' => {
+ 'columns' => [
+ 'svcnum', 'int', '', '', '', '',
+ 'typenum', 'int', '', '', '', '',
+ 'providernum', 'int', '', '', '', '',
+ 'termnum', 'int', '', '', '', '',
+ 'circuit_id', 'varchar', '', 64, '', '',
+ 'desired_due_date', 'int', 'NULL', '', '', '',
+ 'due_date', 'int', 'NULL', '', '', '',
+ 'vendor_order_id', 'varchar', 'NULL', $char_d, '', '',
+ 'vendor_qual_id', 'varchar', 'NULL', $char_d, '', '',
+ 'vendor_order_type', 'varchar', 'NULL', $char_d, '', '',
+ 'vendor_order_status', 'varchar', 'NULL', $char_d, '', '',
+ 'endpoint_ip_addr', 'varchar', 'NULL', 40, '', '',
+ 'endpoint_mac_addr', 'varchar', 'NULL', 12, '', '',
+ ],
+ 'primary_key' => 'svcnum',
+ 'unique' => [],
+ 'index' => [ [ 'providernum' ], [ 'typenum' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'svcnum' ],
+ table => 'cust_svc',
+ },
+ { columns => [ 'typenum' ],
+ table => 'circuit_type',
+ },
+ { columns => [ 'providernum' ],
+ table => 'circuit_provider',
+ },
+ { columns => [ 'termnum' ],
+ table => 'circuit_termination',
+ },
+ ],
+ },
+
+ 'vend_main' => {
+ 'columns' => [
+ 'vendnum', 'serial', '', '', '', '',
+ 'vendname', 'varchar', '', $char_d, '', '',
+ 'classnum', 'int', '', '', '', '',
+ 'disabled', 'char', 'NULL', 1, '', '',
+ ],
+ 'primary_key' => 'vendnum',
+ 'unique' => [ ['vendname', 'disabled'] ],
+ 'index' => [],
+ 'foreign_keys' => [
+ { columns => [ 'classnum' ],
+ table => 'vend_class',
+ },
+ ],
+ },
+
+ 'vend_class' => {
+ 'columns' => [
+ 'classnum', 'serial', '', '', '', '',
+ 'classname', 'varchar', '', $char_d, '', '',
+ 'disabled', 'char', 'NULL', 1, '', '',
+ ],
+ 'primary_key' => 'classnum',
+ 'unique' => [],
+ 'index' => [ ['disabled'] ],
+ },
+
+ 'vend_bill' => {
+ 'columns' => [
+ 'vendbillnum', 'serial', '', '', '', '',
+ 'vendnum', 'int', '', '', '', '',
+ #'_date', @date_type, '', '',
+ '_date', 'int', '', '', '', '',
+ 'charged', @money_type, '', '',
+ ],
+ 'primary_key' => 'vendbillnum',
+ 'unique' => [],
+ 'index' => [ ['vendnum'], ['_date'], ],
+ 'foreign_keys' => [
+ { columns => [ 'vendnum' ],
+ table => 'vend_main',
+ },
+ ],
+ },
+
+ 'vend_pay' => {
+ 'columns' => [
+ 'vendpaynum', 'serial', '', '', '', '',
+ 'vendnum', 'int', '', '', '', '',
+ #'_date', @date_type, '', '',
+ '_date', 'int', '', '', '', '',
+ 'paid', @money_type, '', '',
+ ],
+ 'primary_key' => 'vendpaynum',
+ 'unique' => [],
+ 'index' => [ [ 'vendnum' ], [ '_date' ], ],
+ 'foreign_keys' => [
+ { columns => [ 'vendnum' ],
+ table => 'vend_main',
+ },
+ ],
+ },
+
+ 'vend_bill_pay' => {
+ 'columns' => [
+ 'vendbillpaynum', 'serial', '', '', '', '',
+ 'vendbillnum', 'int', '', '', '', '',
+ 'vendpaynum', 'int', '', '', '', '',
+ 'amount', @money_type, '', '',
+ #? '_date', @date_type, '', '',
+ ],
+ 'primary_key' => 'vendbillpaynum',
+ 'unique' => [],
+ 'index' => [ [ 'vendbillnum' ], [ 'vendpaynum' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'vendbillnum' ],
+ table => 'vend_bill',
+ },
+ { columns => [ 'vendpaynum' ],
+ table => 'vend_pay',
+ },
+ ],
+ },
+
%{ tables_hashref_torrus() },
# tables of ours for doing torrus virtual port combining
'derivenum', 'int', '', '', '', '',
'serviceid', 'varchar', '', 64, '', '', #srvexport / reportfields
],
- 'primary_key' => 'componentnum',
- 'unique' => [ [ 'derivenum', 'serviceid' ], ],
- 'index' => [ [ 'derivenum', ], ],
+ 'primary_key' => 'componentnum',
+ 'unique' => [ [ 'derivenum', 'serviceid' ], ],
+ 'index' => [ [ 'derivenum', ], ],
+ 'foreign_keys' => [
+ { columns => [ 'derivenum' ],
+ table => 'torrus_srvderive',
+ },
+ ],
},
+ 'invoice_mode' => {
+ 'columns' => [
+ 'modenum', 'serial', '', '', '', '',
+ 'agentnum', 'int', 'NULL', '', '', '',
+ 'modename', 'varchar', '', 32, '', '',
+ ],
+ 'primary_key' => 'modenum',
+ 'unique' => [ ],
+ 'index' => [ ],
+ 'foreign_keys' => [
+ { columns => [ 'agentnum' ],
+ table => 'agent',
+ },
+ ],
+ },
+
+ 'invoice_conf' => {
+ 'columns' => [
+ 'confnum', 'serial', '', '', '', '',
+ 'modenum', 'int', '', '', '', '',
+ 'locale', 'varchar', 'NULL', 16, '', '',
+ 'notice_name', 'varchar', 'NULL', 64, '', '',
+ 'subject', 'varchar', 'NULL', 64, '', '',
+ 'htmlnotes', 'text', 'NULL', '', '', '',
+ 'htmlfooter', 'text', 'NULL', '', '', '',
+ 'htmlsummary', 'text', 'NULL', '', '', '',
+ 'htmlreturnaddress', 'text', 'NULL', '', '', '',
+ 'latexnotes', 'text', 'NULL', '', '', '',
+ 'latexfooter', 'text', 'NULL', '', '', '',
+ 'latexsummary', 'text', 'NULL', '', '', '',
+ 'latexsmallfooter', 'text', 'NULL', '', '', '',
+ 'latexreturnaddress', 'text', 'NULL', '', '', '',
+ 'with_latexcoupon', 'char', 'NULL', '1', '', '',
+ 'lpr', 'varchar', 'NULL', $char_d, '', '',
+ ],
+ 'primary_key' => 'confnum',
+ 'unique' => [ [ 'modenum', 'locale' ] ],
+ 'index' => [ ],
+ 'foreign_keys' => [
+ { columns => [ 'modenum' ],
+ table => 'invoice_mode',
+ },
+ ],
+ },
+
+ 'export_batch' => {
+ 'columns' => [
+ 'batchnum', 'serial', '', '', '', '',
+ 'exportnum', 'int', '', '', '', '',
+ '_date', 'int', '', '', '', '',
+ 'status', 'varchar', 'NULL', 32, '', '',
+ 'statustext', 'text', 'NULL', '', '', '',
+ ],
+ 'primary_key' => 'batchnum',
+ 'unique' => [],
+ 'index' => [ [ 'exportnum' ], [ 'status' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'exportnum' ],
+ table => 'part_export',
+ references => [ 'exportnum' ]
+ },
+ ],
+ },
+
+ 'export_batch_item' => {
+ 'columns' => [
+ 'itemnum', 'serial', '', '', '', '',
+ 'batchnum', 'int', '', '', '', '',
+ 'svcnum', 'int', '', '', '', '',
+ 'action', 'varchar', '', 32, '', '',
+ 'data', 'text', 'NULL', '', '', '',
+ 'frozen', 'char', 'NULL', 1, '', '',
+ ],
+ 'primary_key' => 'itemnum',
+ 'unique' => [],
+ 'index' => [ [ 'batchnum' ], [ 'svcnum' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'batchnum' ],
+ table => 'export_batch',
+ references => [ 'batchnum' ]
+ },
+ ],
+ },
+
+ # lookup table for states, similar to msa and lata
+ 'state' => {
+ 'columns' => [
+ 'statenum', 'int', '', '', '', '',
+ 'country', 'char', '', 2, '', '',
+ 'state', 'char', '', $char_d, '', '',
+ 'fips', 'char', '', 3, '', '',
+ ],
+ 'primary_key' => 'statenum',
+ 'unique' => [ [ 'country', 'state' ], ],
+ 'index' => [],
+ },
+
+ # eventually link to tower/sector?
+ 'deploy_zone' => {
+ 'columns' => [
+ 'zonenum', 'serial', '', '', '', '',
+ 'description', 'char', 'NULL', $char_d, '', '',
+ 'agentnum', 'int', '', '', '', '',
+ 'dbaname', 'char', 'NULL', $char_d, '', '',
+ 'zonetype', 'char', '', 1, '', '',
+ 'technology', 'int', '', '', '', '',
+ 'spectrum', 'int', 'NULL', '', '', '',
+ 'adv_speed_up', 'decimal', '', '10,3', '0', '',
+ 'adv_speed_down', 'decimal', '', '10,3', '0', '',
+ 'cir_speed_up', 'decimal', '', '10,3', '0', '',
+ 'cir_speed_down', 'decimal', '', '10,3', '0', '',
+ 'is_broadband', 'char', 'NULL', 1, '', '',
+ 'is_voice', 'char', 'NULL', 1, '', '',
+ 'is_consumer', 'char', 'NULL', 1, '', '',
+ 'is_business', 'char', 'NULL', 1, '', '',
+ 'active_date', @date_type, '', '',
+ 'expire_date', @date_type, '', '',
+ ],
+ 'primary_key' => 'zonenum',
+ 'unique' => [],
+ 'index' => [ [ 'agentnum' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'agentnum' ],
+ table => 'agent',
+ references => [ 'agentnum' ],
+ },
+ ],
+ },
+
+ 'deploy_zone_block' => {
+ 'columns' => [
+ 'blocknum', 'serial', '', '', '', '',
+ 'zonenum', 'int', '', '', '', '',
+ 'censusblock', 'char', '', 15, '', '',
+ 'censusyear', 'char', '', 4, '', '',
+ ],
+ 'primary_key' => 'blocknum',
+ 'unique' => [],
+ 'index' => [ [ 'zonenum' ] ],
+ 'foreign_keys' => [
+ { columns => [ 'zonenum' ],
+ table => 'deploy_zone',
+ references => [ 'zonenum' ],
+ },
+ ],
+ },
+
+ 'deploy_zone_vertex' => {
+ 'columns' => [
+ 'vertexnum', 'serial', '', '', '', '',
+ 'zonenum', 'int', '', '', '', '',
+ 'latitude', 'decimal', '', '10,7', '', '',
+ 'longitude', 'decimal', '', '10,7', '', '',
+ ],
+ 'primary_key' => 'vertexnum',
+ 'unique' => [ ],
+ 'index' => [ ],
+ 'foreign_keys' => [
+ { columns => [ 'zonenum' ],
+ table => 'deploy_zone',
+ references => [ 'zonenum' ],
+ },
+ ],
+ },
+
+
+
+
# name type nullability length default local