summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authoreinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2006-10-30 05:08:55 +0000
committereinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2006-10-30 05:08:55 +0000
commitb5abb3df53ff5970bb422f731663fbef17190954 (patch)
tree1e0a8366544b353170dcb3ceefb8611d286adb36 /sql
parent230d7095e37f5cf9637f12d7de38a77526b74d4d (diff)
Fixing IR, IS, and CT bugs
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@382 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'sql')
-rwxr-xr-xsql/Pg-tables.sql6
-rw-r--r--sql/Pg-upgrade-2.6.18-2.6.19.sql69
2 files changed, 74 insertions, 1 deletions
diff --git a/sql/Pg-tables.sql b/sql/Pg-tables.sql
index 6e5130eb..d490110f 100755
--- a/sql/Pg-tables.sql
+++ b/sql/Pg-tables.sql
@@ -50,6 +50,10 @@ CREATE TABLE gifi (
);
--
CREATE TABLE defaults (
+ setting_key text primary key,
+ value text
+);
+/*
inventory_accno_id int,
income_accno_id int,
expense_accno_id int,
@@ -76,7 +80,7 @@ CREATE TABLE defaults (
glnumber text,
projectnumber text
);
---
+-- */
CREATE TABLE acc_trans (
trans_id int,
chart_id int NOT NULL REFERENCES chart (id),
diff --git a/sql/Pg-upgrade-2.6.18-2.6.19.sql b/sql/Pg-upgrade-2.6.18-2.6.19.sql
index 924bd0ba..b2328844 100644
--- a/sql/Pg-upgrade-2.6.18-2.6.19.sql
+++ b/sql/Pg-upgrade-2.6.18-2.6.19.sql
@@ -1,3 +1,5 @@
+BEGIN;
+
ALTER TABLE ap ADD PRIMARY KEY (id);
ALTER TABLE ar ADD PRIMARY KEY (id);
@@ -206,3 +208,70 @@ CREATE FUNCTION update_user(int4,text) RETURNS int4 AS $$
$$ LANGUAGE 'SQL';
COMMENT ON FUNCTION update_user(int4,text) IS $$ Takes int4 which is users.id and text which is username. Will update username based on id. Username is unique $$;
+
+ALTER TABLE defaults RENAME TO old_defaults;
+
+CREATE TABLE defaults (
+ setting_key TEXT PRIMARY KEY,
+ value TEXT
+);
+
+COMMENT ON TABLE defaults IS $$This table replaces the old one column per value system with a simple key => value table$$;
+
+
+INSERT INTO defaults (setting_key, value)
+SELECT 'inventory_accno_id', inventory_accno_id FROM old_defaults
+UNION
+SELECT 'income_accno_id', income_accno_id FROM old_defaults
+UNION
+SELECT 'expense_accno_id', expense_accno_id FROM old_defaults
+UNION
+SELECT 'fxloss_accno_id', fxloss_accno_id FROM old_defaults
+UNION
+SELECT 'fxgain_accno_id', fxgain_accno_id FROM old_defaults
+UNION
+SELECT 'sinumber', sinumber FROM old_defaults
+UNION
+SELECT 'sonumber', sonumber FROM old_defaults
+UNION
+SELECT 'yearend', yearend FROM old_defaults
+UNION
+SELECT 'weightunit', weightunit FROM old_defaults
+UNION
+SELECT 'businessnumber', businessnumber FROM old_defaults
+UNION
+SELECT 'version', '1.2.0'
+UNION
+SELECT 'curr', curr FROM old_defaults
+UNION
+SELECT 'closedto', closedto FROM old_defaults
+UNION
+SELECT 'revtrans', revtrans FROM old_defaults
+UNION
+SELECT 'ponumber', ponumber FROM old_defaults
+UNION
+SELECT 'sqnumber', sqnumber FROM old_defaults
+UNION
+SELECT 'rfqnumber', rfqnumber FROM old_defaults
+UNION
+SELECT 'audittrail', audittrail FROM old_defaults
+UNION
+SELECT 'vinumber', vinumber FROM old_defaults
+UNION
+SELECT 'employeenumber', employeenumber FROM old_defaults
+UNION
+SELECT 'partnumber', partnumber FROM old_defaults
+UNION
+SELECT 'customernumber', customernumber FROM old_defaults
+UNION
+SELECT 'vendornumber', vendornumber FROM old_defaults
+UNION
+SELECT 'glnumber', glnumber FROM old_defaults
+UNION
+SELECT 'projectnumber', projectnumber FROM old_defaults
+UNION
+SELECT 'appname', 'LedgerSMB';
+
+DROP TABLE old_defaults;
+
+COMMIT;