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