beginning of DNS and Apache support
[freeside.git] / bin / fs-setup
1 #!/usr/bin/perl -Tw
2 #
3 # $Id: fs-setup,v 1.23 2000-02-03 05:16:52 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.23  2000-02-03 05:16:52  ivan
36 # beginning of DNS and Apache support
37 #
38 # Revision 1.22  2000/01/31 05:22:23  ivan
39 # prepaid "internet cards"
40 #
41 # Revision 1.21  2000/01/30 06:03:26  ivan
42 # postgres 6.5 finally supports decimal(10,2)
43 #
44 # Revision 1.20  2000/01/28 22:53:33  ivan
45 # track full phone number
46 #
47 # Revision 1.19  1999/07/29 08:50:35  ivan
48 # wrong type for cust_pay_batch.exp
49 #
50 # Revision 1.18  1999/04/15 22:46:30  ivan
51 # TT isn't a state!
52 #
53 # Revision 1.17  1999/04/14 07:58:39  ivan
54 # export getsecrets from FS::UID instead of calling it explicitly
55 #
56 # Revision 1.16  1999/02/28 19:44:16  ivan
57 # constructors s/create/new/ pointed out by "Bao C. Ha" <bao@hacom.net>
58 #
59 # Revision 1.15  1999/02/27 21:06:21  ivan
60 # cust_main.paydate should be varchar(10), not @date_type ; problem reported
61 # by Ben Leibig <leibig@colorado.edu>
62 #
63 # Revision 1.14  1999/02/07 09:59:14  ivan
64 # more mod_perl fixes, and bugfixes Peter Wemm sent via email
65 #
66 # Revision 1.13  1999/02/04 06:09:23  ivan
67 # add AU provences
68 #
69 # Revision 1.12  1999/02/03 10:42:27  ivan
70 # *** empty log message ***
71 #
72 # Revision 1.11  1999/01/17 03:11:52  ivan
73 # remove preliminary completehost changes
74 #
75 # Revision 1.10  1998/12/16 06:05:38  ivan
76 # add table cust_main_invoice
77 #
78 # Revision 1.9  1998/12/15 04:36:29  ivan
79 # s/croak/die/; #oops
80 #
81 # Revision 1.8  1998/12/15 04:33:27  ivan
82 # dies if it isn't running as the freeside user
83 #
84 # Revision 1.7  1998/11/18 09:01:31  ivan
85 # i18n! i18n!
86 #
87 # Revision 1.6  1998/11/15 13:18:02  ivan
88 # remove debugging
89 #
90 # Revision 1.5  1998/11/15 09:43:03  ivan
91 # update for new config file syntax, new adminsuidsetup
92 #
93 # Revision 1.4  1998/10/22 15:51:23  ivan
94 # also varchar with no length specified - postgresql fix broke mysql.
95 #
96 # Revision 1.3  1998/10/22 15:46:28  ivan
97 # now smallint is illegal, so remove that too.
98 #
99
100 #to delay loading dbdef until we're ready
101 BEGIN { $FS::Record::setup_hack = 1; }
102
103 use strict;
104 use DBI;
105 use FS::dbdef;
106 use FS::UID qw(adminsuidsetup datasrc checkeuid getsecrets);
107 use FS::Record;
108 use FS::cust_main_county;
109
110 die "Not running uid freeside!" unless checkeuid();
111
112 my $user = shift or die &usage;
113 getsecrets($user);
114
115 #needs to match FS::Record
116 my($dbdef_file) = "/usr/local/etc/freeside/dbdef.". datasrc;
117
118 ###
119
120 print "\nEnter the maximum username length: ";
121 my($username_len)=&getvalue;
122
123 print "\n\n", <<END, ":";
124 Freeside tracks the RADIUS attributes User-Name, Password and Framed-IP-Address
125 for each user.  Enter any additional RADIUS attributes you need to track for
126 each user, separated by whitespace.
127 END
128 my @attributes = map { s/\-/_/g; $_; } split(" ",&getvalue);
129
130 sub getvalue {
131   my($x)=scalar(<STDIN>);
132   chop $x;
133   $x;
134 }
135
136 ###
137
138 my($char_d) = 80; #default maxlength for text fields
139
140 #my(@date_type)  = ( 'timestamp', '', ''     );
141 my(@date_type)  = ( 'int', 'NULL', ''     );
142 my(@perl_type) = ( 'varchar', 'NULL', 255  ); 
143 my @money_type = ( 'decimal',   '', '10,2' );
144
145 ###
146 # create a dbdef object from the old data structure
147 ###
148
149 my(%tables)=&tables_hash_hack;
150
151 #turn it into objects
152 my($dbdef) = new FS::dbdef ( map {  
153   my(@columns);
154   while (@{$tables{$_}{'columns'}}) {
155     my($name,$type,$null,$length)=splice @{$tables{$_}{'columns'}}, 0, 4;
156     push @columns, new FS::dbdef_column ( $name,$type,$null,$length );
157   }
158   FS::dbdef_table->new(
159     $_,
160     $tables{$_}{'primary_key'},
161     #FS::dbdef_unique->new(@{$tables{$_}{'unique'}}),
162     #FS::dbdef_index->new(@{$tables{$_}{'index'}}),
163     FS::dbdef_unique->new($tables{$_}{'unique'}),
164     FS::dbdef_index->new($tables{$_}{'index'}),
165     @columns,
166   );
167 } (keys %tables) );
168
169 #add radius attributes to svc_acct
170
171 my($svc_acct)=$dbdef->table('svc_acct');
172
173 my($attribute);
174 foreach $attribute (@attributes) {
175   $svc_acct->addcolumn ( new FS::dbdef_column (
176     'radius_'. $attribute,
177     'varchar',
178     'NULL',
179     $char_d,
180   ));
181 }
182
183 #make part_svc table (but now as object)
184
185 my($part_svc)=$dbdef->table('part_svc');
186
187 #because of svc_acct_pop
188 #foreach (grep /^svc_/, $dbdef->tables) { 
189 #foreach (qw(svc_acct svc_acct_sm svc_charge svc_domain svc_wo)) {
190 foreach (qw(svc_acct svc_acct_sm svc_domain svc_www)) {
191   my($table)=$dbdef->table($_);
192   my($col);
193   foreach $col ( $table->columns ) {
194     next if $col =~ /^svcnum$/;
195     $part_svc->addcolumn( new FS::dbdef_column (
196       $table->name. '__' . $table->column($col)->name,
197       'varchar', #$table->column($col)->type, 
198       'NULL',
199       $char_d, #$table->column($col)->length,
200     ));
201     $part_svc->addcolumn ( new FS::dbdef_column (
202       $table->name. '__'. $table->column($col)->name . "_flag",
203       'char',
204       'NULL',
205       1,
206     ));
207   }
208 }
209
210 #important
211 $dbdef->save($dbdef_file);
212 &FS::Record::reload_dbdef($dbdef_file);
213
214 ###
215 # create 'em
216 ###
217
218 my($dbh)=adminsuidsetup $user;
219
220 #create tables
221 $|=1;
222
223 my($table);
224 foreach  ($dbdef->tables) {
225   my($table)=$dbdef->table($_);
226   print "Creating $_...";
227
228   my($statement);
229
230   #create table
231   foreach $statement ($table->sql_create_table(datasrc)) {
232     #print $statement, "\n"; 
233     $dbh->do( $statement )
234       or die "CREATE error: ",$dbh->errstr, "\ndoing statement: $statement";
235   }
236
237   print "\n";
238 }
239
240 #not really sample data (and shouldn't default to US)
241
242 #cust_main_county
243
244 #USPS state codes
245 foreach ( qw(
246 AL AK AS AZ AR CA CO CT DC DE FM FL GA GU HI ID IL IN IA KS KY LA
247 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 
248 SC SD TN TX UT VT VI VA WA WV WI WY AE AA AP
249 ) ) {
250   my($cust_main_county)=new FS::cust_main_county({
251     'state' => $_,
252     'tax'   => 0,
253     'country' => 'US',
254   });  
255   my($error);
256   $error=$cust_main_county->insert;
257   die $error if $error;
258 }
259
260 #AU "offical" state codes ala mark.williamson@ebbs.com.au (Mark Williamson)
261 foreach ( qw(
262 VIC NSW NT QLD TAS ACT WA SA
263 ) ) {
264   my($cust_main_county)=new FS::cust_main_county({
265     'state' => $_,
266     'tax'   => 0,
267     'country' => 'AU',
268   });  
269   my($error);
270   $error=$cust_main_county->insert;
271   die $error if $error;
272 }
273
274 #ISO 2-letter country codes (same as country TLDs) except US and AU
275 foreach ( qw(
276 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
277 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
278 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
279 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
280 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
281 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
282 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
283 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
284 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
285 YE YU ZR ZM ZW
286 ) ) {
287   my($cust_main_county)=new FS::cust_main_county({
288     'tax'   => 0,
289     'country' => $_,
290   });  
291   my($error);
292   $error=$cust_main_county->insert;
293   die $error if $error;
294 }
295
296 $dbh->disconnect or die $dbh->errstr;
297
298 sub usage {
299   die "Usage:\n  fs-setup user\n"; 
300 }
301
302 ###
303 # Now it becomes an object.  much better.
304 ###
305 sub tables_hash_hack {
306
307   #note that s/(date|change)/_$1/; to avoid keyword conflict.
308   #put a kludge in FS::Record to catch this or? (pry need some date-handling
309   #stuff anyway also)
310
311   my(%tables)=( #yech.}
312
313     'agent' => {
314       'columns' => [
315         'agentnum', 'int',            '',     '',
316         'agent',    'varchar',           '',     $char_d,
317         'typenum',  'int',            '',     '',
318         'freq',     'int',       'NULL', '',
319         'prog',     @perl_type,
320       ],
321       'primary_key' => 'agentnum',
322       'unique' => [ [] ],
323       'index' => [ ['typenum'] ],
324     },
325
326     'agent_type' => {
327       'columns' => [
328         'typenum',   'int',  '', '',
329         'atype',     'varchar', '', $char_d,
330       ],
331       'primary_key' => 'typenum',
332       'unique' => [ [] ],
333       'index' => [ [] ],
334     },
335
336     'type_pkgs' => {
337       'columns' => [
338         'typenum',   'int',  '', '',
339         'pkgpart',   'int',  '', '',
340       ],
341       'primary_key' => '',
342       'unique' => [ ['typenum', 'pkgpart'] ],
343       'index' => [ ['typenum'] ],
344     },
345
346     'cust_bill' => {
347       'columns' => [
348         'invnum',    'int',  '', '',
349         'custnum',   'int',  '', '',
350         '_date',     @date_type,
351         'charged',   @money_type,
352         'owed',      @money_type,
353         'printed',   'int',  '', '',
354       ],
355       'primary_key' => 'invnum',
356       'unique' => [ [] ],
357       'index' => [ ['custnum'] ],
358     },
359
360     'cust_bill_pkg' => {
361       'columns' => [
362         'pkgnum',  'int', '', '',
363         'invnum',  'int', '', '',
364         'setup',   @money_type,
365         'recur',   @money_type,
366         'sdate',   @date_type,
367         'edate',   @date_type,
368       ],
369       'primary_key' => '',
370       'unique' => [ ['pkgnum', 'invnum'] ],
371       'index' => [ ['invnum'] ],
372     },
373
374     'cust_credit' => {
375       'columns' => [
376         'crednum',  'int', '', '',
377         'custnum',  'int', '', '',
378         '_date',    @date_type,
379         'amount',   @money_type,
380         'credited', @money_type,
381         'otaker',   'varchar', '', 8,
382         'reason',   'varchar', '', 255,
383       ],
384       'primary_key' => 'crednum',
385       'unique' => [ [] ],
386       'index' => [ ['custnum'] ],
387     },
388
389     'cust_main' => {
390       'columns' => [
391         'custnum',  'int',  '',     '',
392         'agentnum', 'int',  '',     '',
393 #        'titlenum', 'int',  'NULL',   '',
394         'last',     'varchar', '',     $char_d,
395 #        'middle',   'varchar', 'NULL', $char_d,
396         'first',    'varchar', '',     $char_d,
397         'ss',       'char', 'NULL', 11,
398         'company',  'varchar', 'NULL', $char_d,
399         'address1', 'varchar', '',     $char_d,
400         'address2', 'varchar', 'NULL', $char_d,
401         'city',     'varchar', '',     $char_d,
402         'county',   'varchar', 'NULL', $char_d,
403         'state',    'varchar', 'NULL', $char_d,
404         'zip',      'varchar', '',     10,
405         'country',  'char', '',     2,
406         'daytime',  'varchar', 'NULL', 20,
407         'night',    'varchar', 'NULL', 20,
408         'fax',      'varchar', 'NULL', 12,
409         'payby',    'char', '',     4,
410         'payinfo',  'varchar', 'NULL', 16,
411         #'paydate',  @date_type,
412         'paydate',  'varchar', 'NULL', 10,
413         'payname',  'varchar', 'NULL', $char_d,
414         'tax',      'char', 'NULL', 1,
415         'otaker',   'varchar', '',     8,
416         'refnum',   'int',  '',     '',
417       ],
418       'primary_key' => 'custnum',
419       'unique' => [ [] ],
420       #'index' => [ ['last'], ['company'] ],
421       'index' => [ ['last'], ],
422     },
423
424     'cust_main_invoice' => {
425       'columns' => [
426         'destnum',  'int',  '',     '',
427         'custnum',  'int',  '',     '',
428         'dest',     'varchar', '',  $char_d,
429       ],
430       'primary_key' => 'destnum',
431       'unique' => [ [] ],
432       'index' => [ ['custnum'], ],
433     },
434
435     'cust_main_county' => { #county+state+country are checked off the
436                             #cust_main_county for validation and to provide
437                             # a tax rate.
438       'columns' => [
439         'taxnum',   'int',   '',    '',
440         'state',    'varchar',  'NULL',    $char_d,
441         'county',   'varchar',  'NULL',    $char_d,
442         'country',  'char',  '', 2, 
443         'tax',      'real',  '',    '', #tax %
444       ],
445       'primary_key' => 'taxnum',
446       'unique' => [ [] ],
447   #    'unique' => [ ['taxnum'], ['state', 'county'] ],
448       'index' => [ [] ],
449     },
450
451     'cust_pay' => {
452       'columns' => [
453         'paynum',   'int',    '',   '',
454         'invnum',   'int',    '',   '',
455         'paid',     @money_type,
456         '_date',    @date_type,
457         'payby',    'char',   '',     4, # CARD/BILL/COMP, should be index into
458                                          # payment type table.
459         'payinfo',  'varchar',   'NULL', 16,  #see cust_main above
460         'paybatch', 'varchar',   'NULL', $char_d, #for auditing purposes.
461       ],
462       'primary_key' => 'paynum',
463       'unique' => [ [] ],
464       'index' => [ ['invnum'] ],
465     },
466
467     'cust_pay_batch' => { #what's this used for again?  list of customers
468                           #in current CARD batch? (necessarily CARD?)
469       'columns' => [
470         'invnum',   'int',    '',   '',
471         'custnum',   'int',    '',   '',
472         'last',     'varchar', '',     $char_d,
473         'first',    'varchar', '',     $char_d,
474         'address1', 'varchar', '',     $char_d,
475         'address2', 'varchar', 'NULL', $char_d,
476         'city',     'varchar', '',     $char_d,
477         'state',    'varchar', '',     $char_d,
478         'zip',      'varchar', '',     10,
479         'country',  'char', '',     2,
480         'trancode', 'int', '', '',
481         'cardnum',  'varchar', '',     16,
482         #'exp',      @date_type,
483         'exp',      'varchar', '',     11,
484         'payname',  'varchar', 'NULL', $char_d,
485         'amount',   @money_type,
486       ],
487       'primary_key' => '',
488       'unique' => [ [] ],
489       'index' => [ ['invnum'], ['custnum'] ],
490     },
491
492     'cust_pkg' => {
493       'columns' => [
494         'pkgnum',    'int',    '',   '',
495         'custnum',   'int',    '',   '',
496         'pkgpart',   'int',    '',   '',
497         'otaker',    'varchar', '', 8,
498         'setup',     @date_type,
499         'bill',      @date_type,
500         'susp',      @date_type,
501         'cancel',    @date_type,
502         'expire',    @date_type,
503       ],
504       'primary_key' => 'pkgnum',
505       'unique' => [ [] ],
506       'index' => [ ['custnum'] ],
507     },
508
509     'cust_refund' => {
510       'columns' => [
511         'refundnum',    'int',    '',   '',
512         'crednum',      'int',    '',   '',
513         '_date',        @date_type,
514         'refund',       @money_type,
515         'otaker',       'varchar',   '',   8,
516         'reason',       'varchar',   '',   $char_d,
517         'payby',        'char',   '',     4, # CARD/BILL/COMP, should be index
518                                              # into payment type table.
519         'payinfo',      'varchar',   'NULL', 16,  #see cust_main above
520       ],
521       'primary_key' => 'refundnum',
522       'unique' => [ [] ],
523       'index' => [ ['crednum'] ],
524     },
525
526     'cust_svc' => {
527       'columns' => [
528         'svcnum',    'int',    '',   '',
529         'pkgnum',    'int',    '',   '',
530         'svcpart',   'int',    '',   '',
531       ],
532       'primary_key' => 'svcnum',
533       'unique' => [ [] ],
534       'index' => [ ['svcnum'], ['pkgnum'], ['svcpart'] ],
535     },
536
537     'part_pkg' => {
538       'columns' => [
539         'pkgpart',    'int',    '',   '',
540         'pkg',        'varchar',   '',   $char_d,
541         'comment',    'varchar',   '',   $char_d,
542         'setup',      @perl_type,
543         'freq',       'int', '', '',  #billing frequency (months)
544         'recur',      @perl_type,
545       ],
546       'primary_key' => 'pkgpart',
547       'unique' => [ [] ],
548       'index' => [ [] ],
549     },
550
551 #    'part_title' => {
552 #      'columns' => [
553 #        'titlenum',   'int',    '',   '',
554 #        'title',      'varchar',   '',   $char_d,
555 #      ],
556 #      'primary_key' => 'titlenum',
557 #      'unique' => [ [] ],
558 #      'index' => [ [] ],
559 #    },
560
561     'pkg_svc' => {
562       'columns' => [
563         'pkgpart',    'int',    '',   '',
564         'svcpart',    'int',    '',   '',
565         'quantity',   'int',    '',   '',
566       ],
567       'primary_key' => '',
568       'unique' => [ ['pkgpart', 'svcpart'] ],
569       'index' => [ ['pkgpart'] ],
570     },
571
572     'part_referral' => {
573       'columns' => [
574         'refnum',   'int',    '',   '',
575         'referral', 'varchar',   '',   $char_d,
576       ],
577       'primary_key' => 'refnum',
578       'unique' => [ [] ],
579       'index' => [ [] ],
580     },
581
582     'part_svc' => {
583       'columns' => [
584         'svcpart',    'int',    '',   '',
585         'svc',        'varchar',   '',   $char_d,
586         'svcdb',      'varchar',   '',   $char_d,
587       ],
588       'primary_key' => 'svcpart',
589       'unique' => [ [] ],
590       'index' => [ [] ],
591     },
592
593     #(this should be renamed to part_pop)
594     'svc_acct_pop' => {
595       'columns' => [
596         'popnum',    'int',    '',   '',
597         'city',      'varchar',   '',   $char_d,
598         'state',     'varchar',   '',   $char_d,
599         'ac',        'char',   '',   3,
600         'exch',      'char',   '',   3,
601         'loc',       'char',   'NULL',   4, #NULL for legacy purposes
602       ],
603       'primary_key' => 'popnum',
604       'unique' => [ [] ],
605       'index' => [ [] ],
606     },
607
608     'svc_acct' => {
609       'columns' => [
610         'svcnum',    'int',    '',   '',
611         'username',  'varchar',   '',   $username_len, #unique (& remove dup code)
612         '_password', 'varchar',   '',   25, #13 for encryped pw's plus ' *SUSPENDED*
613         'popnum',    'int',    'NULL',   '',
614         'uid',       'int', 'NULL',   '',
615         'gid',       'int', 'NULL',   '',
616         'finger',    'varchar',   'NULL',   $char_d,
617         'dir',       'varchar',   'NULL',   $char_d,
618         'shell',     'varchar',   'NULL',   $char_d,
619         'quota',     'varchar',   'NULL',   $char_d,
620         'slipip',    'varchar',   'NULL',   15, #four TINYINTs, bah.
621       ],
622       'primary_key' => 'svcnum',
623       'unique' => [ [] ],
624       'index' => [ ['username'] ],
625     },
626
627     'svc_acct_sm' => {
628       'columns' => [
629         'svcnum',    'int',    '',   '',
630         'domsvc',    'int',    '',   '',
631         'domuid',    'int', '',   '',
632         'domuser',   'varchar',   '',   $char_d,
633       ],
634       'primary_key' => 'svcnum',
635       'unique' => [ [] ],
636       'index' => [ ['domsvc'], ['domuid'] ], 
637     },
638
639     #'svc_charge' => {
640     #  'columns' => [
641     #    'svcnum',    'int',    '',   '',
642     #    'amount',    @money_type,
643     #  ],
644     #  'primary_key' => 'svcnum',
645     #  'unique' => [ [] ],
646     #  'index' => [ [] ],
647     #},
648
649     'svc_domain' => {
650       'columns' => [
651         'svcnum',    'int',    '',   '',
652         'domain',    'varchar',    '',   $char_d,
653       ],
654       'primary_key' => 'svcnum',
655       'unique' => [ ['domain'] ],
656       'index' => [ [] ],
657     },
658
659     'domain_record' => {
660       'columns' => [
661         'recnum',    'int',     '',  '',
662         'svcnum',    'int',     '',  '',
663         'reczone',   'varchar', '',  $char_d,
664         'recaf',     'char',    '',  2,
665         'rectype',   'char',    '',  5,
666         'recdata',   'varchar', '',  $char_d,
667       ],
668       'primary_key' => 'recnum',
669       'unique'      => [ [] ],
670       'index'       => [ ['svcnum'] ],
671     },
672
673     'svc_www' => {
674       'columns' => [
675         'svcnum',   'int',    '',  '',
676         'recnum',   'int',    '',  '',
677         'usersvc',  'int',    '',  '',
678       ],
679       'primary_key' => 'svcnum',
680       'unique'      => [ [] ],
681       'index'       => [ [] ],
682     },
683
684     #'svc_wo' => {
685     #  'columns' => [
686     #    'svcnum',    'int',    '',   '',
687     #    'svcnum',    'int',    '',   '',
688     #    'svcnum',    'int',    '',   '',
689     #    'worker',    'varchar',   '',   $char_d,
690     #    '_date',     @date_type,
691     #  ],
692     #  'primary_key' => 'svcnum',
693     #  'unique' => [ [] ],
694     #  'index' => [ [] ],
695     #},
696
697     'prepay_credit' => {
698       'columns' => [
699         'prepaynum',   'int',     '',   '',
700         'identifier',  'varchar', '', $char_d,
701         'amount',      @money_type,
702       ],
703       'primary_key' => 'prepaynum',
704       'unique'      => [ ['identifier'] ],
705       'index        => [ [] ],
706     },
707
708   );
709
710   %tables;
711
712 }
713