X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FSchema.pm;h=660a072b8ff5e53bd88e9f3410aaedace0cb0660;hb=dd2249efe0daa3fc3257029de84d212aa89a4ee9;hp=6a8efcdc5776e38401722196da1e0dd5c0662544;hpb=7d0e23b6ac9c0de45bcc65f13cae6f928dd790ef;p=freeside.git diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index 6a8efcdc5..660a072b8 100644 --- a/FS/FS/Schema.pm +++ b/FS/FS/Schema.pm @@ -102,6 +102,10 @@ sub dbdef_dist { 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 = ; @@ -113,7 +117,17 @@ sub dbdef_dist { #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({ @@ -130,7 +144,7 @@ sub dbdef_dist { 'columns' => $_, }); } - @$index; + @index; DBIx::DBSchema::Table->new({ 'name' => $tablename, @@ -256,7 +270,7 @@ sub dbdef_dist { } ); if ( $column->type =~ /^(\w*)SERIAL$/i ) { - $column->type('int'); + $column->type(uc($1).'INT'); $column->null('NULL'); } #$column->default('') @@ -378,8 +392,9 @@ sub tables_hashref { 'custnum', 'int', '', '', '', '', '_date', @date_type, '', '', 'otaker', 'varchar', '', 32, '', '', - 'filename', 'varchar', '', 32, '', '', - 'mime_type', 'varchar', '', 32, '', '', + 'filename', 'varchar', '', 255, '', '', + 'mime_type', 'varchar', '', $char_d, '', '', + 'title', 'varchar', 'NULL', $char_d, '', '', 'body', 'blob', 'NULL', '', '', '', 'disabled', @date_type, '', '', ], @@ -572,7 +587,9 @@ sub tables_hashref { 'amount', 'decimal', 'NULL', '10,4', '', '', 'format', 'char', 'NULL', 1, '', '', 'classnum', 'int', 'NULL', '', '', '', + 'duration', 'int', 'NULL', '', 0, '', 'phonenum', 'varchar', 'NULL', 15, '', '', + 'regionname', 'varchar', 'NULL', $char_d, '', '', 'detail', 'varchar', '', 255, '', '', ], 'primary_key' => 'detailnum', @@ -638,10 +655,11 @@ sub tables_hashref { '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'], ['eventnum'] ], }, 'cust_credit_bill' => { @@ -911,6 +929,8 @@ sub tables_hashref { 'passflag', 'char', 'NULL', 1, '', '', # Y = required to list as line item, N = Prohibited 'setuptax', 'char', 'NULL', 1, '', '', # Y = setup tax exempt 'recurtax', 'char', 'NULL', 1, '', '', # Y = recur tax exempt + 'inoutcity', 'char', 'NULL', 1, '', '', # '', 'I', or 'O' + 'inoutlocal', 'char', 'NULL', 1, '', '', # '', 'I', or 'O' 'manual', 'char', 'NULL', 1, '', '', # Y = manually edited 'disabled', 'char', 'NULL', 1, '', '', # Y = tax disabled ], @@ -1348,8 +1368,8 @@ sub tables_hashref { 'part_pkg_taxoverride' => { 'columns' => [ 'taxoverridenum', 'serial', '', '', '', '', - 'pkgpart', 'serial', '', '', '', '', - 'taxclassnum', 'serial', '', '', '', '', + 'pkgpart', 'int', '', '', '', '', + 'taxclassnum', 'int', '', '', '', '', 'usage_class', 'varchar', 'NULL', $char_d, '', '', ], 'primary_key' => 'taxoverridenum', @@ -1470,14 +1490,26 @@ sub tables_hashref { 'downbytes_threshold', 'bigint', 'NULL', '', '', '', 'totalbytes','bigint', 'NULL', '', '', '', 'totalbytes_threshold', 'bigint', 'NULL', '', '', '', - 'domsvc', 'int', '', '', '', '', + 'domsvc', 'int', '', '', '', '', + 'pbxsvc', 'int', 'NULL', '', '', '', 'last_login', @date_type, '', '', 'last_logout', @date_type, '', '', + #communigate pro fields (quota = MaxAccountSize) + '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, '', '', #PasswordRecovery + 'cgp_type', 'varchar', 'NULL', $char_d, '', '', #AccountType + 'cgp_aliases', 'varchar', 'NULL', 255, '', '', + 'cgp_deletemode', 'varchar', 'NULL', $char_d, '', '', #DeleteMode + 'cgp_emptytrash', 'varchar', 'NULL', $char_d, '', '', #EmptyTrash ], 'primary_key' => 'svcnum', #'unique' => [ [ 'username', 'domsvc' ] ], 'unique' => [], - 'index' => [ ['username'], ['domsvc'] ], + 'index' => [ ['username'], ['domsvc'], ['pbxsvc'] ], }, 'acct_rt_transaction' => { @@ -1513,9 +1545,22 @@ sub tables_hashref { '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', '', '', '', + 'cgp_aliases', 'varchar', 'NULL', 255, '', '', + 'cgp_accessmodes','varchar','NULL', 255, '', '', #DomainAccessModes + 'acct_def_password_selfchange','char', 'NULL', 1, '', '', + 'acct_def_password_recover', 'char', 'NULL', 1, '', '', + '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_deletemode', 'varchar', 'NULL', $char_d, '', '', + 'acct_def_cgp_emptytrash', 'varchar', 'NULL', $char_d, '', '', ], 'primary_key' => 'svcnum', 'unique' => [ ], @@ -1691,6 +1736,17 @@ sub tables_hashref { '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', '', '', '', '', @@ -1928,16 +1984,17 @@ sub tables_hashref { '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', '', '', '', '', + 'ratedetailnum', 'serial', '', '', '', '', + 'ratenum', 'int', '', '', '', '', + 'orig_regionnum', 'int', 'NULL', '', '', '', + 'dest_regionnum', 'int', '', '', '', '', + 'min_included', 'int', '', '', '', '', + 'conn_charge', @money_type, '0', '', #'decimal','','10,5','0','', + 'conn_sec', 'int', '', '', '0', '', + 'min_charge', 'decimal', '', '10,5', '', '', #@money_type, '', '', + 'sec_granularity', 'int', '', '', '', '', #time period (link to table of periods)? - 'classnum', 'int', 'NULL', '', '', '', + 'classnum', 'int', 'NULL', '', '', '', ], 'primary_key' => 'ratedetailnum', 'unique' => [ [ 'ratenum', 'orig_regionnum', 'dest_regionnum' ] ], @@ -1964,14 +2021,16 @@ sub tables_hashref { ], 'primary_key' => 'prefixnum', 'unique' => [], - 'index' => [ [ 'countrycode' ], [ 'regionnum' ] ], + 'index' => [ [ 'countrycode' ], [ 'npa' ], [ 'regionnum' ] ], }, 'usage_class' => { 'columns' => [ - 'classnum', 'serial', '', '', '', '', - 'classname', 'varchar', '', $char_d, '', '', - 'disabled', 'char', 'NULL', 1, '', '', + 'classnum', 'serial', '', '', '', '', + 'weight', 'int', 'NULL', '', '', '', + 'classname', 'varchar', '', $char_d, '', '', + 'format', 'varchar', 'NULL', $char_d, '', '', + 'disabled', 'char', 'NULL', 1, '', '', ], 'primary_key' => 'classnum', 'unique' => [], @@ -2084,6 +2143,7 @@ sub tables_hashref { 'categorynum', 'serial', '', '', '', '', 'categoryname', 'varchar', '', $char_d, '', '', 'weight', 'int', 'NULL', '', '', '', + 'condense', 'char', 'NULL', 1, '', '', 'disabled', 'char', 'NULL', 1, '', '', ], 'primary_key' => 'categorynum', @@ -2147,6 +2207,8 @@ sub tables_hashref { ### # fields for unitel/RSLCOM/convergent that don't map well to asterisk # defaults + # though these are now used elsewhere: + # charged_party, upstream_price, rated_price, carrierid ### #cdr_type: Usage = 1, S&E = 7, OC&C = 8 @@ -2189,19 +2251,36 @@ sub tables_hashref { #NULL, done (or something) 'freesiderewritestatus', 'varchar', 'NULL', 32, '', '', + #an indexed place to put big numbers + 'cdrid', 'bigint', 'NULL', '', '', '', + + #old 'cdrbatch', 'varchar', 'NULL', 255, '', '', + #new + 'cdrbatchnum', 'int', 'NULL', '', '', '', ], 'primary_key' => 'acctid', 'unique' => [], 'index' => [ [ 'calldate' ], [ 'src' ], [ 'dst' ], [ 'dcontext' ], [ 'charged_party' ], - [ 'accountcode' ], [ 'carrierid' ], + [ 'accountcode' ], [ 'carrierid' ], [ 'cdrid' ], [ 'freesidestatus' ], [ 'freesiderewritestatus' ], - [ 'cdrbatch' ], + [ 'cdrbatch' ], [ 'cdrbatchnum' ], ], }, + 'cdr_batch' => { + 'columns' => [ + 'cdrbatchnum', 'serial', '', '', '', '', + 'cdrbatch', 'varchar', 'NULL', 255, '', '', + '_date', @date_type, '', '', + ], + 'primary_key' => 'cdrbatchnum', + 'unique' => [ [ 'cdrbatch' ] ], + 'index' => [], + }, + 'cdr_termination' => { 'columns' => [ 'cdrtermnum', 'bigserial', '', '', '', '', @@ -2302,11 +2381,12 @@ sub tables_hashref { '_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' => { @@ -2374,10 +2454,15 @@ sub tables_hashref { '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', '', '', '', ], 'primary_key' => 'svcnum', 'unique' => [], - 'index' => [ [ 'countrycode', 'phonenum' ] ], + 'index' => [ ['countrycode', 'phonenum'], ['pbxsvc'], ['domsvc'], + ['locationnum'], + ], }, 'phone_device' => { @@ -2472,6 +2557,58 @@ sub tables_hashref { 'unique' => [ [ 'pkgnum', 'refnum' ] ], 'index' => [ [ 'pkgnum' ], [ 'refnum' ] ], }, + + 'svc_pbx' => { + 'columns' => [ + 'svcnum', 'int', '', '', '', '', + 'id', 'int', 'NULL', '', '', '', + 'title', 'varchar', 'NULL', $char_d, '', '', + 'max_extensions', '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', '', '', '', + 'email', 'varchar', 'NULL', 255, '', '', + ], + 'primary_key' => 'membernum', + 'unique' => [], + 'index' => [['listnum'],['svcnum'],['email']], + }, + + # name type nullability length default local #'new_table' => {