part_export schema changes
[freeside.git] / httemplate / docs / upgrade8.html
1 <head>
2   <title>Upgrading to 1.4.0</title>
3 </head>
4 <body>
5 <h1>Upgrading to 1.4.0 from 1.3.1</h1>
6 <ul>
7   <li>If migrating from less than 1.3.1, see these <a href="upgrade7.html">instructions</a> first.
8   <li><font size="+2" color="#ff0000">Backup your database and current Freeside installation.</font> (with&nbsp;<a href="http://www.ca.postgresql.org/devel-corner/docs/postgres/backup.html">PostgreSQL</a>) (with&nbsp;<a href="http://www.mysql.com/documentation/mysql/bychapter/manual_MySQL_Database_Administration.html#Backup">MySQL</a>)
9   <li>Install <a href="http://www.apache-asp.org/">Apache::ASP</a> or <a href="http://www.masonhq.com/">HTML::Mason</a>.
10 </ul>
11 <table>
12   <tr>
13     <th>Apache::ASP</th><th>Mason</th>
14   </tr>
15   <tr>
16     <td><ul>
17       <li>Run <tt>make aspdocs</tt>
18       <li>Copy <tt>aspdocs/</tt> to your web server's document space.
19       <li>Create a <a href="http://www.apache-asp.org/config.html#Global">Global</a> directory, such as <tt>/usr/local/etc/freeside/asp-global/</tt>
20       <li>Copy <tt>htetc/global.asa</tt> to the Global directory.
21       <li>Configure Apache for the Global directory and to execute .cgi files using Apache::ASP.  For example:
22 <font size="-1"><pre>
23 &lt;Directory /usr/local/apache/htdocs/freeside-asp&gt;
24 &lt;Files ~ (\.cgi)&gt;
25 AddHandler perl-script .cgi
26 PerlHandler Apache::ASP
27 &lt;/Files&gt;
28 &lt;Perl&gt;
29 $MLDBM::RemoveTaint = 1;
30 &lt;/Perl&gt;
31 PerlSetVar Global /usr/local/etc/freeside/asp-global/
32 &lt;/Directory&gt;
33 </pre></font>
34     </ul></td>
35     <td><ul>
36       <li>NOTE: Mason support is still a bit buggy in the 1.4.0 prereleases.  This will be fixed before 1.4.0.  You have been warned.
37       <li>Run <tt>make masondocs</tt>
38       <li>Copy <tt>masondocs/</tt> to your web server's document space.
39       <li>Copy <tt>htetc/handler.pl</tt> to your web server's configuration directory.
40       <li>Edit <tt>handler.pl</tt> and set an appropriate <tt>data_dir</tt>, such as <tt>/usr/local/etc/freeside/mason-data</tt>
41       <li>Configure Apache to use the <tt>handler.pl</tt> file and to execute .cgi files using HTML::Mason.  For example:
42 <font size="-1"><pre>
43 &lt;Directory /usr/local/apache/htdocs/freeside-mason&gt;
44 &lt;Files ~ (\.cgi)&gt;
45 AddHandler perl-script .cgi
46 PerlHandler HTML::Mason
47 &lt;/Files&gt;
48 &lt;Perl&gt;
49 require "/usr/local/apache/conf/handler.pl";
50 &lt;/Perl&gt;
51 &lt;/Directory&gt;
52 </pre></font>
53     </ul></td>
54   </tr>
55 </table>
56 <ul>
57   <li>Build and install the Perl modules:
58     <pre>
59 $ su
60 # make install-perl-modules</pre>
61    <li>Apply the following changes to your database:
62 <pre>
63 CREATE TABLE svc_forward (
64   svcnum int NOT NULL,
65   srcsvc int NOT NULL,
66   dstsvc int NOT NULL,
67   dst varchar(80),
68   PRIMARY KEY (svcnum)
69 );
70
71 CREATE TABLE cust_credit_bill (
72   creditbillnum int primary key,
73   crednum int not null,
74   invnum int not null,
75   _date int not null,
76   amount decimal(10,2) not null
77 );
78
79 CREATE TABLE cust_bill_pay (
80   billpaynum int primary key,
81   invnum int not null,
82   paynum int not null,
83   _date int not null,
84   amount decimal(10,2) not null
85 );
86
87 CREATE TABLE cust_credit_refund (
88   creditrefundnum int primary key,
89   crednum int not null,
90   refundnum int not null,
91   _date int not null,
92   amount decimal(10,2) not null
93 );
94
95 CREATE TABLE part_svc_column (
96   columnnum int primary key,
97   svcpart int not null,
98   columnname varchar(64) not null,
99   columnvalue varchar(80) null,
100   columnflag char(1) null
101 );
102
103 CREATE TABLE queue (
104   jobnum int primary key,
105   job text not null,
106   _date int not null,
107   status varchar(80) not null
108 );
109
110 CREATE TABLE queue_arg (
111   argnum int primary key,
112   jobnum int not null,
113   arg text null
114 );
115 CREATE INDEX queue_arg1 ON queue_arg ( jobnum );
116
117 CREATE TABLE part_pop_local (
118   localnum int primary key,
119   popnum int not null,
120   city varchar(80) null,
121   state char(2) null,
122   npa char(3) not null,
123   nxx char(3) not null
124 );
125 CREATE UNIQUE INDEX part_pop_local1 ON part_pop_local ( npa, nxx );
126
127 CREATE TABLE cust_bill_event (
128   eventnum int primary key,
129   invnum int not null,
130   eventpart int not null,
131   _date int not null,
132 );
133 CREATE UNIQUE INDEX cust_bill_event1 ON cust_bill_event ( eventpart, invnum );
134 CREATE INDEX cust_bill_event2 ON cust_bill_event ( invnum );
135
136 CREATE TABLE part_bill_event (
137   eventpart int primary key,
138   payby char(4) not null,
139   event varchar(80) not null,
140   eventcode text null,
141   seconds int null,
142   disabled char(1) null,
143 );
144 CREATE INDEX part_bill_event1 ON part_bill_event ( payby );
145
146 CREATE TABLE part_export (
147   exportnum int primary key,
148   svcpart int not null,
149   machine varchar(80) not null,
150   exporttype varchar(80) not null,
151   nodomain char(1) NULL
152 );
153 CREATE INDEX part_export1 ON part_export ( machine );
154 CREATE INDEX part_export2 ON part_export ( exporttype );
155
156 CREATE INDEX part_export_option (
157   optionnum int primary key,
158   exportnum int not null,
159   option varchar(80) not null,
160   optionvalue text NULL
161 );
162 CREATE INDEX part_export_option1 ON part_export ( exportnum );
163 CREATE INDEX part_export_option2 ON part_export ( option );
164
165 ALTER TABLE svc_acct ADD domsvc integer NOT NULL;
166 ALTER TABLE svc_domain ADD catchall integer NULL;
167 ALTER TABLE cust_main ADD referral_custnum integer NULL;
168 ALTER TABLE cust_pay ADD custnum integer;
169 ALTER TABLE cust_pay_batch ADD paybatchnum integer;
170 ALTER TABLE cust_refund ADD custnum integer;
171 ALTER TABLE cust_pkg ADD manual_flag char(1) NULL;
172 ALTER TABLE part_pkg ADD plan varchar(80) NULL;
173 ALTER TABLE part_pkg ADD plandata text NULL;
174 ALTER TABLE part_pkg ADD setuptax char(1) NULL;
175 ALTER TABLE part_pkg ADD recurtax char(1) NULL;
176 ALTER TABLE part_pkg ADD disabled char(1) NULL;
177 ALTER TABLE part_svc ADD disabled char(1) NULL;
178 CREATE INDEX cust_main3 ON cust_main ( referral_custnum );
179 CREATE INDEX cust_credit_bill1 ON cust_credit_bill ( crednum );
180 CREATE INDEX cust_credit_bill2 ON cust_credit_bill ( invnum );
181 CREATE INDEX cust_bill_pay1 ON cust_bill_pay ( invnum );
182 CREATE INDEX cust_bill_pay2 ON cust_bill_pay ( paynum );
183 CREATE INDEX cust_credit_refund1 ON cust_credit_refund ( crednum );
184 CREATE INDEX cust_credit_refund2 ON cust_credit_refund ( refundnum );
185 CREATE UNIQUE INDEX cust_pay_batch_pkey ON cust_pay_batch ( paybatchnum );
186 CREATE UNIQUE INDEX part_svc_column1 ON part_svc_column ( svcpart, columnname );
187 </pre>
188
189   <li>If you are using PostgreSQL, apply the following changes to your database:
190 <pre>
191 CREATE UNIQUE INDEX agent_pkey ON agent ( agentnum );
192 CREATE UNIQUE INDEX agent_type_pkey ON agent_type ( typenum );
193 CREATE UNIQUE INDEX cust_bill_pkey ON cust_bill ( invnum );
194 CREATE UNIQUE INDEX cust_credit_pkey ON cust_credit ( crednum );
195 CREATE UNIQUE INDEX cust_main_pkey ON cust_main ( custnum );
196 CREATE UNIQUE INDEX cust_main_county_pkey ON cust_main_county ( taxnum );
197 CREATE UNIQUE INDEX cust_main_invoice_pkey ON cust_main_invoice ( destnum );
198 CREATE UNIQUE INDEX cust_pay_pkey ON cust_pay ( paynum );
199 CREATE UNIQUE INDEX cust_pkg_pkey ON cust_pkg ( pkgnum );
200 CREATE UNIQUE INDEX cust_refund_pkey ON cust_refund ( refundnum );
201 CREATE UNIQUE INDEX cust_svc_pkey ON cust_svc ( svcnum );
202 CREATE UNIQUE INDEX domain_record_pkey ON domain_record ( recnum );
203 CREATE UNIQUE INDEX nas_pkey ON nas ( nasnum );
204 CREATE UNIQUE INDEX part_pkg_pkey ON part_pkg ( pkgpart );
205 CREATE UNIQUE INDEX part_referral_pkey ON part_referral ( refnum );
206 CREATE UNIQUE INDEX part_svc_pkey ON part_svc ( svcpart );
207 CREATE UNIQUE INDEX port_pkey ON port ( portnum );
208 CREATE UNIQUE INDEX prepay_credit_pkey ON prepay_credit ( prepaynum );
209 CREATE UNIQUE INDEX session_pkey ON session ( sessionnum );
210 CREATE UNIQUE INDEX svc_acct_pkey ON svc_acct ( svcnum );
211 CREATE UNIQUE INDEX svc_acct_pop_pkey ON svc_acct_pop ( popnum );
212 CREATE UNIQUE INDEX svc_acct_sm_pkey ON svc_acct_sm ( svcnum );
213 CREATE UNIQUE INDEX svc_domain_pkey ON svc_domain ( svcnum );
214 CREATE UNIQUE INDEX svc_www_pkey ON svc_www ( svcnum );
215 CREATE UNIQUE INDEX type_pkgs_pkey ON type_pkgs ( typenum );
216 </pre>
217   <li>If you wish to enable service/shipping addresses, apply the following
218       changes to your database:
219 <pre>
220 ALTER TABLE cust_main ADD COLUMN ship_last varchar(80) NULL;
221 ALTER TABLE cust_main ADD COLUMN ship_first varchar(80) NULL;
222 ALTER TABLE cust_main ADD COLUMN ship_company varchar(80) NULL;
223 ALTER TABLE cust_main ADD COLUMN ship_address1 varchar(80) NULL;
224 ALTER TABLE cust_main ADD COLUMN ship_address2 varchar(80) NULL;
225 ALTER TABLE cust_main ADD COLUMN ship_city varchar(80) NULL;
226 ALTER TABLE cust_main ADD COLUMN ship_county varchar(80) NULL;
227 ALTER TABLE cust_main ADD COLUMN ship_state varchar(80) NULL;
228 ALTER TABLE cust_main ADD COLUMN ship_zip varchar(10) NULL;
229 ALTER TABLE cust_main ADD COLUMN ship_country char(2) NULL;
230 ALTER TABLE cust_main ADD COLUMN ship_daytime varchar(20) NULL;
231 ALTER TABLE cust_main ADD COLUMN ship_night varchar(20) NULL;
232 ALTER TABLE cust_main ADD COLUMN ship_fax varchar(12) NULL;
233 CREATE INDEX cust_main1 ON cust_main ( ship_last );
234 CREATE INDEX cust_main2 ON cust_main ( ship_company );
235 </pre>
236   <li>If you wish to enable customer comments, apply the following change to
237       your database:
238 <pre>
239 ALTER TABLE cust_main ADD COLUMN comments text NULL;
240 </pre>
241   <li>If you are using the signup server, reinstall it according to the <a href="signup.html">instructions</a>.  The 1.3.x signup server is not compatible with 1.4.x.
242   <li>Run bin/dbdef-create.
243   <li>If you have svc_acct_sm records or service definitions:
244     <ul>
245       <li>Create a service definition with table svc_forward
246       <li>Run bin/fs-migrate-svc_acct_sm
247     </ul>
248   <li>Run bin/fs-migrate-payref
249   <li>Run bin/fs-migrate-part_svc
250   <li><b>After running bin/fs-migrate-payref</b>, apply the following changes to your database:
251   <table border><tr><th>PostgreSQL</th><th>MySQL, others</th></tr>
252 <tr><td>
253 <font size=-1><pre>
254 CREATE TABLE cust_pay_temp (
255   paynum int primary key,
256   custnum int not null,
257   paid decimal(10,2) not null,
258   _date int null,
259   payby char(4) not null,
260   payinfo varchar(16) null,
261   paybatch varchar(80) null
262 );
263 INSERT INTO cust_pay_temp SELECT * from cust_pay;
264 DROP TABLE cust_pay;
265 ALTER TABLE cust_pay_temp RENAME TO cust_pay;
266 CREATE UNIQUE INDEX cust_pay1 ON cust_pay (paynum);
267 CREATE TABLE cust_refund_temp (
268   refundnum int primary key,
269   custnum int not null,
270   _date int null,
271   refund decimal(10,2) not null,
272   otaker varchar(8) not null,
273   reason varchar(80) not null,
274   payby char(4) not null,
275   payinfo varchar(16) null,
276   paybatch varchar(80) null
277 );
278 INSERT INTO cust_refund_temp SELECT * from cust_refund;
279 DROP TABLE cust_refund;
280 ALTER TABLE cust_refund_temp RENAME TO cust_refund;
281 CREATE UNIQUE INDEX cust_refund1 ON cust_refund (refundnum);
282 </pre></font>
283 </td><td>
284 <font size=-1><pre>
285 ALTER TABLE cust_pay DROP COLUMN invnum;
286 ALTER TABLE cust_refund DROP COLUMN crednum;
287 </pre></font>
288 </td></tr></table>
289   <li><b>IMPORTANT: After applying the second set of database changes</b>, run bin/dbdef-create again.
290   <li>set the <a href="../config/config.cgi#username_policy">user_policy configuration value</a> as appropriate for your site.
291   <li>Create the `/usr/local/etc/freeside/cache.<i>datasrc</i>' directory
292       (ownded by the freeside user).
293   <li>freeside-queued was installed with the Perl modules.  Start it now and ensure that is run upon system startup.
294 </ul>
295 </body>