From 5c84fa7553e974a341320bf36ee8e25d1dd7b560 Mon Sep 17 00:00:00 2001 From: aurynn_cmd Date: Thu, 13 Sep 2007 22:08:33 +0000 Subject: Adding dbobject/admin.pm git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1589 4979c152-3d1c-0410-bac9-87ea11338e46 --- sql/Pg-database.sql | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) (limited to 'sql') diff --git a/sql/Pg-database.sql b/sql/Pg-database.sql index d4df3ea5..9b0d66d1 100644 --- a/sql/Pg-database.sql +++ b/sql/Pg-database.sql @@ -6,8 +6,44 @@ CREATE SEQUENCE id; -- can be named anything. -- USERS stuff -- -CREATE TABLE users (id serial UNIQUE, username varchar(30) primary key); +CREATE TABLE users ( + id serial UNIQUE, + username varchar(30) primary key + entity_id not null references entity(id) on delete cascade +); COMMENT ON TABLE users IS $$username is the actual primary key here because we do not want duplicate users$$; + +create table user_connection ( + user_id int not null references user(id) on delete cascade, + dbname text not null, + host text not null default 'localhost', + port int not null default '5432' +); + +CREATE VIEW users_conf as + select + user.id, + loc.address1 || '\n'|| loc.address2 ||'\n' || loc.address3, + em.employeenumber, + company, + loc.country, + currency, + dateformat, + 'Pg', + u_cx.host + u_cx.dbname, + u_cx.dbport, + user.username, + p.email, + p.fax, + 50, + p.first_name || ' ' || p.last_name, + p.number_format, + '', -- password + + +; + CREATE TABLE users_conf(id integer primary key references users(id) deferrable initially deferred, acs text, address text, -- cgit v1.2.3