herding elephants: add primary keys to *all* tables for slony
[freeside.git] / httemplate / docs / schema.html
1
2   <title>Schema reference</title>
3 </head>
4 <body>
5   <h1>Schema reference</h1>
6   Schema diagram (1.4.1): <a href="schema.png">as a giant .png</a> or <a href="schema.dia">dia source</a> (<a href="http://www.lysator.liu.se/~alla/dia/">dia homepage</a>).
7   <ul>
8     <li><a name="agent" href="man/FS/agent.html">agent</a> - Agents are resellers of your service.  Agents may be limited to a subset of your full offerings (via their agent type).
9       <ul>
10         <li>agentnum - primary key
11         <li>agent - name of this agent
12         <li>typenum - <a href="#agent_type">agent type</a>
13         <li>prog - (unimplemented)
14         <li>freq - (unimplemented)
15         <li>disabled - Disabled flag, empty or 'Y'
16         <li>username - Username for the Agent interface
17         <li>_password - Password for the Agent interface
18       </ul>
19     <li><a name="agent_type" href="man/FS/agent_type.html">agent_type</a> - Agent types define groups of packages that you can then assign to particular agents.
20       <ul>
21         <li>typenum - primary key
22         <li>atype - name of this agent type
23       </ul>
24     <li><a name="cust_bill" href="man/FS/cust_bill.html">cust_bill</a> - Invoices.  Declarations that a customer owes you money.  The specific charges are itemized in <a href="#cust_bill_pkg">cust_bill_pkg</a>.
25       <ul>
26         <li>billpkgnum - primary_key
27         <li>invnum - primary key
28         <li>custnum - <a href="#cust_main">customer</a>
29         <li>_date
30         <li>charged - amount of this invoice
31         <li>printed - how many times this invoice has been printed automatically
32         <li>closed - books closed flag, empty or `Y'
33       </ul>
34     <li><a name="cust_bill_event" href="man/FS/cust_bill_event.html">cust_bill_event</a> - Invoice event history
35       <ul>
36         <li>eventnum - primary key
37         <li>invnum - <a href="#cust_bill">invoice</a>
38         <li>eventpart - <a href="#part_bill_event">event definition</a>
39         <li>_date
40         <li>status
41         <li>statustext
42       </ul>
43     <li><a name="part_bill_event" href="man/FS/part_bill_event.html">part_bill_event</a> - Invoice event definitions
44       <ul>
45         <li>eventpart - primary key
46         <li>payby - CARD, DCRD, CHEK, DCHK, LECB, BILL, or COMP
47         <li>event - event name
48         <li>eventcode - event action
49         <li>seconds - how long after the invoice date (<a href="#cust_bill">cust_bill</a>._date) events of this type are triggered
50         <li>weight - ordering for events with identical seconds
51         <li>plan - eventcode plan
52         <li>plandata - additional plan data
53         <li>disabled - Disabled flag, empty or `Y'
54         <li>taxclass - Texas tax class flag, empty or "none", "access", or "hosting"
55       </ul>
56     <li><a name="cust_bill_pkg" href="man/FS/cust_bill_pkg.html">cust_bill_pkg</a> - Invoice line items
57       <ul>
58         <li>invnum - (multiple) key
59         <li>pkgnum - <a href="#cust_pkg">package</a> or 0 for the special virtual sales tax package
60         <li>setup - setup fee 
61         <li>recur - recurring fee
62         <li>sdate - starting date
63         <li>edate - ending date
64         <li>itemdesc - Line item description (currently used only when pkgnum is 0)
65       </ul>
66     <li><a name="cust_bill_pkg_detail" href="man/FS/cust_bill_pkg_detail.html">cust_bill_pkg_detail</a> - Invoice line items detail
67       <ul>
68         <li>detailnum - primary key
69         <li>pkgnum -
70         <li>invnum - 
71         <li>detail - Detail description
72       </ul>
73     <li><a name="cust_credit" href="man/FS/cust_credit.html">cust_credit</a> - Credits.  The equivalent of a negative <a href="#cust_bill">cust_bill</a> record.
74       <ul>
75         <li>crednum - primary key
76         <li>custnum - <a href="#cust_main">customer</a>
77         <li>amount - amount credited
78         <li>_date
79         <li>otaker - order taker
80         <li>reason
81         <li>closed - books closed flag, empty or `Y'
82       </ul>
83     <li><a name="cust_credit_bill" href="man/FS/cust_credit_bill.html">cust_credit_bill</a> - Credit invoice application.  Links a credit to an invoice.
84       <ul>
85         <li>creditbillnum - primary key
86         <li>crednum - <a href="#cust_credit">credit</a> being applied
87         <li>invnum - <a href="#cust_bill">invoice</a> to which credit is applied
88         <li>amount - amount applied
89         <li>_date
90       </ul>
91     <li><a name="cust_pay_refund" href="man/FS/cust_pay_refund.html">cust_credit_bill</a> - Refund payment application.  Links a refund to a payment.
92       <ul>
93         <li>payrefundnum - primary key
94         <li>paynum - <a href="#cust_pay">payment</a>
95         <li>refundnum - <a href="#cust_refund">refund</a>
96         <li>amount - amount applied
97         <li>_date
98       </ul>
99     <li><a name="cust_main" href="man/FS/cust_main.html">cust_main</a> - Customers
100       <ul>
101         <li>custnum - primary key
102         <li>agentnum - <a href="#agent">agent</a>
103         <li>refnum - <a href="#part_referral">referral</a>
104         <li>first - name
105         <li>last - name
106         <li>ss - social security number
107         <li>company
108         <li>address1
109         <li>address2
110         <li>city
111         <li>county
112         <li>state
113         <li>zip
114         <li>country
115         <li>daytime - phone
116         <li>night - phone
117         <li>fax - phone
118         <li><i>ship_first</i>
119         <li><i>ship_last</i>
120         <li><i>ship_company</i>
121         <li><i>ship_address1</i>
122         <li><i>ship_address2</i>
123         <li><i>ship_city</i>
124         <li><i>ship_county</i>
125         <li><i>ship_state</i>
126         <li><i>ship_zip</i>
127         <li><i>ship_country</i>
128         <li><i>ship_daytime</i>
129         <li><i>ship_night</i>
130         <li><i>ship_fax</i>
131         <li>payby - CARD, DCHK, CHEK, DCHK, LECB, BILL, or COMP
132         <li>payinfo - card number, P.O.#, or comp issuer
133         <li>paycvv - Card Verification Value, "CVV2" (also known as CVC2 or CID), the 3 or 4 digit number on the back (or front, for American Express) of the credit card
134         <li>paydate - expiration date
135         <li>payname - billing name (name on card)
136         <li>tax - tax exempt, Y or null
137         <li>otaker - order taker
138         <li>referral_custnum
139         <li>comments
140       </ul>
141       (columns in <i>italics</i> are optional)
142     <li><a name="cust_main_invoice" href="man/FS/cust_main_invoice.html">cust_main_invoice</a> - Invoice destinations for email invoices.  Note that a customer can have many email destinations for their invoice (either literal or via svcnum), but only one postal destination.
143       <ul>
144         <li>destnum - primary key
145         <li>custnum - <a href="#cust_main">customer</a>
146         <li>dest - Invoice destination.  Freeside supports three types of invoice delivery: send directly to a service defined in Freeside, send to an arbitrary email address, or print the invoice to a printer and have someone send it out via snail mail.  Freeside determines which method to use based on the contents of the dest field.  If the contents are numeric, a <a href="#svc_acct">svcnum</a> pointing to a valid service is expected in the field.  If the contents are a string, a literal email address is expected to be in the field.  If the special keyword `POST' is present, the snail mail method is used (which is the default if no cust_main_invoice records exist).  Snail mail invoices get their address information from <A name="#cust_main">cust_main</A> and are printed with the printer defined in the configuration files.
147       </ul>
148     <li><a name="cust_main_county" href="man/FS/cust_main_county.html">cust_main_county</a> - Tax rates
149       <ul>
150         <li>taxnum - primary key
151         <li>state
152         <li>county
153         <li>country
154         <li>tax - % rate
155         <li>taxclass
156         <li>exempt_amount
157         <li>taxname - if defined, printed on invoices instead of "Tax"
158         <li>setuptax - if 'Y', this tax does not apply to setup fees
159         <li>recurtax - if 'Y', this tax does not apply to recurring fees
160       </ul>
161     <li><a name="cust_tax_exempt" href="man/FS/cust_tax_exempt.html">cust_tax_exempt</a> - Tax exemption record
162       <ul>
163         <li>exemptnum - primary key
164         <li>taxnum - <a href="#cust_main_county">tax rate</a>
165         <li>year
166         <li>month
167         <li>amount
168       </ul>
169     <li><a name="cust_pay" href="man/FS/cust_pay.html">cust_pay</a> - Payments.  Money being transferred from a customer.
170       <ul>
171         <li>paynum - primary key
172         <li>custnum - <a href="#cust_main">customer</a>
173         <li>paid - amount
174         <li>_date
175         <li>payby - CARD, CHEK, LECB, BILL, or COMP
176         <li>payinfo - card number, P.O.#, or comp issuer
177         <li>paybatch - text field for tracking card processor batches
178         <li>closed - books closed flag, empty or `Y'
179       </ul>
180     <li><a name="cust_pay-void" href="man/FS/cust_pay_void.html">cust_pay_void</a> - Voided payments.
181       <ul>
182         <li>paynum - primary key
183         <li>custnum - <a href="#cust_main">customer</a>
184         <li>paid - amount
185         <li>_date
186         <li>payby - CARD, CHEK, LECB, BILL, or COMP
187         <li>payinfo - card number, P.O.#, or comp issuer
188         <li>paybatch - text field for tracking card processor batches
189         <li>closed - books closed flag, empty or `Y'
190         <li>void_date
191         <li>reason
192         <li>otaker - order taker
193       </ul>
194     <li><a name="cust_bill_pay" href="man/FS/cust_bill_pay.html">cust_bill_pay</a> - Applicaton of a payment to a specific invoice.
195       <ul>
196         <li>billpaynum
197         <li>invnum - <a href="#cust_bill">invoice</a>
198         <li>paynum - <a href="#cust_pay">payment</a>
199         <li>amount
200         <li>_date
201       </ul>
202     <li><a name="cust_pay_batch" href="man/FS/cust_pay_batch.html">cust_pay_batch</a> - Pending batch
203       <ul>
204         <li>paybatchnum
205         <li>cardnum
206         <li>exp - card expiration
207         <li>amount
208         <li>invnum - <a href="#cust_bill">invoice</a>
209         <li>custnum - <a href="#cust_main">customer</a>
210         <li>payname - name on card
211         <li>first - name
212         <li>last - name
213         <li>address1
214         <li>address2
215         <li>city
216         <li>state
217         <li>zip
218         <li>country
219       </ul>
220     <li><a name="cust_pkg" href="man/FS/cust_pkg.html">cust_pkg</a> - Customer billing items
221       <ul>
222         <li>pkgnum - primary key
223         <li>custnum - <a href="#cust_main">customer</a>
224         <li>pkgpart - <a href="#part_pkg">Package definition</a>
225         <li>setup - date
226         <li>bill - next bill date
227         <li>last_bill - last bill date
228         <li>susp - (past) suspension date
229         <li>expire - (future) cancellation date
230         <li>cancel - (past) cancellation date
231         <li>otaker - order taker
232         <li>manual_flag - If this field is set to 1, disables the automatic unsuspensiond of this package when using the <a href="config.html#unsuspendauto">unsuspendauto</a> config file.
233       </ul>
234     <li><a name="cust_refund" href="man/FS/cust_refund.html">cust_refund</a> - Refunds.  The transfer of money to a customer; equivalent to a negative <a href="#cust_pay">cust_pay</a> record.
235       <ul>
236         <li>refundnum - primary key
237         <li>custnum - <a href="#cust_main">customer</a>
238         <li>refund - amount
239         <li>_date
240         <li>payby - CARD, CHEK, LECB, BILL or COMP
241         <li>payinfo - card number, P.O.#, or comp issuer
242         <li>otaker - order taker
243         <li>closed - books closed flag, empty or `Y'
244       </ul>
245     <li><a name="cust_credit_refund" href="man/FS/cust_credit_refund.html">cust_credit_refund</a> - Applicaton of a refund to a specific credit.
246       <ul>
247         <li>creditrefundnum - primary key
248         <li>crednum - <a href="#cust_credit">credit</a>
249         <li>refundnum - <a href="#cust_refund">refund</a>
250         <li>amount
251         <li>_date
252       </ul>
253     <li><a name="cust_svc" href="man/FS/cust_svc.html">cust_svc</a> - Customer services
254       <ul>
255         <li>svcnum - primary key
256         <li>pkgnum - <a href="#cust_pkg">package</a>
257         <li>svcpart - <a href="#part_svc">Service definition</a>
258       </ul>
259     <li><a name="nas" href="man/FS/nas.html">nas</a> - Network Access Server (terminal server)
260       <ul>
261         <li>nasnum - primary key
262         <li>nas - NAS name
263         <li>nasip - NAS ip address
264         <li>nasfqdn - NAS fully-qualified domain name
265         <li>last - timestamp indicating the last instant the NAS was in a known state (used by the session monitoring).
266       </ul>
267     <li><a name="part_pkg" href="man/FS/part_pkg.html">part_pkg</a> - Package definitions
268       <ul>
269         <li>pkgpart - primary key
270         <li>pkg - package name
271         <li>comment - non-customer visable package comment
272         <li>promo_code - promotional code
273         <li><i>deprecated</i> setup - setup fee expression
274         <li>freq - recurring frequency (months)
275         <li><i>deprecated</i> recur - recurring fee expression
276         <li>setuptax - Setup fee tax exempt flag, empty or `Y'
277         <li>recurtax - Recurring fee tax exempt flag, empty or `Y'
278         <li>plan - price plan
279         <li><i>deprecated</i> plandata - additional price plan data
280         <li>disabled - Disabled flag, empty or `Y'
281       </ul>
282     <li><a name="part_pkg_option" href="man/FS/part_pkg_option.html">part_pkg_option</a> - Package definition options
283       <ul>
284         <li>optionnum - primary key
285         <li>pkgpart - <a href="#part_pkg">Package definition</a>
286         <li>optionname - option name
287         <li>optionvalue - option value
288       </ul>
289     <li><a name="reg_code" href="man/FS/reg_code.html">reg_code</A> - One-time registration codes
290       <ul>
291         <li>codenum - primary key
292         <li>code
293         <li>agentnum - <a href="#agent">Agent</a>
294       </ul>
295     <li><a name="reg_code_pkg" href="man/FS/reg_code_pkg.html">reg_code_pkg</A> - Registration code link to package definitions
296       <ul>
297         <li>codepkgnum - primary key
298         <li>codenum - <a href="#reg_code">Registration code</a>
299         <li>pkgpart - <a href="#part_pkg">Package definition</a>
300       </ul>
301     <li><a name="part_referral" href="man/FS/part_referral.html">part_referral</a> - Referral listing
302       <ul>
303         <li>refnum - primary key
304         <li>referral - referral
305       </ul>
306     <li><a name="part_svc" href="man/FS/part_svc.html">part_svc</a> - Service definitions
307       <ul>
308         <li>svcpart - primary key
309         <li>svc - name of this service
310         <li>svcdb - table used for this service: svc_acct, svc_forward, svc_domain, svc_charge or svc_wo
311         <li>disabled - Disabled flag, empty or `Y'
312 <!--        <li><i>table</i>__<i>field</i> - Default or fixed value for <i>field</i> in <i>table</i>
313         <li><i>table</i>__<i>field</i>_flag - null, D or F
314 -->
315       </ul>
316     <li><a name="part_svc_column" href="man/FS/part_svc_column.html">part_svc_column</a>
317       <ul>
318         <li>columnnum - primary key
319         <li>svcpart - <a href="#part_svc">Service definition</a>
320         <li>columnname - column name in part_svc.svcdb table
321         <li>columnvalue - default or fixed value for the column
322         <li>columnflag - null, D or F
323       </ul>
324     <li><a name="pkg_svc" href="man/FS/pkg_svc.html">pkg_svc</a>
325       <ul>
326         <li>pkgsvcnum - primary key
327         <li>pkgpart - <a href="#part_pkg">Package definition</a>
328         <li>svcpart - <a href="#part_svc">Service definition</a>
329         <li>quantity - quantity of this service that this package includes
330         <li>primary_svc - blank or Y: primary service
331       </ul>
332     <li><a name="export_svc" href="man/FS/export_svc.html">export_svc</a>
333       <ul>
334         <li>exportsvcnum - primary key
335         <li>svcpart - <a href="#part_svc">Service definition</a>
336         <li>exportnum - <a href="#exportnum">Export</a>
337       </ul>
338     <li><a name="part_export" href="man/FS/part_export.html">part_export</a> - Export to external provisioning
339       <ul>
340         <li>exportnum - primary key
341         <li>machine - Machine name 
342         <li>exporttype - Export type
343         <li>nodomain - blank or Y: usernames are exported to this service with no domain
344       </ul>
345     <li><a name="part_export_option" href="man/FS/part_export_option.html">part_export_option</a> - provisioning options
346       <ul>
347         <li>optionnum - primary key
348         <li>exportnum - <a href="#part_export">Export</a>
349         <li>optionname - option name
350         <li>optionvalue - option value
351       </ul>
352     <li><a name="port" href="man/FS/port.html">port</a> - individual port on a <a href="#nas">nas</a>
353       <ul>
354         <li>portnum - primary key
355         <li>ip - IP address of this port
356         <li>nasport - port number on the NAS
357         <li>nasnum - <a href="#nas">NAS</a>
358       </ul>
359     <li><a name="prepay_credit" href="man/FS/prepay_credit.html">prepay_credit</a> - prepaid cards
360       <ul>
361         <li>prepaynum - primary key
362         <li>identifier - text or numeric string of prepaid card
363         <li>amount - amount of prepayment
364         <li>seconds - prepaid time instead of (or in addition to) monetary value
365         <li>agentnum - optional agent assignment for prepaid cards
366       </ul>
367     <li><a name="session" href="man/FS/session.html">session</a>
368       <ul>
369         <li>sessionnum - primary key
370         <li>portnum - <a href="#port">Port</a>
371         <li>svcnum - <a href="#svc_acct">Account</a>
372         <li>login - timestamp indicating the beginning of this user session.
373         <li>logout - timestamp indicating the end of this user session.  May be null, which indicates a currently open session.
374       </ul>
375
376     <li><a name="svc_acct" href="man/FS/svc_acct.html">svc_acct</a> - Accounts
377       <ul>
378         <li>svcnum - <a href="#cust_svc">primary key</a>
379         <li>username
380         <li>_password
381         <li>sec_phrase - security phrase
382         <li>popnum - <a href="#svc_acct_pop">Point of Presence</a>
383         <li>uid
384         <li>gid
385         <li>finger - GECOS
386         <li>dir
387         <li>shell
388         <li>quota - (unimplementd)
389         <li>slipip - IP address
390         <li>seconds
391         <li>domsvc
392         <li>radius_<i>Radius_Reply_Attribute</i> - Radius-Reply-Attribute
393         <li>rc_<i>Radius_Check_Attribute</i> - Radius-Check-Attribute
394       </ul>
395     <li><a name="svc_acct_pop" href="man/FS/svc_acct_pop.html">svc_acct_pop</a> - Points of Presence
396       <ul>
397         <li>popnum - primary key
398         <li>city
399         <li>state
400         <li>ac - area code
401         <li>exch - exchange
402         <li>loc - rest of number
403       </ul>
404     <li><a name="part_pop_local" href="man/FS/part_pop_local.html">part_pop_local</a> - Local calling areas
405       <ul>
406         <li>localnum - primary key
407         <li>popnum - primary key
408         <li>city
409         <li>state
410         <li>npa - area code
411         <li>nxx - exchange
412       </ul>
413     <li><a name="svc_domain" href="man/FS/svc_domain.html">svc_domain</a> - Domains
414       <ul>
415         <li>svcnum - <a href="#cust_svc">primary key</a>
416         <li>domain
417       </ul>
418     <li><a name="svc_forward" href="man/FS/svc_forward.html">svc_forward</a> - Mail forwarding aliases
419       <ul>
420         <li>svcnum - <a href="#cust_svc">primary key</a>
421         <li>srcsvc - <a href="#svc_acct">svcnum of the source of this forward</a>
422         <li>src - literal source (username or full email address)
423         <li>dstsvc - <a href="#svc_acct">svcnum of the destination of this forward</a>
424         <li>dst - literal destination (username or full email address)
425       </ul>
426     <li><a name="domain_record" href="man/FS/domain_record.html">domain_record</a> - Domain zone detail
427       <ul>
428         <li>recnum - primary key
429         <li>svcnum - <a href="#svc_domain">Domain</a> (by svcnum)
430         <li>reczone - zone for this line
431         <li>recaf - address family, usually <b>IN</b>
432         <li>rectype - type for this record (<b>A</b>, <b>MX</b>, etc.)
433         <li>recdata - data for this record
434       </ul>
435     <li><a name="svc_www" href="man/FS/svc_www.html">svc_www</a>
436       <ul>
437        <li>svcnum - <a href="#cust-svc">primary key</a>
438        <li>recnum - <a href="#domain_record">host</a>
439        <li>usersvc - <a href="#svc_acct">account</a>
440       </ul>
441     <li><a name="type_pkgs" href="man/FS/type_pkgs.html">type_pkgs</a>
442       <ul>
443         <li>typepkgnum - primary key
444         <li>typenum - <a href="#agent_type">agent type</a>
445         <li>pkgpart - <a href="#part_pkg">Package definition</a>
446       </ul>
447     <li><a name="queue" href="man/FS/queue.html">queue</a> - job queue
448       <ul>
449         <li>jobnum - primary key
450         <li>job
451         <li>_date
452         <li>status
453         <li>statustext
454         <li>svcnum
455       </ul>
456     <li><a name="queue_arg" href="man/FS/queue_arg.html">queue_arg</a> - job arguments
457       <ul>
458         <li>argnum - primary key
459         <li>jobnum - <a href="#queue">job</a>
460         <li>arg - argument
461       </ul>
462     <li><a name="queue_depend" href="man/FS/queue_depend.html">queue_depend</a> - job dependancies
463       <ul>
464         <li>dependnum - primary key
465         <li>jobnum - source jobnum
466         <li>depend_jobnum - dependancy jobnum
467       </ul>
468     <li><a name="radius_usergroup" href="man/FS/radius_usergroup.html">radius_usergroup</a> - Link users to RADIUS groups.
469       <ul>
470         <li>usergroupnum - primary key
471         <li>svcnum - <a href="#svc_acct">account</a>
472         <li>groupname
473       </ul>
474     <li><a name="rate" href="man/FS/rate.html">rate</a> - Call rate plans
475       <ul>
476         <li>ratenum - primary key
477         <li>ratename
478       </ul>
479     <li><a name="rate_detail" href="man/FS/rate_detail.html">rate_detail</a> - Call rate detail
480       <ul>
481         <li>ratedetailnum - primary key
482         <li>ratenum - <a href="#rate">rate plan</a>
483         <li>orig_regionnum - call origination <a href="#rate_region">region</a>
484         <li>dest_regionnum - call destination <a href="#rate_region">region</a>
485         <li>min_included - included minutes
486         <li>min_charge - charge per minute
487         <li>sec_granularity - granularity in seconds, i.e. 6 or 60
488       </ul>
489     <li><a name="rate_region" href="man/FS/rate_region.html">rate_region</a> - Call rate region
490       <ul>
491         <li>regionnum - primary key
492         <li>regionname
493       </ul>
494     <li><a name="rate_prefix" href="man/FS/rate_prefix.html">rate_prefix</a> - Call rate prefix
495       <ul>
496         <li>prefixnum - primary key
497         <li>regionnum - <a href="#rate_region">rate region</a>
498         <li>countrycode
499         <li>npa
500         <li>nxx
501       </ul>
502     <li><a name="msgcat" href="man/FS/msgcat.html">msgcat</a> - i18n message catalog
503       <ul>
504         <li>msgnum - primary key
505         <li>msgcode - message code
506         <li>locale - locale
507         <li>msg - Message text
508       </ul>
509     <li><a name="clientapi_session" href="man/FS/clientapi_session.html">clientapi_session</a> - ClientAPI session store
510       <ul>
511         <li>sessionnum - primary key
512         <li>sessionid - session ID
513         <li>namespace - session namespace
514       </ul>
515     <li><a name="clientapi_session_field" href="man/FS/clientapi_session_field.html">clientapi_session_field</a> - Client API session store data
516       <ul>
517         <li>fieldnum - primary key
518         <li>sessionnum - <a href="#session">session</a>
519         <li>fieldname
520         <li>fieldvalue
521       </ul>
522   </ul>
523 </body>