support for radius check attributes (except importing). poorly documented.
[freeside.git] / bin / fs-setup
1 #!/usr/bin/perl -Tw
2 #
3 # $Id: fs-setup,v 1.26 2000-07-06 08:57:27 ivan Exp $
4 #
5 # ivan@sisd.com 97-nov-8,9
6 #
7 # agent_type and type_pkgs added.
8 # (index need to be declared, & primary keys shoudln't have mysql syntax)
9 # ivan@sisd.com 97-nov-13
10 #
11 # pulled modified version back out of register.cgi ivan@sisd.com 98-feb-21
12 #
13 # removed extraneous sample data ivan@sisd.com 98-mar-23
14 #
15 # gained the big hash from dbdef.pm, dbdef.pm usage rewrite ivan@sisd.com
16 # 98-apr-19 - 98-may-11 plus
17 #
18 # finished up ivan@sisd.com 98-jun-1
19 #
20 # part_svc fields are all forced NULL, not the opposite
21 # hmm: also are forced varchar($char_d) as fixed '0' for things like
22 # uid is Not Good.  will this break anything else?
23 # ivan@sisd.com 98-jun-29
24 #
25 # ss is 11 chars ivan@sisd.com 98-jul-20
26 #
27 # setup of arbitrary radius fields ivan@sisd.com 98-aug-9
28 #
29 # ouch, removed index on company name that wasn't supposed to be there
30 # ivan@sisd.com 98-sep-4
31 #
32 # fix radius attributes ivan@sisd.com 98-sep-27
33 #
34 # $Log: fs-setup,v $
35 # Revision 1.26  2000-07-06 08:57:27  ivan
36 # support for radius check attributes (except importing).  poorly documented.
37 #
38 # Revision 1.25  2000/06/29 12:00:49  ivan
39 # support for pre-encrypted md5 passwords.
40 #
41 # Revision 1.24  2000/03/02 07:44:07  ivan
42 # typo forgot closing '
43 #
44 # Revision 1.23  2000/02/03 05:16:52  ivan
45 # beginning of DNS and Apache support
46 #
47 # Revision 1.22  2000/01/31 05:22:23  ivan
48 # prepaid "internet cards"
49 #
50 # Revision 1.21  2000/01/30 06:03:26  ivan
51 # postgres 6.5 finally supports decimal(10,2)
52 #
53 # Revision 1.20  2000/01/28 22:53:33  ivan
54 # track full phone number
55 #
56 # Revision 1.19  1999/07/29 08:50:35  ivan
57 # wrong type for cust_pay_batch.exp
58 #
59 # Revision 1.18  1999/04/15 22:46:30  ivan
60 # TT isn't a state!
61 #
62 # Revision 1.17  1999/04/14 07:58:39  ivan
63 # export getsecrets from FS::UID instead of calling it explicitly
64 #
65 # Revision 1.16  1999/02/28 19:44:16  ivan
66 # constructors s/create/new/ pointed out by "Bao C. Ha" <bao@hacom.net>
67 #
68 # Revision 1.15  1999/02/27 21:06:21  ivan
69 # cust_main.paydate should be varchar(10), not @date_type ; problem reported
70 # by Ben Leibig <leibig@colorado.edu>
71 #
72 # Revision 1.14  1999/02/07 09:59:14  ivan
73 # more mod_perl fixes, and bugfixes Peter Wemm sent via email
74 #
75 # Revision 1.13  1999/02/04 06:09:23  ivan
76 # add AU provences
77 #
78 # Revision 1.12  1999/02/03 10:42:27  ivan
79 # *** empty log message ***
80 #
81 # Revision 1.11  1999/01/17 03:11:52  ivan
82 # remove preliminary completehost changes
83 #
84 # Revision 1.10  1998/12/16 06:05:38  ivan
85 # add table cust_main_invoice
86 #
87 # Revision 1.9  1998/12/15 04:36:29  ivan
88 # s/croak/die/; #oops
89 #
90 # Revision 1.8  1998/12/15 04:33:27  ivan
91 # dies if it isn't running as the freeside user
92 #
93 # Revision 1.7  1998/11/18 09:01:31  ivan
94 # i18n! i18n!
95 #
96 # Revision 1.6  1998/11/15 13:18:02  ivan
97 # remove debugging
98 #
99 # Revision 1.5  1998/11/15 09:43:03  ivan
100 # update for new config file syntax, new adminsuidsetup
101 #
102 # Revision 1.4  1998/10/22 15:51:23  ivan
103 # also varchar with no length specified - postgresql fix broke mysql.
104 #
105 # Revision 1.3  1998/10/22 15:46:28  ivan
106 # now smallint is illegal, so remove that too.
107 #
108
109 #to delay loading dbdef until we're ready
110 BEGIN { $FS::Record::setup_hack = 1; }
111
112 use strict;
113 use DBI;
114 use FS::dbdef;
115 use FS::UID qw(adminsuidsetup datasrc checkeuid getsecrets);
116 use FS::Record;
117 use FS::cust_main_county;
118
119 die "Not running uid freeside!" unless checkeuid();
120
121 my $user = shift or die &usage;
122 getsecrets($user);
123
124 #needs to match FS::Record
125 my($dbdef_file) = "/usr/local/etc/freeside/dbdef.". datasrc;
126
127 ###
128
129 print "\nEnter the maximum username length: ";
130 my($username_len)=&getvalue;
131
132 print "\n\n", <<END, ":";
133 Freeside tracks the RADIUS attributes User-Name, check attribute Password and
134 reply attribute Framed-IP-Address for each user.  You can specify additional
135 check and reply attributes.  First enter any additional RADIUS check attributes
136 you need to track for each user, separated by whitespace.
137 END
138 my @check_attributes = map { s/\-/_/g; $_; } split(" ",&getvalue);
139
140 print "\n\n", <<END, ":";
141 Now enter any additional reply attributes you need to track for each user,
142 separated by whitespace.
143 END
144 my @attributes = map { s/\-/_/g; $_; } split(" ",&getvalue);
145
146 sub getvalue {
147   my($x)=scalar(<STDIN>);
148   chop $x;
149   $x;
150 }
151
152 ###
153
154 my($char_d) = 80; #default maxlength for text fields
155
156 #my(@date_type)  = ( 'timestamp', '', ''     );
157 my(@date_type)  = ( 'int', 'NULL', ''     );
158 my(@perl_type) = ( 'varchar', 'NULL', 255  ); 
159 my @money_type = ( 'decimal',   '', '10,2' );
160
161 ###
162 # create a dbdef object from the old data structure
163 ###
164
165 my(%tables)=&tables_hash_hack;
166
167 #turn it into objects
168 my($dbdef) = new FS::dbdef ( map {  
169   my(@columns);
170   while (@{$tables{$_}{'columns'}}) {
171     my($name,$type,$null,$length)=splice @{$tables{$_}{'columns'}}, 0, 4;
172     push @columns, new FS::dbdef_column ( $name,$type,$null,$length );
173   }
174   FS::dbdef_table->new(
175     $_,
176     $tables{$_}{'primary_key'},
177     #FS::dbdef_unique->new(@{$tables{$_}{'unique'}}),
178     #FS::dbdef_index->new(@{$tables{$_}{'index'}}),
179     FS::dbdef_unique->new($tables{$_}{'unique'}),
180     FS::dbdef_index->new($tables{$_}{'index'}),
181     @columns,
182   );
183 } (keys %tables) );
184
185 #add radius attributes to svc_acct
186
187 my($svc_acct)=$dbdef->table('svc_acct');
188
189 my($attribute);
190 foreach $attribute (@attributes) {
191   $svc_acct->addcolumn ( new FS::dbdef_column (
192     'radius_'. $attribute,
193     'varchar',
194     'NULL',
195     $char_d,
196   ));
197 }
198
199 foreach $attribute (@check_attributes) {
200   $svc_acct->addcolumn( new FS::dbdef_column (
201     'rc_'. $attribute,
202     'varchar',
203     'NULL',
204     $char_d,
205   ));
206 }
207
208 #make part_svc table (but now as object)
209
210 my($part_svc)=$dbdef->table('part_svc');
211
212 #because of svc_acct_pop
213 #foreach (grep /^svc_/, $dbdef->tables) { 
214 #foreach (qw(svc_acct svc_acct_sm svc_charge svc_domain svc_wo)) {
215 foreach (qw(svc_acct svc_acct_sm svc_domain svc_www)) {
216   my($table)=$dbdef->table($_);
217   my($col);
218   foreach $col ( $table->columns ) {
219     next if $col =~ /^svcnum$/;
220     $part_svc->addcolumn( new FS::dbdef_column (
221       $table->name. '__' . $table->column($col)->name,
222       'varchar', #$table->column($col)->type, 
223       'NULL',
224       $char_d, #$table->column($col)->length,
225     ));
226     $part_svc->addcolumn ( new FS::dbdef_column (
227       $table->name. '__'. $table->column($col)->name . "_flag",
228       'char',
229       'NULL',
230       1,
231     ));
232   }
233 }
234
235 #important
236 $dbdef->save($dbdef_file);
237 &FS::Record::reload_dbdef($dbdef_file);
238
239 ###
240 # create 'em
241 ###
242
243 my($dbh)=adminsuidsetup $user;
244
245 #create tables
246 $|=1;
247
248 my($table);
249 foreach  ($dbdef->tables) {
250   my($table)=$dbdef->table($_);
251   print "Creating $_...";
252
253   my($statement);
254
255   #create table
256   foreach $statement ($table->sql_create_table(datasrc)) {
257     #print $statement, "\n"; 
258     $dbh->do( $statement )
259       or die "CREATE error: ",$dbh->errstr, "\ndoing statement: $statement";
260   }
261
262   print "\n";
263 }
264
265 #not really sample data (and shouldn't default to US)
266
267 #cust_main_county
268
269 #USPS state codes
270 foreach ( qw(
271 AL AK AS AZ AR CA CO CT DC DE FM FL GA GU HI ID IL IN IA KS KY LA
272 ME MH MD MA MI MN MS MO MT NC ND NE NH NJ NM NV NY MP OH OK OR PA PW PR RI 
273 SC SD TN TX UT VT VI VA WA WV WI WY AE AA AP
274 ) ) {
275   my($cust_main_county)=new FS::cust_main_county({
276     'state' => $_,
277     'tax'   => 0,
278     'country' => 'US',
279   });  
280   my($error);
281   $error=$cust_main_county->insert;
282   die $error if $error;
283 }
284
285 #AU "offical" state codes ala mark.williamson@ebbs.com.au (Mark Williamson)
286 foreach ( qw(
287 VIC NSW NT QLD TAS ACT WA SA
288 ) ) {
289   my($cust_main_county)=new FS::cust_main_county({
290     'state' => $_,
291     'tax'   => 0,
292     'country' => 'AU',
293   });  
294   my($error);
295   $error=$cust_main_county->insert;
296   die $error if $error;
297 }
298
299 #ISO 2-letter country codes (same as country TLDs) except US and AU
300 foreach ( qw(
301 AF AL DZ AS AD AO AI AQ AG AR AM AW AT AZ BS BH BD BB BY BE BZ BJ BM BT BO
302 BA BW BV BR IO BN BG BF BI KH CM CA CV KY CF TD CL CN CX CC CO KM CG CK CR CI
303 HR CU CY CZ DK DJ DM DO TP EC EG SV GQ ER EE ET FK FO FJ FI FR FX GF PF TF GA
304 GM GE DE GH GI GR GL GD GP GU GT GN GW GY HT HM HN HK HU IS IN ID IR IQ IE IL
305 IT JM JP JO KZ KE KI KP KR KW KG LA LV LB LS LR LY LI LT LU MO MK MG MW MY MV
306 ML MT MH MQ MR MU YT MX FM MD MC MN MS MA MZ MM NA NR NP NL AN NC NZ NI NE NG
307 NU NF MP NO OM PK PW PA PG PY PE PH PN PL PT PR QA RE RO RU RW KN LC VC WS SM
308 ST SA SN SC SL SG SK SI SB SO ZA GS ES LK SH PM SD SR SJ SZ SE CH SY TW TJ TZ
309 TH TG TK TO TT TN TR TM TC TV UG UA AE GB UM UY UZ VU VA VE VN VG VI WF EH
310 YE YU ZR ZM ZW
311 ) ) {
312   my($cust_main_county)=new FS::cust_main_county({
313     'tax'   => 0,
314     'country' => $_,
315   });  
316   my($error);
317   $error=$cust_main_county->insert;
318   die $error if $error;
319 }
320
321 $dbh->disconnect or die $dbh->errstr;
322
323 sub usage {
324   die "Usage:\n  fs-setup user\n"; 
325 }
326
327 ###
328 # Now it becomes an object.  much better.
329 ###
330 sub tables_hash_hack {
331
332   #note that s/(date|change)/_$1/; to avoid keyword conflict.
333   #put a kludge in FS::Record to catch this or? (pry need some date-handling
334   #stuff anyway also)
335
336   my(%tables)=( #yech.}
337
338     'agent' => {
339       'columns' => [
340         'agentnum', 'int',            '',     '',
341         'agent',    'varchar',           '',     $char_d,
342         'typenum',  'int',            '',     '',
343         'freq',     'int',       'NULL', '',
344         'prog',     @perl_type,
345       ],
346       'primary_key' => 'agentnum',
347       'unique' => [ [] ],
348       'index' => [ ['typenum'] ],
349     },
350
351     'agent_type' => {
352       'columns' => [
353         'typenum',   'int',  '', '',
354         'atype',     'varchar', '', $char_d,
355       ],
356       'primary_key' => 'typenum',
357       'unique' => [ [] ],
358       'index' => [ [] ],
359     },
360
361     'type_pkgs' => {
362       'columns' => [
363         'typenum',   'int',  '', '',
364         'pkgpart',   'int',  '', '',
365       ],
366       'primary_key' => '',
367       'unique' => [ ['typenum', 'pkgpart'] ],
368       'index' => [ ['typenum'] ],
369     },
370
371     'cust_bill' => {
372       'columns' => [
373         'invnum',    'int',  '', '',
374         'custnum',   'int',  '', '',
375         '_date',     @date_type,
376         'charged',   @money_type,
377         'owed',      @money_type,
378         'printed',   'int',  '', '',
379       ],
380       'primary_key' => 'invnum',
381       'unique' => [ [] ],
382       'index' => [ ['custnum'] ],
383     },
384
385     'cust_bill_pkg' => {
386       'columns' => [
387         'pkgnum',  'int', '', '',
388         'invnum',  'int', '', '',
389         'setup',   @money_type,
390         'recur',   @money_type,
391         'sdate',   @date_type,
392         'edate',   @date_type,
393       ],
394       'primary_key' => '',
395       'unique' => [ ['pkgnum', 'invnum'] ],
396       'index' => [ ['invnum'] ],
397     },
398
399     'cust_credit' => {
400       'columns' => [
401         'crednum',  'int', '', '',
402         'custnum',  'int', '', '',
403         '_date',    @date_type,
404         'amount',   @money_type,
405         'credited', @money_type,
406         'otaker',   'varchar', '', 8,
407         'reason',   'varchar', '', 255,
408       ],
409       'primary_key' => 'crednum',
410       'unique' => [ [] ],
411       'index' => [ ['custnum'] ],
412     },
413
414     'cust_main' => {
415       'columns' => [
416         'custnum',  'int',  '',     '',
417         'agentnum', 'int',  '',     '',
418 #        'titlenum', 'int',  'NULL',   '',
419         'last',     'varchar', '',     $char_d,
420 #        'middle',   'varchar', 'NULL', $char_d,
421         'first',    'varchar', '',     $char_d,
422         'ss',       'char', 'NULL', 11,
423         'company',  'varchar', 'NULL', $char_d,
424         'address1', 'varchar', '',     $char_d,
425         'address2', 'varchar', 'NULL', $char_d,
426         'city',     'varchar', '',     $char_d,
427         'county',   'varchar', 'NULL', $char_d,
428         'state',    'varchar', 'NULL', $char_d,
429         'zip',      'varchar', '',     10,
430         'country',  'char', '',     2,
431         'daytime',  'varchar', 'NULL', 20,
432         'night',    'varchar', 'NULL', 20,
433         'fax',      'varchar', 'NULL', 12,
434         'payby',    'char', '',     4,
435         'payinfo',  'varchar', 'NULL', 16,
436         #'paydate',  @date_type,
437         'paydate',  'varchar', 'NULL', 10,
438         'payname',  'varchar', 'NULL', $char_d,
439         'tax',      'char', 'NULL', 1,
440         'otaker',   'varchar', '',     8,
441         'refnum',   'int',  '',     '',
442       ],
443       'primary_key' => 'custnum',
444       'unique' => [ [] ],
445       #'index' => [ ['last'], ['company'] ],
446       'index' => [ ['last'], ],
447     },
448
449     'cust_main_invoice' => {
450       'columns' => [
451         'destnum',  'int',  '',     '',
452         'custnum',  'int',  '',     '',
453         'dest',     'varchar', '',  $char_d,
454       ],
455       'primary_key' => 'destnum',
456       'unique' => [ [] ],
457       'index' => [ ['custnum'], ],
458     },
459
460     'cust_main_county' => { #county+state+country are checked off the
461                             #cust_main_county for validation and to provide
462                             # a tax rate.
463       'columns' => [
464         'taxnum',   'int',   '',    '',
465         'state',    'varchar',  'NULL',    $char_d,
466         'county',   'varchar',  'NULL',    $char_d,
467         'country',  'char',  '', 2, 
468         'tax',      'real',  '',    '', #tax %
469       ],
470       'primary_key' => 'taxnum',
471       'unique' => [ [] ],
472   #    'unique' => [ ['taxnum'], ['state', 'county'] ],
473       'index' => [ [] ],
474     },
475
476     'cust_pay' => {
477       'columns' => [
478         'paynum',   'int',    '',   '',
479         'invnum',   'int',    '',   '',
480         'paid',     @money_type,
481         '_date',    @date_type,
482         'payby',    'char',   '',     4, # CARD/BILL/COMP, should be index into
483                                          # payment type table.
484         'payinfo',  'varchar',   'NULL', 16,  #see cust_main above
485         'paybatch', 'varchar',   'NULL', $char_d, #for auditing purposes.
486       ],
487       'primary_key' => 'paynum',
488       'unique' => [ [] ],
489       'index' => [ ['invnum'] ],
490     },
491
492     'cust_pay_batch' => { #what's this used for again?  list of customers
493                           #in current CARD batch? (necessarily CARD?)
494       'columns' => [
495         'invnum',   'int',    '',   '',
496         'custnum',   'int',    '',   '',
497         'last',     'varchar', '',     $char_d,
498         'first',    'varchar', '',     $char_d,
499         'address1', 'varchar', '',     $char_d,
500         'address2', 'varchar', 'NULL', $char_d,
501         'city',     'varchar', '',     $char_d,
502         'state',    'varchar', '',     $char_d,
503         'zip',      'varchar', '',     10,
504         'country',  'char', '',     2,
505         'trancode', 'int', '', '',
506         'cardnum',  'varchar', '',     16,
507         #'exp',      @date_type,
508         'exp',      'varchar', '',     11,
509         'payname',  'varchar', 'NULL', $char_d,
510         'amount',   @money_type,
511       ],
512       'primary_key' => '',
513       'unique' => [ [] ],
514       'index' => [ ['invnum'], ['custnum'] ],
515     },
516
517     'cust_pkg' => {
518       'columns' => [
519         'pkgnum',    'int',    '',   '',
520         'custnum',   'int',    '',   '',
521         'pkgpart',   'int',    '',   '',
522         'otaker',    'varchar', '', 8,
523         'setup',     @date_type,
524         'bill',      @date_type,
525         'susp',      @date_type,
526         'cancel',    @date_type,
527         'expire',    @date_type,
528       ],
529       'primary_key' => 'pkgnum',
530       'unique' => [ [] ],
531       'index' => [ ['custnum'] ],
532     },
533
534     'cust_refund' => {
535       'columns' => [
536         'refundnum',    'int',    '',   '',
537         'crednum',      'int',    '',   '',
538         '_date',        @date_type,
539         'refund',       @money_type,
540         'otaker',       'varchar',   '',   8,
541         'reason',       'varchar',   '',   $char_d,
542         'payby',        'char',   '',     4, # CARD/BILL/COMP, should be index
543                                              # into payment type table.
544         'payinfo',      'varchar',   'NULL', 16,  #see cust_main above
545       ],
546       'primary_key' => 'refundnum',
547       'unique' => [ [] ],
548       'index' => [ ['crednum'] ],
549     },
550
551     'cust_svc' => {
552       'columns' => [
553         'svcnum',    'int',    '',   '',
554         'pkgnum',    'int',    '',   '',
555         'svcpart',   'int',    '',   '',
556       ],
557       'primary_key' => 'svcnum',
558       'unique' => [ [] ],
559       'index' => [ ['svcnum'], ['pkgnum'], ['svcpart'] ],
560     },
561
562     'part_pkg' => {
563       'columns' => [
564         'pkgpart',    'int',    '',   '',
565         'pkg',        'varchar',   '',   $char_d,
566         'comment',    'varchar',   '',   $char_d,
567         'setup',      @perl_type,
568         'freq',       'int', '', '',  #billing frequency (months)
569         'recur',      @perl_type,
570       ],
571       'primary_key' => 'pkgpart',
572       'unique' => [ [] ],
573       'index' => [ [] ],
574     },
575
576 #    'part_title' => {
577 #      'columns' => [
578 #        'titlenum',   'int',    '',   '',
579 #        'title',      'varchar',   '',   $char_d,
580 #      ],
581 #      'primary_key' => 'titlenum',
582 #      'unique' => [ [] ],
583 #      'index' => [ [] ],
584 #    },
585
586     'pkg_svc' => {
587       'columns' => [
588         'pkgpart',    'int',    '',   '',
589         'svcpart',    'int',    '',   '',
590         'quantity',   'int',    '',   '',
591       ],
592       'primary_key' => '',
593       'unique' => [ ['pkgpart', 'svcpart'] ],
594       'index' => [ ['pkgpart'] ],
595     },
596
597     'part_referral' => {
598       'columns' => [
599         'refnum',   'int',    '',   '',
600         'referral', 'varchar',   '',   $char_d,
601       ],
602       'primary_key' => 'refnum',
603       'unique' => [ [] ],
604       'index' => [ [] ],
605     },
606
607     'part_svc' => {
608       'columns' => [
609         'svcpart',    'int',    '',   '',
610         'svc',        'varchar',   '',   $char_d,
611         'svcdb',      'varchar',   '',   $char_d,
612       ],
613       'primary_key' => 'svcpart',
614       'unique' => [ [] ],
615       'index' => [ [] ],
616     },
617
618     #(this should be renamed to part_pop)
619     'svc_acct_pop' => {
620       'columns' => [
621         'popnum',    'int',    '',   '',
622         'city',      'varchar',   '',   $char_d,
623         'state',     'varchar',   '',   $char_d,
624         'ac',        'char',   '',   3,
625         'exch',      'char',   '',   3,
626         'loc',       'char',   'NULL',   4, #NULL for legacy purposes
627       ],
628       'primary_key' => 'popnum',
629       'unique' => [ [] ],
630       'index' => [ [] ],
631     },
632
633     'svc_acct' => {
634       'columns' => [
635         'svcnum',    'int',    '',   '',
636         'username',  'varchar',   '',   $username_len, #unique (& remove dup code)
637         '_password', 'varchar',   '',   50, #13 for encryped pw's plus ' *SUSPENDED* (mp5 passwords can be 34)
638         'popnum',    'int',    'NULL',   '',
639         'uid',       'int', 'NULL',   '',
640         'gid',       'int', 'NULL',   '',
641         'finger',    'varchar',   'NULL',   $char_d,
642         'dir',       'varchar',   'NULL',   $char_d,
643         'shell',     'varchar',   'NULL',   $char_d,
644         'quota',     'varchar',   'NULL',   $char_d,
645         'slipip',    'varchar',   'NULL',   15, #four TINYINTs, bah.
646       ],
647       'primary_key' => 'svcnum',
648       'unique' => [ [] ],
649       'index' => [ ['username'] ],
650     },
651
652     'svc_acct_sm' => {
653       'columns' => [
654         'svcnum',    'int',    '',   '',
655         'domsvc',    'int',    '',   '',
656         'domuid',    'int', '',   '',
657         'domuser',   'varchar',   '',   $char_d,
658       ],
659       'primary_key' => 'svcnum',
660       'unique' => [ [] ],
661       'index' => [ ['domsvc'], ['domuid'] ], 
662     },
663
664     #'svc_charge' => {
665     #  'columns' => [
666     #    'svcnum',    'int',    '',   '',
667     #    'amount',    @money_type,
668     #  ],
669     #  'primary_key' => 'svcnum',
670     #  'unique' => [ [] ],
671     #  'index' => [ [] ],
672     #},
673
674     'svc_domain' => {
675       'columns' => [
676         'svcnum',    'int',    '',   '',
677         'domain',    'varchar',    '',   $char_d,
678       ],
679       'primary_key' => 'svcnum',
680       'unique' => [ ['domain'] ],
681       'index' => [ [] ],
682     },
683
684     'domain_record' => {
685       'columns' => [
686         'recnum',    'int',     '',  '',
687         'svcnum',    'int',     '',  '',
688         'reczone',   'varchar', '',  $char_d,
689         'recaf',     'char',    '',  2,
690         'rectype',   'char',    '',  5,
691         'recdata',   'varchar', '',  $char_d,
692       ],
693       'primary_key' => 'recnum',
694       'unique'      => [ [] ],
695       'index'       => [ ['svcnum'] ],
696     },
697
698     'svc_www' => {
699       'columns' => [
700         'svcnum',   'int',    '',  '',
701         'recnum',   'int',    '',  '',
702         'usersvc',  'int',    '',  '',
703       ],
704       'primary_key' => 'svcnum',
705       'unique'      => [ [] ],
706       'index'       => [ [] ],
707     },
708
709     #'svc_wo' => {
710     #  'columns' => [
711     #    'svcnum',    'int',    '',   '',
712     #    'svcnum',    'int',    '',   '',
713     #    'svcnum',    'int',    '',   '',
714     #    'worker',    'varchar',   '',   $char_d,
715     #    '_date',     @date_type,
716     #  ],
717     #  'primary_key' => 'svcnum',
718     #  'unique' => [ [] ],
719     #  'index' => [ [] ],
720     #},
721
722     'prepay_credit' => {
723       'columns' => [
724         'prepaynum',   'int',     '',   '',
725         'identifier',  'varchar', '', $char_d,
726         'amount',      @money_type,
727       ],
728       'primary_key' => 'prepaynum',
729       'unique'      => [ ['identifier'] ],
730       'index'       => [ [] ],
731     },
732
733   );
734
735   %tables;
736
737 }
738