my %hash = map { $_ => shift @coldef }
qw( name type null length default local );
+ #can be removed once we depend on DBIx::DBSchema 0.39;
+ $hash{'type'} = 'LONGTEXT'
+ if $hash{'type'} =~ /^TEXT$/i && $datasrc =~ /^dbi:mysql/i;
+
unless ( defined $hash{'default'} ) {
warn "$tablename:\n".
join('', map "$_ => $hash{$_}\n", keys %hash) ;# $stop = <STDIN>;
#false laziness w/sub indices in DBIx::DBSchema::DBD (well, sorta)
#and sub sql_create_table in DBIx::DBSchema::Table (slighty more?)
my $unique = $tables_hashref->{$tablename}{'unique'};
- my $index = $tables_hashref->{$tablename}{'index'};
+ my @index = @{ $tables_hashref->{$tablename}{'index'} };
+
+ # kludge to avoid avoid "BLOB/TEXT column 'statustext' used in key
+ # specification without a key length".
+ # better solution: teach DBIx::DBSchema to specify a default length for
+ # MySQL indices on text columns, or just to support an index length at all
+ # so we can pass something in.
+ # best solution: eliminate need for this index in cust_main::retry_realtime
+ @index = grep { @{$_}[0] ne 'statustext' } @index
+ if $datasrc =~ /^dbi:mysql/i;
+
my @indices = ();
push @indices, map {
DBIx::DBSchema::Index->new({
'columns' => $_,
});
}
- @$index;
+ @index;
DBIx::DBSchema::Table->new({
'name' => $tablename,
# ));
#}
+ my $tables_hashref_torrus = tables_hashref_torrus();
+
#create history tables (false laziness w/create-history-tables)
foreach my $table (
- grep { ! /^clientapi_session/ }
- grep { ! /^h_/ }
- $dbdef->tables
+ grep { ! /^clientapi_session/
+ && ! /^h_/
+ && ! $tables_hashref_torrus->{$_}
+ }
+ $dbdef->tables
) {
my $tableobj = $dbdef->table($table)
or die "unknown table $table";
}
+#torrus tables http://torrus.org/reporting_setup.pod.html#create_sql_tables
+sub tables_hashref_torrus {
+
+ return {
+
+ # Collector export table. It usually grows at several megabytes
+ # per month, and is updated every 5 minutes
+ 'srvexport' => {
+ 'columns' => [
+ 'id', 'serial', '', '', '', '',
+ 'srv_date', 'date', '', '', '', '',#date and time of the data sample
+ 'srv_time', 'time', '', '', '', '',
+ 'serviceid', 'varchar', '', 64, '', '',#unique service ID per counter
+ 'value', 'double precision', '', '', '', '',#collected rate or gauge value
+ 'intvl', 'int', '', '', '', '', # collection interval - for counter volume calculation
+ ],
+ 'primary_key' => 'id',
+ 'unique' => [],
+ 'index' => [ ['srv_date'], ['serviceid'], ],
+ },
+
+ #Tables for (currently monthly only) report contents.
+ #These are updated usually once per month, and read at the moment of
+ #rendering the report output (HTML now, PDF or XML or Excel or whatever
+ #in the future)
+
+ #DBIx::Sequence backend, theplatform-independent inplementation
+ #of sequences
+ 'dbix_sequence_state' => {
+ 'columns' => [
+ 'id', 'serial', '', '', '', '',
+ 'dataset', 'varchar', '', 50, '', '',
+ 'state_id', 'int', '', '', '', '',
+ ],
+ 'primary_key' => 'id',
+ #CONSTRAINT pk_dbix_sequence PRIMARY KEY (dataset, state_id)
+ 'unique' => [ [ 'dataset', 'state_id' ], ],
+ 'index' => [],
+ },
+
+ 'dbix_sequence_release' => {
+ 'columns' => [
+ 'id', 'serial', '', '', '', '',
+ 'dataset', 'varchar', '', 50, '', '',
+ 'released_id', 'int', '', '', '', '',
+ ],
+ 'primary_key' => 'id',
+ #CONSTRAINT pk_dbi_release PRIMARY KEY (dataset, released_id)
+ 'unique' => [ [ 'dataset', 'released_id', ] ],
+ 'index' => [],
+ },
+
+ #Each report is characterized by name, date and time.
+ #Monthly reports are automatically assigned 00:00 of the 1st day
+ #in the month. The report contains fields for every service ID
+ #defined across all datasource trees.
+ 'reports' => {
+ 'columns' => [
+ 'id', 'serial', '', '', '', '',
+ 'rep_date', 'date', '', '', '', '',#Start date of the report
+ 'rep_time', 'time', '', '', '', '',#Start time of the report
+ 'reportname', 'varchar', '', 64, '', '',#Report name, such as
+ # MonthlyUsage
+ 'iscomplete', 'int', '', '', '', '',#0 when the report is in
+ # progress, 1 when it is ready
+ ],
+ 'primary_key' => 'id',
+ 'unique' => [ [ qw(rep_date rep_time reportname) ] ],
+ 'index' => [ [ 'rep_date' ] ],
+ },
+
+ #Each report contains fields. For each service ID,
+ #the report may contain several fields for various statistics.
+ #Each field contains information about the units of the value it
+ #contains
+ 'reportfields' => {
+ 'columns' => [
+ 'id', 'serial', '', '', '', '',
+ 'rep_id', 'int', 'NULL', '', '', '',
+ 'name', 'varchar', '', 64, '', '',#name of the field,
+ # such as AVG or MAX
+ 'serviceid', 'varchar', '', 64, '', '',#service ID
+ 'value', 'double precision', '', '', '', '',#Numeric value
+ 'units', 'varchar', '', 64, \"''", '',#Units, such as bytes
+ # or Mbps
+ ],
+ 'primary_key', => 'id',
+ 'unique' => [ [ qw(rep_id name serviceid) ] ],
+ 'index' => [],
+ },
+
+ };
+
+}
+
sub tables_hashref {
my $char_d = 80; #default maxlength for text fields
'invoice_template', 'varchar', 'NULL', $char_d, '', '',
'agent_custnum', 'int', 'NULL', '', '', '',
'disabled', 'char', 'NULL', 1, '', '',
- 'username', 'varchar', 'NULL', $char_d, '', '', #deprecated
- '_password', 'varchar', 'NULL', $char_d, '', '', #deprecated
+ 'username', 'varchar', 'NULL', $char_d, '', '',
+ '_password', 'varchar', 'NULL', $char_d, '', '',
'freq', 'int', 'NULL', '', '', '', #deprecated (never used)
'prog', @perl_type, '', '', #deprecated (never used)
],
'attachnum', 'serial', '', '', '', '',
'custnum', 'int', '', '', '', '',
'_date', @date_type, '', '',
- 'otaker', 'varchar', '', 32, '', '',
+ 'otaker', 'varchar', 'NULL', 32, '', '',
+ 'usernum', 'int', 'NULL', '', '', '',
'filename', 'varchar', '', 255, '', '',
'mime_type', 'varchar', '', $char_d, '', '',
'title', 'varchar', 'NULL', $char_d, '', '',
],
'primary_key' => 'attachnum',
'unique' => [],
- 'index' => [ ['custnum'] ],
+ 'index' => [ ['custnum'], ['usernum'], ],
},
'cust_bill' => {
'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, '', '',
'custnum', 'int', '', '', '', '',
'_date', @date_type, '', '',
'amount', @money_type, '', '',
- 'otaker', 'varchar', '', 32, '', '',
+ '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
],
'primary_key' => 'crednum',
'unique' => [],
- 'index' => [ ['custnum'], ['_date'] ],
+ 'index' => [ ['custnum'], ['_date'], ['usernum'], ['eventnum'] ],
},
'cust_credit_bill' => {
'geocode', 'varchar', 'NULL', 20, '', '',
'censustract', 'varchar', 'NULL', 20, '', '', # 7 to save space?
'tax', 'char', 'NULL', 1, '', '',
- 'otaker', 'varchar', '', 32, '', '',
+ 'otaker', 'varchar', 'NULL', 32, '', '',
+ 'usernum', 'int', 'NULL', '', '', '',
'refnum', 'int', '', '', '', '',
'referral_custnum', 'int', 'NULL', '', '', '',
'comments', 'text', 'NULL', '', '', '',
'squelch_cdr','char', 'NULL', 1, '', '',
'cdr_termination_percentage', 'decimal', 'NULL', '', '', '',
'invoice_terms', 'varchar', 'NULL', $char_d, '', '',
+ 'credit_limit', @money_typen, '', '',
'archived', 'char', 'NULL', 1, '', '',
'email_csv_cdr', 'char', 'NULL', 1, '', '',
],
'unique' => [ [ 'agentnum', 'agent_custid' ] ],
#'index' => [ ['last'], ['company'] ],
'index' => [
- [ 'agentnum' ], [ 'refnum' ], [ 'classnum' ],
+ [ 'agentnum' ], [ 'refnum' ], [ 'classnum' ], [ 'usernum' ],
[ 'custbatch' ],
[ 'referral_custnum' ],
[ 'payby' ], [ 'paydate' ],
'last', 'varchar', '', $char_d, '', '',
# 'middle', 'varchar', 'NULL', $char_d, '', '',
'first', 'varchar', '', $char_d, '', '',
- 'title', 'varchar', '', $char_d, '', '', #eg Head Bottle Washer
- 'comment', 'varchar', '', $char_d, '', '',
+ 'title', 'varchar', 'NULL', $char_d, '', '', #eg Head Bottle Washer
+ 'comment', 'varchar', 'NULL', $char_d, '', '',
'disabled', 'char', 'NULL', 1, '', '',
],
'primary_key' => 'contactnum',
'contact_phone' => {
'columns' => [
- 'contactphonenum', 'serial', '', '', '', '',
- 'contactnum', 'int', '', '', '', '',
- 'phonetypenum', 'int', '', '', '', '',
- 'countrycode', 'varchar', '', 3, '', '',
- 'phonenum', 'varchar', '', 14, '', '',
- 'extension', 'varchar', '', 7, '', '',
- #?#'comment', 'varchar', '', $char_d, '', '',
+ 'contactphonenum', 'serial', '', '', '', '',
+ 'contactnum', 'int', '', '', '', '',
+ 'phonetypenum', 'int', '', '', '', '',
+ 'countrycode', 'varchar', '', 3, '', '',
+ 'phonenum', 'varchar', '', 14, '', '',
+ 'extension', 'varchar', 'NULL', 7, '', '',
+ #?#'comment', 'varchar', '', $char_d, '', '',
],
'primary_key' => 'contactphonenum',
'unique' => [],
'zip', 'varchar', 'NULL', 10, '', '',
'country', 'char', '', 2, '', '',
'geocode', 'varchar', 'NULL', 20, '', '',
+ 'location_type', 'varchar', 'NULL', 20, '', '',
+ 'location_number', 'varchar', 'NULL', 20, '', '',
+ 'location_kind', 'char', 'NULL', 1, '', '',
+ 'disabled', 'char', 'NULL', 1, '', '',
],
'primary_key' => 'locationnum',
'unique' => [],
'columns' => [
'notenum', 'serial', '', '', '', '',
'custnum', 'int', '', '', '', '',
+ 'classnum', 'int', 'NULL', '', '', '',
'_date', @date_type, '', '',
- 'otaker', 'varchar', '', 32, '', '',
+ 'otaker', 'varchar', 'NULL', 32, '', '',
+ 'usernum', 'int', 'NULL', '', '', '',
'comments', 'text', 'NULL', '', '', '',
],
'primary_key' => 'notenum',
'unique' => [],
- 'index' => [ [ 'custnum' ], [ '_date' ], ],
+ 'index' => [ [ 'custnum' ], [ '_date' ], [ 'usernum' ], ],
+ },
+
+ 'cust_note_class' => {
+ 'columns' => [
+ 'classnum', 'serial', '', '', '', '',
+ 'classname', 'varchar', '', $char_d, '', '',
+ 'disabled', 'char', 'NULL', 1, '', '',
+ ],
+ 'primary_key' => 'classnum',
+ 'unique' => [],
+ 'index' => [ ['disabled'] ],
},
'cust_category' => {
'unique' => [],
'index' => [ ['disabled'] ],
},
+
+ 'cust_tag' => {
+ 'columns' => [
+ 'custtagnum', 'serial', '', '', '', '',
+ 'custnum', 'int', '', '', '', '',
+ 'tagnum', 'int', '', '', '', '',
+ ],
+ 'primary_key' => 'custtagnum',
+ 'unique' => [ [ 'custnum', 'tagnum' ] ],
+ 'index' => [ [ 'custnum' ] ],
+ },
+
+ 'part_tag' => {
+ 'columns' => [
+ 'tagnum', 'serial', '', '', '', '',
+ 'tagname', 'varchar', '', $char_d, '', '',
+ 'tagdesc', 'varchar', 'NULL', $char_d, '', '',
+ 'tagcolor', 'varchar', 'NULL', 6, '', '',
+ 'disabled', 'char', 'NULL', 1, '', '',
+ ],
+ 'primary_key' => 'tagnum',
+ 'unique' => [], #[ [ 'tagname' ] ], #?
+ 'index' => [ [ 'disabled' ] ],
+ },
'cust_main_exemption' => {
'columns' => [
'custnum', 'int', '', '', '', '',
'_date', @date_type, '', '',
'paid', @money_type, '', '',
- 'otaker', 'varchar', 'NULL', 32, '', '', #NULL for the upgrade so we can create & populate the field
+ 'otaker', 'varchar', 'NULL', 32, '', '',
+ 'usernum', 'int', 'NULL', '', '', '',
'payby', 'char', '', 4, '', '', # CARD/BILL/COMP, should be
# index into payby table
# eventually
],
'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' ] ],
+ 'index' => [ [ 'custnum' ], [ 'paybatch' ], [ 'payby' ], [ '_date' ], [ 'usernum' ] ],
},
'cust_pay_void' => {
'pkgnum', 'int', 'NULL', '', '', '', #desired pkgnum for pkg-balances
'void_date', @date_type, '', '',
'reason', 'varchar', 'NULL', $char_d, '', '',
- 'otaker', 'varchar', '', 32, '', '',
+ 'otaker', 'varchar', 'NULL', 32, '', '',
+ 'usernum', 'int', 'NULL', '', '', '',
+ 'void_usernum', 'int', 'NULL', '', '', '',
],
'primary_key' => 'paynum',
'unique' => [],
- 'index' => [ [ 'custnum' ] ],
+ 'index' => [ [ 'custnum' ], [ 'usernum' ], [ 'void_usernum' ] ],
},
'cust_bill_pay' => {
'pkgnum', 'serial', '', '', '', '',
'custnum', 'int', '', '', '', '',
'pkgpart', 'int', '', '', '', '',
+ 'pkgbatch', 'varchar', 'NULL', $char_d, '', '',
'locationnum', 'int', 'NULL', '', '', '',
- 'otaker', 'varchar', '', 32, '', '',
+ 'otaker', 'varchar', 'NULL', 32, '', '',
+ 'usernum', 'int', 'NULL', '', '', '',
+ 'order_date', @date_type, '', '',
'start_date', @date_type, '', '',
'setup', @date_type, '', '',
'bill', @date_type, '', '',
'adjourn', @date_type, '', '',
'cancel', @date_type, '', '',
'expire', @date_type, '', '',
+ 'contract_end', @date_type, '', '',
'change_date', @date_type, '', '',
'change_pkgnum', 'int', 'NULL', '', '', '',
'change_pkgpart', 'int', 'NULL', '', '', '',
'change_locationnum', 'int', 'NULL', '', '', '',
'manual_flag', 'char', 'NULL', 1, '', '',
+ 'no_auto', 'char', 'NULL', 1, '', '',
'quantity', 'int', 'NULL', '', '', '',
],
'primary_key' => 'pkgnum',
'unique' => [],
- 'index' => [ ['custnum'], ['pkgpart'], [ 'locationnum' ],
+ 'index' => [ ['custnum'], ['pkgpart'], [ 'pkgbatch' ], [ 'locationnum' ],
+ [ 'usernum' ],
[ 'start_date' ], ['setup'], ['last_bill'], ['bill'],
['susp'], ['adjourn'], ['expire'], ['cancel'],
- ['change_date'],
+ ['change_date'], ['order_date'],
],
},
'pkgnum', 'int', '', '', '', '',
'reasonnum','int', '', '', '', '',
'action', 'char', 'NULL', 1, '', '', #should not be nullable
- 'otaker', 'varchar', '', 32, '', '',
+ 'otaker', 'varchar', 'NULL', 32, '', '',
+ 'usernum', 'int', 'NULL', '', '', '',
'date', @date_type, '', '',
],
'primary_key' => 'num',
'unique' => [],
- 'index' => [ [ 'pkgnum' ], [ 'reasonnum' ], ['action'], ],
+ 'index' => [ [ 'pkgnum' ], [ 'reasonnum' ], ['action'], [ 'usernum' ], ],
},
'cust_pkg_discount' => {
'discountnum', 'int', '', '', '', '',
'months_used', 'decimal', 'NULL', '', '', '',
'end_date', @date_type, '', '',
- 'otaker', 'varchar', '', 32, '', '',
+ 'otaker', 'varchar', 'NULL', 32, '', '',
+ 'usernum', 'int', 'NULL', '', '', '',
+ 'disabled', 'char', 'NULL', 1, '', '',
],
'primary_key' => 'pkgdiscountnum',
'unique' => [],
- 'index' => [ [ 'pkgnum' ], [ 'discountnum' ] ],
+ 'index' => [ [ 'pkgnum' ], [ 'discountnum' ], [ 'usernum' ], ],
+ },
+
+ 'cust_bill_pkg_discount' => {
+ 'columns' => [
+ 'billpkgdiscountnum', 'serial', '', '', '', '',
+ 'billpkgnum', 'int', '', '', '', '',
+ 'pkgdiscountnum', 'int', '', '', '', '',
+ 'amount', @money_type, '', '',
+ 'months', 'decimal', 'NULL', '', '', '',
+ ],
+ 'primary_key' => 'billpkgdiscountnum',
+ 'unique' => [],
+ 'index' => [ [ 'billpkgnum' ], [ 'pkgdiscountnum' ] ],
},
'discount' => {
'custnum', 'int', '', '', '', '',
'_date', @date_type, '', '',
'refund', @money_type, '', '',
- 'otaker', 'varchar', '', 32, '', '',
+ 'otaker', 'varchar', 'NULL', 32, '', '',
+ 'usernum', 'int', 'NULL', '', '', '',
'reason', 'varchar', '', $char_d, '', '',
'payby', 'char', '', 4, '', '', # CARD/BILL/COMP, should
# be index into payby
],
'primary_key' => 'refundnum',
'unique' => [],
- 'index' => [ ['custnum'], ['_date'] ],
+ 'index' => [ ['custnum'], ['_date'], [ 'usernum' ], ],
},
'cust_credit_refund' => {
'pay_weight', 'real', 'NULL', '', '', '',
'credit_weight', 'real', 'NULL', '', '', '',
'agentnum', 'int', 'NULL', '', '', '',
-
+ 'fcc_ds0s', 'int', 'NULL', '', '', '',
+ 'no_auto', 'char', 'NULL', 1, '', '',
],
'primary_key' => 'pkgpart',
'unique' => [],
# 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)
+ 'part_pkg_discount' => {
+ 'columns' => [
+ 'pkgdiscountnum', 'serial', '', '', '', '',
+ 'pkgpart', 'int', '', '', '', '',
+ 'discountnum', 'int', '', '', '', '',
+ ],
+ 'primary_key' => 'pkgdiscountnum',
+ 'unique' => [ [ 'pkgpart', 'discountnum' ] ],
+ 'index' => [],
+ },
+
'part_pkg_taxclass' => {
'columns' => [
'taxclassnum', 'serial', '', '', '', '',
'part_pkg_taxoverride' => {
'columns' => [
'taxoverridenum', 'serial', '', '', '', '',
- 'pkgpart', 'serial', '', '', '', '',
- 'taxclassnum', 'serial', '', '', '', '',
+ 'pkgpart', 'int', '', '', '', '',
+ 'taxclassnum', 'int', '', '', '', '',
'usage_class', 'varchar', 'NULL', $char_d, '', '',
],
'primary_key' => 'taxoverridenum',
'svcpart', 'int', '', '', '', '',
'quantity', 'int', '', '', '', '',
'primary_svc','char', 'NULL', 1, '', '',
+ 'hidden', 'char', 'NULL', 1, '', '',
],
'primary_key' => 'pkgsvcnum',
'unique' => [ ['pkgpart', 'svcpart'] ],
'unique' => [],
'index' => [ [ 'npa', 'nxx' ], [ 'popnum' ] ],
},
+
+ 'qual' => {
+ 'columns' => [
+ 'qualnum', 'serial', '', '', '', '',
+ 'custnum', 'int', 'NULL', '', '', '',
+ 'prospectnum', 'int', 'NULL', '', '', '',
+ 'locationnum', 'int', 'NULL', '', '', '',
+ 'phonenum', 'varchar', 'NULL', 24, '', '',
+ 'exportnum', 'int', 'NULL', '', '', '',
+ 'vendor_qual_id', 'varchar', 'NULL', $char_d, '', '',
+ 'status', 'char', '', 1, '', '',
+ ],
+ 'primary_key' => 'qualnum',
+ 'unique' => [],
+ 'index' => [ [ 'locationnum' ], ['custnum'], ['prospectnum'],
+ ['phonenum'], ['vendor_qual_id'] ],
+ },
+
+ 'qual_option' => {
+ 'columns' => [
+ 'optionnum', 'serial', '', '', '', '',
+ 'qualnum', 'int', '', '', '', '',
+ 'optionname', 'varchar', '', $char_d, '', '',
+ 'optionvalue', 'text', 'NULL', '', '', '',
+ ],
+ 'primary_key' => 'optionnum',
+ 'unique' => [],
+ 'index' => [],
+ },
'svc_acct' => {
'columns' => [
'pbxsvc', 'int', 'NULL', '', '', '',
'last_login', @date_type, '', '',
'last_logout', @date_type, '', '',
+ #cardfortress field(s)
+ 'cf_privatekey', 'text', 'NULL', '', '', '',
+ #communigate pro fields (quota = MaxAccountSize)
+ 'cgp_aliases', 'varchar', 'NULL', 255, '', '',
+ #settings
+ 'cgp_type', 'varchar', 'NULL', $char_d, '', '', #AccountType
+ 'file_quota', 'varchar', 'NULL', $char_d, '', '', #MaxWebSize
+ 'file_maxnum', 'varchar', 'NULL', $char_d, '', '', #MaxWebFiles
+ 'file_maxsize', 'varchar', 'NULL', $char_d, '', '', #MaxFileSize
+ 'cgp_accessmodes', 'varchar', 'NULL', 255, '', '', #AccessModes
+ 'password_selfchange','char', 'NULL', 1, '', '', #PWDAllowed
+ 'password_recover', 'char', 'NULL', 1, 'Y','', #PasswordRecovery
+ 'cgp_rulesallowed','varchar', 'NULL', $char_d, '', '', #RulesAllowed
+ 'cgp_rpopallowed', 'char', 'NULL', 1, '', '', #RPOPAllowed
+ 'cgp_mailtoall', 'char', 'NULL', 1, '', '', #MailToAll
+ 'cgp_addmailtrailer', 'char', 'NULL', 1, '', '', #AddMailTrailer
+ 'cgp_archiveafter', 'int', 'NULL', '', '', '', #ArchiveMessagesAfter
+ #XXX mailing lists
+ #preferences
+ 'cgp_deletemode', 'varchar', 'NULL', $char_d, '', '',#DeleteMode
+ 'cgp_emptytrash', 'varchar', 'NULL', $char_d, '', '',#EmptyTrash
+ 'cgp_language', 'varchar', 'NULL', $char_d, '', '',#Language
+ 'cgp_timezone', 'varchar', 'NULL', $char_d, '', '',#TimeZone
+ 'cgp_skinname', 'varchar', 'NULL', $char_d, '', '',#SkinName
+ 'cgp_prontoskinname', 'varchar', 'NULL', $char_d, '', '',#ProntoSkinName
+ 'cgp_sendmdnmode', 'varchar', 'NULL', $char_d, '', '',#SendMDNMode
+ #mail
+ #XXX RPOP settings
],
'primary_key' => 'svcnum',
#'unique' => [ [ 'username', 'domsvc' ] ],
'parent_svcnum', 'int', 'NULL', '', '', '',
'registrarnum', 'int', 'NULL', '', '', '',
'registrarkey', 'varchar', 'NULL', 512, '', '',
- 'setup_date', @date_type, '', '',
+ 'setup_date', @date_type, '', '',
'renewal_interval', 'int', 'NULL', '', '', '',
'expiration_date', @date_type, '', '',
+ #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
+ 'acct_def_password_selfchange', 'char', 'NULL', 1, '', '',
+ 'acct_def_password_recover', 'char', 'NULL', 1, 'Y', '',
+ 'acct_def_cgp_accessmodes', 'varchar', 'NULL', 255, '', '',
+ 'acct_def_quota', 'varchar', 'NULL', $char_d, '', '',
+ 'acct_def_file_quota', 'varchar', 'NULL', $char_d, '', '',
+ 'acct_def_file_maxnum', 'varchar', 'NULL', $char_d, '', '',
+ 'acct_def_file_maxsize', 'varchar', 'NULL', $char_d, '', '',
+ 'acct_def_cgp_rulesallowed', 'varchar', 'NULL', $char_d, '', '',
+ 'acct_def_cgp_rpopallowed', 'char', 'NULL', 1, '', '',
+ 'acct_def_cgp_mailtoall', 'char', 'NULL', 1, '', '',
+ 'acct_def_cgp_addmailtrailer', 'char', 'NULL', 1, '', '',
+ 'acct_def_cgp_archiveafter', 'int', 'NULL', '', '', '',
+ #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_timezone', 'varchar', 'NULL', $char_d, '', '',
+ 'acct_def_cgp_skinname', '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'] ],
},
+
+ 'svc_dsl' => {
+ 'columns' => [
+ 'svcnum', 'int', '', '', '', '',
+ 'pushed', 'int', 'NULL', '', '', '',
+ '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, '', '',
+ 'first', 'varchar', 'NULL', $char_d, '', '',
+ 'last', 'varchar', 'NULL', $char_d, '', '',
+ 'company', 'varchar', 'NULL', $char_d, '', '',
+ 'phonenum', 'varchar', 'NULL', 24, '', '',
+ 'loop_type', 'char', 'NULL', 1, '', '',
+ 'local_voice_provider', 'varchar', 'NULL', $char_d, '', '',
+ 'circuitnum', 'varchar', 'NULL', $char_d, '', '',
+ 'rate_band', 'varchar', 'NULL', $char_d, '', '',
+ 'isp_chg', 'char', 'NULL', 1, '', '',
+ 'isp_prev', 'varchar', 'NULL', $char_d, '', '',
+ 'username', 'varchar', 'NULL', $char_d, '', '',
+ 'password', 'varchar', 'NULL', $char_d, '', '',
+ 'staticips', 'text', 'NULL', '', '', '',
+ 'monitored', 'char', 'NULL', 1, '', '',
+ 'last_pull', 'int', 'NULL', '', '', '',
+ ],
+ 'primary_key' => 'svcnum',
+ 'unique' => [ ],
+ 'index' => [ ['phonenum'], ['vendor_order_id'] ],
+ },
+
+ 'dsl_note' => {
+ 'columns' => [
+ 'notenum', 'serial', '', '', '', '',
+ 'svcnum', 'int', '', '', '', '',
+ 'author', 'varchar', 'NULL', $char_d, '', '',
+ 'priority', 'char', 'NULL', 1, '', '',
+ '_date', 'int', 'NULL', '', '', '',
+ 'note', 'text', '', '', '', '',
+ ],
+ 'primary_key' => 'notenum',
+ 'unique' => [ ],
+ 'index' => [ ['svcnum'] ],
+ },
'domain_record' => {
'columns' => [
'recaf', 'char', '', 2, '', '',
'rectype', 'varchar', '', 5, '', '',
'recdata', 'varchar', '', 255, '', '',
+ 'ttl', 'int', 'NULL', '', '', '',
],
'primary_key' => 'recnum',
'unique' => [],
'index' => [],
},
+ 'cgp_rule' => {
+ 'columns' => [
+ 'rulenum', 'serial', '', '', '', '',
+ 'name', 'varchar', '', $char_d, '', '',
+ 'comment', 'varchar', 'NULL', $char_d, '', '',
+ 'svcnum', 'int', '', '', '', '',
+ 'priority', 'int', '', '', '', '',
+ ],
+ 'primary_key' => 'rulenum',
+ 'unique' => [ [ 'svcnum', 'name' ] ],
+ 'index' => [ [ 'svcnum' ] ],
+ },
+
+ 'cgp_rule_condition' => {
+ 'columns' => [
+ 'ruleconditionnum', 'serial', '', '', '', '',
+ 'conditionname', 'varchar', '', $char_d, '', '',
+ 'op', 'varchar', 'NULL', $char_d, '', '',
+ 'params', 'varchar', 'NULL', 255, '', '',
+ 'rulenum', 'int', '', '', '', '',
+ ],
+ 'primary_key' => 'ruleconditionnum',
+ 'unique' => [],
+ 'index' => [ [ 'rulenum' ] ],
+ },
+
+ 'cgp_rule_action' => {
+ 'columns' => [
+ 'ruleactionnum', 'serial', '', '', '', '',
+ 'action', 'varchar', '', $char_d, '', '',
+ 'params', 'varchar', 'NULL', 255, '', '',
+ 'rulenum', 'int', '', '', '', '',
+ ],
+ 'primary_key' => 'ruleactionnum',
+ 'unique' => [],
+ 'index' => [ [ 'rulenum' ] ],
+ },
+
'svc_forward' => {
'columns' => [
'svcnum', 'int', '', '', '', '',
'index' => [ [ 'exportnum' ], [ 'svcpart' ] ],
},
+ 'export_device' => {
+ 'columns' => [
+ 'exportdevicenum' => 'serial', '', '', '', '',
+ 'exportnum' => 'int', '', '', '', '',
+ 'devicepart' => 'int', '', '', '', '',
+ ],
+ 'primary_key' => 'exportdevicenum',
+ 'unique' => [ [ 'exportnum', 'devicepart' ] ],
+ 'index' => [ [ 'exportnum' ], [ 'devicepart' ] ],
+ },
+
'part_export' => {
'columns' => [
'exportnum', 'serial', '', '', '', '',
+ 'exportname', 'varchar', 'NULL', $char_d, '', '',
'machine', 'varchar', '', $char_d, '', '',
'exporttype', 'varchar', '', $char_d, '', '',
'nodomain', 'char', 'NULL', 1, '', '',
'acct_snarf' => {
'columns' => [
- 'snarfnum', 'int', '', '', '', '',
- 'svcnum', 'int', '', '', '', '',
- 'machine', 'varchar', '', 255, '', '',
- 'protocol', 'varchar', '', $char_d, '', '',
- 'username', 'varchar', '', $char_d, '', '',
- '_password', 'varchar', '', $char_d, '', '',
+ 'snarfnum', 'serial', '', '', '', '',
+ 'snarfname', 'varchar', 'NULL', $char_d, '', '',
+ 'svcnum', 'int', '', '', '', '',
+ 'machine', 'varchar', '', 255, '', '',
+ 'protocol', 'varchar', '', $char_d, '', '',
+ 'username', 'varchar', '', $char_d, '', '',
+ '_password', 'varchar', '', $char_d, '', '',
+ 'check_freq', 'int', 'NULL', '', '', '',
+ 'leavemail', 'char', 'NULL', 1, '', '',
+ 'apop', 'char', 'NULL', 1, '', '',
+ 'tls', 'char', 'NULL', 1, '', '',
+ 'mailbox', 'varchar', 'NULL', $char_d, '', '',
],
'primary_key' => 'snarfnum',
'unique' => [],
'index' => [ [ 'pkgpart' ], [ 'optionname' ] ],
},
+ 'part_pkg_vendor' => {
+ 'columns' => [
+ 'num', 'serial', '', '', '', '',
+ 'pkgpart', 'int', '', '', '', '',
+ 'exportnum', 'int', '', '', '', '',
+ 'vendor_pkg_id', 'varchar', '', $char_d, '', '',
+ ],
+ 'primary_key' => 'num',
+ 'unique' => [ [ 'pkgpart', 'exportnum' ] ],
+ 'index' => [ [ 'pkgpart' ] ],
+ },
+
'part_pkg_report_option' => {
'columns' => [
'num', 'serial', '', '', '', '',
'rate_detail' => {
'columns' => [
- 'ratedetailnum', 'serial', '', '', '', '',
- 'ratenum', 'int', '', '', '', '',
- 'orig_regionnum', 'int', 'NULL', '', '', '',
- 'dest_regionnum', 'int', '', '', '', '',
- 'min_included', 'int', '', '', '', '',
- #'min_charge', @money_type, '', '',
- 'min_charge', 'decimal', '', '10,5', '', '',
- 'sec_granularity', 'int', '', '', '', '',
- #time period (link to table of periods)?
- 'classnum', 'int', 'NULL', '', '', '',
+ 'ratedetailnum', 'serial', '', '', '', '',
+ 'ratenum', 'int', '', '', '', '',
+ 'orig_regionnum', 'int', 'NULL', '', '', '',
+ 'dest_regionnum', 'int', '', '', '', '',
+ 'min_included', 'int', '', '', '', '',
+ 'conn_charge', 'decimal', '', '10,4', '0', '',
+ 'conn_sec', 'int', '', '', '0', '',
+ 'min_charge', 'decimal', '', '10,5', '', '', #@money_type, '', '',
+ 'sec_granularity', 'int', '', '', '', '',
+ 'ratetimenum', 'int', 'NULL', '', '', '',
+ 'classnum', 'int', 'NULL', '', '', '',
],
'primary_key' => 'ratedetailnum',
'unique' => [ [ 'ratenum', 'orig_regionnum', 'dest_regionnum' ] ],
'index' => [ [ 'countrycode' ], [ 'npa' ], [ 'regionnum' ] ],
},
+ 'rate_time' => {
+ 'columns' => [
+ 'ratetimenum', 'serial', '', '', '', '',
+ 'ratetimename', 'varchar', '', $char_d, '', '',
+ ],
+ 'primary_key' => 'ratetimenum',
+ 'unique' => [],
+ 'index' => [],
+ },
+
+ 'rate_time_interval' => {
+ 'columns' => [
+ 'intervalnum', 'serial', '', '', '', '',
+ 'stime', 'int', '', '', '', '',
+ 'etime', 'int', '', '', '', '',
+ 'ratetimenum', 'int', '', '', '', '',
+ ],
+ 'primary_key' => 'intervalnum',
+ 'unique' => [],
+ 'index' => [],
+ },
+
'usage_class' => {
'columns' => [
'classnum', 'serial', '', '', '', '',
'payinfo', 'varchar', '', 128, '', '', #say, a 512-big digest _hex encoded
#'paymask', 'varchar', 'NULL', $char_d, '', ''
'_date', @date_type, '', '',
- 'otaker', 'varchar', '', 32, '', '',
+ 'otaker', 'varchar', 'NULL', 32, '', '',
+ 'usernum', 'int', 'NULL', '', '', '',
'reason', 'varchar', 'NULL', $char_d, '', '',
],
'primary_key' => 'bannum',
'unique' => [ [ 'payby', 'payinfo' ] ],
- 'index' => [],
+ 'index' => [ [ 'usernum' ] ],
},
'pkg_category' => {
'uniqueid', 'varchar', '', 32, \"''", '',
'userfield', 'varchar', '', 255, \"''", '',
+ 'max_callers', 'int', 'NULL', '', '', '',
+
###
# fields for unitel/RSLCOM/convergent that don't map well to asterisk
# defaults
'termpart', 'int', '', '', '', '',#future use see below
'rated_price', 'decimal', 'NULL', '10,4', '', '',
'status', 'varchar', 'NULL', 32, '', '',
+ 'svcnum', 'int', 'NULL', '', '', '',
],
'primary_key' => 'cdrtermnum',
'unique' => [ [ 'acctid', 'termpart' ] ],
'columns' => [
'itemnum', 'serial', '', '', '', '',
'classnum', 'int', '', '', '', '',
+ 'agentnum', 'int', 'NULL', '', '', '',
'item', 'varchar', '', $char_d, '', '',
'svcnum', 'int', 'NULL', '', '', '',
],
'primary_key' => 'itemnum',
'unique' => [ [ 'classnum', 'item' ] ],
- 'index' => [ [ 'classnum' ], [ 'svcnum' ] ],
+ 'index' => [ [ 'classnum' ], [ 'agentnum' ], [ 'svcnum' ] ],
},
'inventory_class' => {
'_password', 'varchar', '', $char_d, '', '',
'last', 'varchar', '', $char_d, '', '',
'first', 'varchar', '', $char_d, '', '',
+ 'user_custnum', 'int', 'NULL', '', '', '',
'disabled', 'char', 'NULL', 1, '', '',
],
'primary_key' => 'usernum',
'unique' => [ [ 'username' ] ],
- 'index' => [],
+ 'index' => [ [ 'user_custnum' ] ],
},
'access_user_pref' => {
'sip_password', 'varchar', 'NULL', $char_d, '', '',
'phone_name', 'varchar', 'NULL', $char_d, '', '',
'pbxsvc', 'int', 'NULL', '', '', '',
+ 'domsvc', 'int', 'NULL', '', '', '',
+ 'locationnum', 'int', 'NULL', '', '', '',
+ 'route', 'varchar', 'NULL', $char_d, '', '',
+ '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, '', '',
],
'primary_key' => 'svcnum',
'unique' => [],
- 'index' => [ [ 'countrycode', 'phonenum' ], ['pbxsvc'] ],
+ 'index' => [ ['countrycode', 'phonenum'], ['pbxsvc'], ['domsvc'],
+ ['locationnum'],
+ ],
},
'phone_device' => {
'svc_pbx' => {
'columns' => [
- 'svcnum', 'int', '', '', '', '',
- 'id', 'int', 'NULL', '', '', '',
- 'title', 'varchar', 'NULL', $char_d, '', '',
- 'max_extensions', 'int', 'NULL', '', '', '',
+ 'svcnum', 'int', '', '', '', '',
+ 'id', 'int', 'NULL', '', '', '',
+ 'title', 'varchar', 'NULL', $char_d, '', '',
+ 'max_extensions', 'int', 'NULL', '', '', '',
+ 'max_simultaneous', 'int', 'NULL', '', '', '',
],
'primary_key' => 'svcnum',
'unique' => [],
'index' => [ [ 'id' ] ],
},
+ 'svc_mailinglist' => { #svc_group?
+ 'columns' => [
+ 'svcnum', 'int', '', '', '', '',
+ 'username', 'varchar', '', $username_len, '', '',
+ 'domsvc', 'int', '', '', '', '',
+ 'listnum', 'int', '', '', '', '',
+ 'reply_to', 'char', 'NULL', 1, '', '',#SetReplyTo
+ 'remove_from', 'char', 'NULL', 1, '', '',#RemoveAuthor
+ 'reject_auto', 'char', 'NULL', 1, '', '',#RejectAuto
+ 'remove_to_and_cc', 'char', 'NULL', 1, '', '',#RemoveToAndCc
+ ],
+ 'primary_key' => 'svcnum',
+ 'unique' => [],
+ 'index' => [ ['username'], ['domsvc'], ['listnum'] ],
+ },
+
+ 'mailinglist' => {
+ 'columns' => [
+ 'listnum', 'serial', '', '', '', '',
+ 'listname', 'varchar', '', $char_d, '', '',
+ ],
+ 'primary_key' => 'listnum',
+ 'unique' => [],
+ 'index' => [],
+ },
+
+ 'mailinglistmember' => {
+ 'columns' => [
+ 'membernum', 'serial', '', '', '', '',
+ 'listnum', 'int', '', '', '', '',
+ 'svcnum', 'int', 'NULL', '', '', '',
+ 'contactemailnum', 'int', 'NULL', '', '', '',
+ 'email', 'varchar', 'NULL', 255, '', '',
+ ],
+ 'primary_key' => 'membernum',
+ 'unique' => [],
+ 'index' => [['listnum'],['svcnum'],['contactemailnum'],['email']],
+ },
+
+ 'bill_batch' => {
+ 'columns' => [
+ 'batchnum', 'serial', '', '', '', '',
+ 'status', 'char', 'NULL','1', '', '',
+ 'pdf', 'blob', 'NULL', '', '', '',
+ ],
+ 'primary_key' => 'batchnum',
+ 'unique' => [],
+ 'index' => [],
+ },
+
+ 'cust_bill_batch' => {
+ 'columns' => [
+ 'billbatchnum', 'serial', '', '', '', '',
+ 'batchnum', 'int', '', '', '', '',
+ 'invnum', 'int', '', '', '', '',
+ ],
+ 'primary_key' => 'billbatchnum',
+ 'unique' => [],
+ 'index' => [ [ 'batchnum' ], [ 'invnum' ] ],
+ },
+
+ 'cust_bill_batch_option' => {
+ 'columns' => [
+ 'optionnum', 'serial', '', '', '', '',
+ 'billbatchnum', 'int', '', '', '', '',
+ 'optionname', 'varchar', '', $char_d, '', '',
+ 'optionvalue', 'text', 'NULL', '', '', '',
+ ],
+ 'primary_key' => 'optionnum',
+ 'unique' => [],
+ 'index' => [ [ 'billbatchnum' ], [ 'optionname' ] ],
+ },
+
+ 'msg_template' => {
+ 'columns' => [
+ 'msgnum', 'serial', '', '', '', '',
+ 'msgname', 'varchar', '', $char_d, '', '',
+ 'agentnum', 'int', 'NULL', '', '', '',
+ 'subject', 'varchar', 'NULL', 512, '', '',
+ 'mime_type', 'varchar', '', $char_d, '', '',
+ 'body', 'blob', 'NULL', '', '', '',
+ 'disabled', 'char', 'NULL', 1, '', '',
+ 'from_addr', 'varchar', 'NULL', 255, '', '',
+ 'bcc_addr', 'varchar', 'NULL', 255, '', '',
+ ],
+ 'primary_key' => 'msgnum',
+ 'unique' => [ ['msgname', 'mime_type'] ],
+ 'index' => [ ['agentnum'], ]
+ },
+
+ 'svc_cert' => {
+ 'columns' => [
+ 'svcnum', 'int', '', '', '', '',
+ 'recnum', 'int', 'NULL', '', '', '',
+ 'privatekey', 'text', 'NULL', '', '', '',
+ 'csr', 'text', 'NULL', '', '', '',
+ 'certificate', 'text', 'NULL', '', '', '',
+ 'cacert', 'text', 'NULL', '', '', '',
+ 'common_name', 'varchar', 'NULL', $char_d, '', '',
+ 'organization', 'varchar', 'NULL', $char_d, '', '',
+ 'organization_unit', 'varchar', 'NULL', $char_d, '', '',
+ 'city', 'varchar', 'NULL', $char_d, '', '',
+ 'state', 'varchar', 'NULL', $char_d, '', '',
+ 'country', 'char', 'NULL', 2, '', '',
+ 'cert_contact', 'varchar', 'NULL', $char_d, '', '',
+ ],
+ 'primary_key' => 'svcnum',
+ 'unique' => [],
+ 'index' => [], #recnum
+ },
+
+ 'nms_device' => {
+ 'columns' => [
+ 'nms_devicenum', 'serial', '', '', '', '',
+ #'agentnum', 'int', 'NULL', '', '', '',
+ 'devicename', 'varchar', '', $char_d, '', '',
+ 'ip', 'varchar', '', 15, '', '',
+ 'protocol', 'varchar', '', $char_d, '', '',
+# 'last', 'int', '', '', '', '',
+ ],
+ 'primary_key' => 'nms_devicenum',
+ 'unique' => [],
+ 'index' => [],
+ },
+
+ 'nms_deviceport' => {
+ 'columns' => [
+ 'portnum', 'serial', '', '', '', '',
+ 'nms_devicenum', 'int', '', '', '', '',
+ 'deviceport', 'int', '', '', '', '',
+ #'ip', 'varchar', 'NULL', 15, '', '',
+ 'svcnum', 'int', 'NULL', '', '', '',
+ ],
+ 'primary_key' => 'portnum',
+ 'unique' => [ [ 'nms_devicenum', 'deviceport' ] ],
+ 'index' => [ [ 'svcnum' ] ],
+ },
+
+ 'svc_port' => {
+ 'columns' => [
+ 'svcnum', 'int', '', '', '', '',
+ ],
+ 'primary_key' => 'svcnum',
+ 'unique' => [],
+ 'index' => [], #recnum
+ },
+
+ %{ tables_hashref_torrus() },
+
# name type nullability length default local