From 783fcb9c858a9ce1df370fed7dfd5c963207c92d Mon Sep 17 00:00:00 2001
From: linuxpoet <linuxpoet@4979c152-3d1c-0410-bac9-87ea11338e46>
Date: Mon, 11 Sep 2006 00:13:32 +0000
Subject: Rather large amount of changes to Pg-tables.sql and the 2.6.17-2.6.18
 upgrade script. Changed all floats to numeric. If the float was a percent, it
 is just numeric. If the float was a cost, it is (10,2)

git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@62 4979c152-3d1c-0410-bac9-87ea11338e46
---
 sql/Pg-upgrade-2.6.17-2.6.18.sql | 62 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 62 insertions(+)

(limited to 'sql/Pg-upgrade-2.6.17-2.6.18.sql')

diff --git a/sql/Pg-upgrade-2.6.17-2.6.18.sql b/sql/Pg-upgrade-2.6.17-2.6.18.sql
index 4cf7c9e0..a0ad36d5 100644
--- a/sql/Pg-upgrade-2.6.17-2.6.18.sql
+++ b/sql/Pg-upgrade-2.6.17-2.6.18.sql
@@ -11,6 +11,68 @@ ALTER TABLE acc_trans ALTER COLUMN entry_id SET DEFAULT nextval('acctrans_entry_
 UPDATE acc_trans SET entry_id = nextval('acctrans_entry_id_seq');
 ALTER TABLE acc_trans ADD PRIMARY key (entry_id);
 
+-- Start changing floats
+ALTER TABLE acc_trans ALTER COLUMN amount TYPE numeric(10,2);
+
+-- This may break someone if they for some reason have an actual float type in the qty column
+ALTER TABLE invoice ALTER COLUMN qty TYPE numeric;
+
+ALTER TABLE invoice ALTER COLUMN allocated TYPE numeric;
+ALTER TABLE invoice ALTER COLUMN sellprice TYPE numeric(10,2);
+ALTER TABLE invoice ALTER COLUMN fxsellprice TYPE numeric(10,2);
+
+ALTER TABLE customer ALTER COLUMN discount TYPE numeric;
+ALTER TABLE customer ALTER COLUMN creditlimit TYPE numeric(10,2);
+
+ALTER TABLE parts ALTER COLUMN listprice TYPE numeric(10,2);
+ALTER TABLE parts ALTER COLUMN sellprice TYPE numeric(10,2);
+ALTER TABLE parts ALTER COLUMN lastcost TYPE numeric(10,2);
+ALTER TABLE parts ALTER COLUMN weight TYPE numeric;
+ALTER TABLE parts ALTER COLUMN onhand TYPE numeric;
+ALTER TABLE parts ALTER COLUMN avgcost TYPE numeric(10,2);
+
+ALTER TABLE assembly ALTER COLUMN qty TYPE numeric;
+
+ALTER TABLE ar ALTER COLUMN amount TYPE numeric(10,2);
+ALTER TABLE ar ALTER COLUMN netamount TYPE numeric(10,2);
+ALTER TABLE ar ALTER COLUMN paid TYPE numeric(10,2);
+
+ALTER TABLE ap ALTER COLUMN amount TYPE numeric(10,2);
+ALTER TABLE ap ALTER COLUMN netamount TYPE numeric(10,2);
+ALTER TABLE ap ALTER COLUMN paid TYPE numeric(10,2);
+
+ALTER TABLE tax ALTER COLUMN rate TYPE numeric;
+
+ALTER TABLE oe ALTER COLUMN amount TYPE numeric(10,2);
+ALTER TABLE oe ALTER COLUMN netamount TYPE numeric(10,2);
+
+ALTER TABLE orderitems ALTER COLUMN qty TYPE numeric;
+ALTER TABLE orderitems ALTER COLUMN sellprice TYPE numeric(10,2);
+ALTER TABLE orderitems ALTER COLUMN discount TYPE numeric;
+ALTER TABLE orderitems ALTER COLUMN ship TYPE numeric;
+
+ALTER TABLE exchangerate ALTER COLUMN buy TYPE numeric;
+ALTER TABLE exchangerate ALTER COLUMN sell TYPE numeric;
+
+ALTER TABLE vendor ALTER COLUMN discount TYPE numeric;
+ALTER TABLE vendor ALTER COLUMN creditlimit TYPE numeric; 
+
+ALTER TABLE project ALTER COLUMN production TYPE numeric; 
+ALTER TABLE project ALTER COLUMN completed TYPE numeric;
+
+ALTER TABLE business ALTER COLUMN discount TYPE numeric;
+
+ALTER TABLE inventory ALTER COLUMN qty TYPE numeric;
+
+ALTER TABLE partsvendor ALTER COLUMN lastcost TYPE numeric(10,2);
+
+ALTER TABLE partscustomer ALTER COLUMN pricebreak TYPE numeric;
+ALTER TABLE partscustomer ALTER COLUMN sellprice TYPE numeric(10,2);
+
+ALTER TABLE jcitems ALTER COLUMN qty TYPE numeric;
+ALTER TABLE jcitems ALTER COLUMN allocated TYPE numeric;
+ALTER TABLE jcitems ALTER COLUMN sellprice TYPE numeric(10,2);
+ALTER TABLE jcitems ALTER COLUMN fxsellprice TYPE numeric(10,2);
 
 -- The query rewrite rule necessary to notify the email app that a new report
 -- needs to be sent to the designated administrator.
-- 
cgit v1.2.3

