mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-07 08:34:42 +01:00
removed those reserved words. added the sequences. triggers still missing.
This commit is contained in:
parent
41fae14630
commit
7355ddb1f5
@ -1,10 +1,22 @@
|
||||
------------------------------------------------------------------------------
|
||||
-- Create_Tables Script for Oracle --
|
||||
-- not yet completed and not yet fully working. The trigger functions still --
|
||||
-- need to be built and I couldn't figure out yet how to do this... --
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
create table applications (
|
||||
app_name varchar(25) NOT NULL,
|
||||
app_title varchar(50),
|
||||
app_enabled int,
|
||||
unique(app_name)
|
||||
);
|
||||
|
||||
------------------
|
||||
-- APPLICATIONS --
|
||||
------------------
|
||||
|
||||
CREATE TABLE applications (
|
||||
app_name varchar2(25) NOT NULL,
|
||||
app_title varchar2(50),
|
||||
app_enabled int
|
||||
);
|
||||
|
||||
create unique index applications_app_name
|
||||
on applications (app_name);
|
||||
|
||||
insert into applications (app_name, app_title, app_enabled) values ('admin', 'Administration', 1);
|
||||
insert into applications (app_name, app_title, app_enabled) values ('filemanager', 'File manager', 1);
|
||||
@ -15,71 +27,86 @@ insert into applications (app_name, app_title, app_enabled) values ('email', 'Em
|
||||
insert into applications (app_name, app_title, app_enabled) values ('nntp', 'NNTP', 1);
|
||||
insert into applications (app_name, app_title, app_enabled) values ('cron_apps', 'cron_apps', 0);
|
||||
|
||||
create function get_seq(seq_table in varchar2(40))
|
||||
return number is
|
||||
seq number(11);
|
||||
begin
|
||||
select seq_table.nextval into seq from dual;
|
||||
return(seq);
|
||||
end
|
||||
--------------
|
||||
-- ACCOUNTS --
|
||||
--------------
|
||||
|
||||
create sequence accounts_seq;
|
||||
# we need to write an insert trigger for autoincrementation
|
||||
create table accounts (
|
||||
con int default get_seq(accounts_seq),
|
||||
loginid varchar(25) NOT NULL,
|
||||
passwd char(32) NOT NULL,
|
||||
firstname varchar(50),
|
||||
lastname varchar(50),
|
||||
CREATE TABLE accounts (
|
||||
con number(11) DEFAULT '0' NOT NULL , --auto-increment
|
||||
loginid varchar2(25) NOT NULL,
|
||||
passwd varchar2(32) NOT NULL,
|
||||
firstname varchar2(50),
|
||||
lastname varchar2(50),
|
||||
permissions text,
|
||||
groups varchar(30),
|
||||
lastlogin int,
|
||||
lastloginfrom varchar(255),
|
||||
lastpasswd_change int,
|
||||
status char(1),
|
||||
unique(loginid),unique(con)
|
||||
groups varchar2(30),
|
||||
lastlogin number(11),
|
||||
lastloginfrom varchar2(255),
|
||||
lastpasswd_change number(11),
|
||||
status varchar2(40) DEFAULT 'A' check (status in ('A','L')) NOT NULL,
|
||||
PRIMARY KEY (con)
|
||||
);
|
||||
|
||||
create unique index accounts_loginid
|
||||
on accounts (loginid);
|
||||
|
||||
create sequence accounts_seq
|
||||
increment by 1
|
||||
start with 0
|
||||
maxvalue 999999999
|
||||
minvalue 0
|
||||
nocycle
|
||||
nocache;
|
||||
|
||||
-- this trigger unfortunately does not work, since "NEW or OLD references are
|
||||
-- not allowed in table level triggers" (oracle error msg quoted here). But we
|
||||
-- need to define some triggers like this for each table that needs the
|
||||
-- auto-increment function:
|
||||
--
|
||||
-- create trigger accounts_trg
|
||||
-- before insert into accounts
|
||||
-- begin
|
||||
-- :new.con := accounts_seq.nextid;
|
||||
-- end;
|
||||
-- /
|
||||
|
||||
insert into accounts (loginid,passwd,firstname,lastname,permissions,groups,
|
||||
status) values ('demo','81dc9bdb52d04dc20036dbd8313ed055','Demo','Account',
|
||||
':admin:email:todo:addressbook:calendar:hr:',',1,','A');
|
||||
status) values ('demo','81dc9bdb52d04dc20036dbd8313ed055','Demo','Account',
|
||||
':admin:email:todo:addressbook:calendar:hr:',',1,','A');
|
||||
|
||||
|
||||
------------
|
||||
-- GROUPS --
|
||||
------------
|
||||
|
||||
create sequence groups_seq;
|
||||
# we need to write an insert trigger for autoincrementation
|
||||
create table groups (
|
||||
group_id int default get_seq(groups_seq),
|
||||
group_name varchar(50),
|
||||
group_apps varchar(255),
|
||||
unique(group_id)
|
||||
group_id int NOT NULL , --auto-increment
|
||||
group_name varchar2(255),
|
||||
group_apps varchar2(255),
|
||||
primary key(group_id)
|
||||
);
|
||||
|
||||
create sequence groups_seq
|
||||
increment by 1
|
||||
start with 0
|
||||
maxvalue 999999999
|
||||
minvalue 0
|
||||
nocycle
|
||||
nocache;
|
||||
|
||||
insert into groups (group_name) values ('Default');
|
||||
|
||||
create table sessions (
|
||||
sessionid varchar(255),
|
||||
loginid varchar(20),
|
||||
passwd varchar(255),
|
||||
ip varchar(255),
|
||||
logintime int,
|
||||
dla int,
|
||||
unique(sessionid)
|
||||
);
|
||||
|
||||
CREATE TABLE app_sessions (
|
||||
sessionid varchar(255) NOT NULL,
|
||||
loginid varchar(20),
|
||||
app varchar(20),
|
||||
content text
|
||||
);
|
||||
-----------------
|
||||
-- PREFERENCES --
|
||||
-----------------
|
||||
|
||||
create table preferences (
|
||||
owner varchar(20),
|
||||
name varchar(50),
|
||||
value varchar(50)
|
||||
CREATE TABLE preferences (
|
||||
owner varchar2(20),
|
||||
name varchar2(50),
|
||||
value varchar2(50)
|
||||
);
|
||||
|
||||
insert into preferences values ('demo','maxmatchs','10');
|
||||
insert into preferences values ('demo','email_sig','');
|
||||
insert into preferences values ('demo','mainscreen_showbirthdays','True');
|
||||
insert into preferences values ('demo','mainscreen_showevents','True');
|
||||
insert into preferences values ('demo','timeformat','12');
|
||||
@ -87,127 +114,243 @@ insert into preferences values ('demo','dateformat','m/d/Y');
|
||||
insert into preferences values ('demo','theme','default');
|
||||
insert into preferences values ('demo','tz_offset','0');
|
||||
|
||||
|
||||
--------------
|
||||
-- SESSIONS --
|
||||
--------------
|
||||
|
||||
CREATE TABLE sessions (
|
||||
sessionid varchar2(255) NOT NULL,
|
||||
loginid varchar2(20),
|
||||
passwd varchar2(255),
|
||||
ip varchar2(255),
|
||||
logintime number(11),
|
||||
dla number(11)
|
||||
);
|
||||
|
||||
create unique index sessions_sessionid
|
||||
on sessions (sessionid);
|
||||
|
||||
|
||||
------------------
|
||||
-- APP_SESSIONS --
|
||||
------------------
|
||||
|
||||
CREATE TABLE app_sessions (
|
||||
sessionid varchar2(255) NOT NULL,
|
||||
loginid varchar2(20),
|
||||
app varchar2(20),
|
||||
content text
|
||||
);
|
||||
|
||||
|
||||
----------------
|
||||
-- ACCESS_LOG --
|
||||
----------------
|
||||
|
||||
create table access_log (
|
||||
sessionid varchar(30),
|
||||
loginid varchar(30),
|
||||
ip varchar(30),
|
||||
li int,
|
||||
lo int
|
||||
sessionid varchar2(30),
|
||||
loginid varchar2(30),
|
||||
ip varchar2(30),
|
||||
li int,
|
||||
lo int
|
||||
);
|
||||
|
||||
create sequence profiles_seq;
|
||||
# we need to write an insert trigger for autoincrementation
|
||||
|
||||
--------------
|
||||
-- PROFILES --
|
||||
--------------
|
||||
|
||||
CREATE TABLE profiles (
|
||||
con int default get_seq(profiles_seq),
|
||||
owner varchar(20),
|
||||
title varchar(255),
|
||||
phone_number varchar(255),
|
||||
comments text,
|
||||
picture_format varchar(255),
|
||||
picture text,
|
||||
unique(con)
|
||||
con number(11) DEFAULT '0' NOT NULL , --auto-increment
|
||||
owner varchar2(20),
|
||||
title varchar2(255),
|
||||
phone_number varchar2(255),
|
||||
comments varchar2(4000),
|
||||
picture_format varchar2(255),
|
||||
picture blob,
|
||||
PRIMARY KEY (con)
|
||||
);
|
||||
|
||||
create sequence addressbook_seq;
|
||||
# we need to write an insert trigger for autoincrementation
|
||||
create table addressbook (
|
||||
con int default get_seq(addressbook_seq),
|
||||
owner varchar(25),
|
||||
access varchar(10),
|
||||
firstname varchar(255),
|
||||
lastname varchar(255),
|
||||
email varchar(255),
|
||||
hphone varchar(255),
|
||||
wphone varchar(255),
|
||||
fax varchar(255),
|
||||
pager varchar(255),
|
||||
mphone varchar(255),
|
||||
ophone varchar(255),
|
||||
street varchar(255),
|
||||
city varchar(255),
|
||||
state varchar(255),
|
||||
zip varchar(255),
|
||||
bday varchar(255),
|
||||
notes TEXT,
|
||||
company varchar(255),
|
||||
unique(con)
|
||||
create sequence profiles_seq
|
||||
increment by 1
|
||||
start with 0
|
||||
maxvalue 999999999
|
||||
minvalue 0
|
||||
nocycle
|
||||
nocache;
|
||||
|
||||
|
||||
-----------------
|
||||
-- ADDRESSBOOK --
|
||||
-----------------
|
||||
|
||||
CREATE TABLE addressbook (
|
||||
con number(11) DEFAULT '0' NOT NULL , --auto-increment
|
||||
owner varchar2(25),
|
||||
addr_access varchar2(10),
|
||||
firstname varchar2(255),
|
||||
lastname varchar2(255),
|
||||
email varchar2(255),
|
||||
hphone varchar2(255),
|
||||
wphone varchar2(255),
|
||||
fax varchar2(255),
|
||||
pager varchar2(255),
|
||||
mphone varchar2(255),
|
||||
ophone varchar2(255),
|
||||
street varchar2(255),
|
||||
city varchar2(255),
|
||||
state varchar2(255),
|
||||
zip varchar2(255),
|
||||
bday varchar2(255),
|
||||
notes text,
|
||||
company varchar2(255),
|
||||
PRIMARY KEY (con)
|
||||
);
|
||||
|
||||
create sequence todo_seq;
|
||||
# we need to write an insert trigger for autoincrementation
|
||||
create table todo (
|
||||
con int default get_seq(todo_seq),
|
||||
owner varchar(25),
|
||||
access varchar(10),
|
||||
des text,
|
||||
pri int,
|
||||
status int,
|
||||
datecreated int,
|
||||
datedue int,
|
||||
unique(con)
|
||||
create sequence addressbook_seq
|
||||
increment by 1
|
||||
start with 0
|
||||
maxvalue 999999999
|
||||
minvalue 0
|
||||
nocycle
|
||||
nocache;
|
||||
|
||||
|
||||
----------
|
||||
-- TODO --
|
||||
----------
|
||||
|
||||
CREATE TABLE todo (
|
||||
con number(11) DEFAULT '0' NOT NULL , --auto-increment
|
||||
owner varchar2(25),
|
||||
todo_access varchar2(10),
|
||||
des text,
|
||||
pri number(11),
|
||||
status number(11),
|
||||
datecreated number(11),
|
||||
datedue number(11),
|
||||
PRIMARY KEY (con)
|
||||
);
|
||||
|
||||
create sequence webcal_entry_seq;
|
||||
# we need to write an insert trigger for autoincrementation
|
||||
create sequence todo_seq
|
||||
increment by 1
|
||||
start with 0
|
||||
maxvalue 999999999
|
||||
minvalue 0
|
||||
nocycle
|
||||
nocache;
|
||||
|
||||
|
||||
------------------
|
||||
-- WEBCAL_ENTRY --
|
||||
------------------
|
||||
|
||||
CREATE TABLE webcal_entry (
|
||||
cal_id int default get_seq(webcal_entry_seq),
|
||||
cal_group_id int NULL,
|
||||
cal_create_by varchar(25) NOT NULL,
|
||||
cal_date int NOT NULL,
|
||||
cal_time int NULL,
|
||||
cal_mod_date int,
|
||||
cal_mod_time int,
|
||||
cal_duration int NOT NULL,
|
||||
cal_priority int DEFAULT 2,
|
||||
cal_type varchar(10),
|
||||
cal_access varchar(10),
|
||||
cal_name varchar(80) NOT NULL,
|
||||
cal_description TEXT,
|
||||
unique(cal_id)
|
||||
cal_id number(11) DEFAULT '0' NOT NULL , --auto-increment
|
||||
cal_group_id number(11),
|
||||
cal_create_by varchar2(25) NOT NULL,
|
||||
cal_date number(11) DEFAULT '0' NOT NULL,
|
||||
cal_time number(11),
|
||||
cal_mod_date number(11),
|
||||
cal_mod_time number(11),
|
||||
cal_duration number(11) DEFAULT '0' NOT NULL,
|
||||
cal_priority number(11) DEFAULT '2',
|
||||
cal_type varchar2(10),
|
||||
cal_access char(10),
|
||||
cal_name varchar2(80) NOT NULL,
|
||||
cal_description varchar2(4000),
|
||||
PRIMARY KEY (cal_id)
|
||||
);
|
||||
|
||||
CREATE TABLE webcal_entry_user (
|
||||
cal_id int NOT NULL,
|
||||
cal_login varchar(25) NOT NULL,
|
||||
cal_status char(1) DEFAULT 'A'
|
||||
);
|
||||
create sequence webcal_entry_seq
|
||||
increment by 1
|
||||
start with 0
|
||||
maxvalue 999999999
|
||||
minvalue 0
|
||||
nocycle
|
||||
nocache;
|
||||
|
||||
create table webcal_entry_repeats (
|
||||
cal_id int,
|
||||
cal_type varchar(20),
|
||||
cal_end int,
|
||||
cal_frequency int default 1,
|
||||
|
||||
--------------------------
|
||||
-- WEBCAL_ENTRY_REPEATS --
|
||||
--------------------------
|
||||
|
||||
CREATE TABLE webcal_entry_repeats (
|
||||
cal_id number(11) DEFAULT '0' NOT NULL,
|
||||
cal_type varchar2(40) DEFAULT 'daily' check (cal_type in ('daily','weekly','monthlyByDay','monthlyByDate','yearly')) NOT NULL,
|
||||
cal_end number(11),
|
||||
cal_frequency number(11) DEFAULT '1',
|
||||
cal_days char(7)
|
||||
);
|
||||
|
||||
|
||||
------------------------
|
||||
-- WEBCAL_ENTRY_USERS --
|
||||
------------------------
|
||||
|
||||
CREATE TABLE webcal_entry_user (
|
||||
cal_id number(11) DEFAULT '0' NOT NULL,
|
||||
cal_login varchar2(25) NOT NULL,
|
||||
cal_status char(1) DEFAULT 'A',
|
||||
PRIMARY KEY (cal_id, cal_login)
|
||||
);
|
||||
|
||||
|
||||
-------------------------
|
||||
-- WEBCAL_ENTRY_GROUPS --
|
||||
-------------------------
|
||||
|
||||
create table webcal_entry_groups (
|
||||
cal_id int,
|
||||
groups varchar(255)
|
||||
groups varchar2(255)
|
||||
);
|
||||
|
||||
create sequence newsgroups_seq;
|
||||
# we need to write an insert trigger for autoincrementation
|
||||
|
||||
----------------
|
||||
-- NEWSGROUPS --
|
||||
----------------
|
||||
|
||||
CREATE TABLE newsgroups (
|
||||
con int default get_seq(newsgroups_seq),
|
||||
name varchar(255) NOT NULL,
|
||||
messagecount int NOT NULL,
|
||||
lastmessage int NOT NULL,
|
||||
con number(11) NOT NULL , --auto-increment
|
||||
name varchar2(255) NOT NULL,
|
||||
messagecount number(11) NOT NULL,
|
||||
lastmessage number(11) NOT NULL,
|
||||
active char DEFAULT 'N' NOT NULL,
|
||||
lastread int,
|
||||
unique(con)
|
||||
lastread number(11),
|
||||
PRIMARY KEY (con)
|
||||
);
|
||||
|
||||
create unique index newsgroups_name
|
||||
on newsgroups (name);
|
||||
|
||||
create sequence newsgroups_seq
|
||||
increment by 1
|
||||
start with 0
|
||||
maxvalue 999999999
|
||||
minvalue 0
|
||||
nocycle
|
||||
nocache;
|
||||
|
||||
|
||||
---------------------
|
||||
-- USERS_NEWSGOUPS --
|
||||
---------------------
|
||||
|
||||
CREATE TABLE users_newsgroups (
|
||||
owner int NOT NULL,
|
||||
newsgroup int NOT NULL
|
||||
owner number(11) NOT NULL,
|
||||
newsgroup number(11) NOT NULL
|
||||
);
|
||||
|
||||
|
||||
----------
|
||||
-- LANG --
|
||||
----------
|
||||
|
||||
CREATE TABLE lang (
|
||||
message_id varchar(150) DEFAULT '' NOT NULL,
|
||||
app_name varchar(100) DEFAULT 'common' NOT NULL,
|
||||
lang varchar(5) DEFAULT '' NOT NULL,
|
||||
content text NOT NULL,
|
||||
unique(message_id,app_name,lang)
|
||||
message_id varchar2(150) NOT NULL,
|
||||
app_name varchar2(100) DEFAULT 'common' NOT NULL,
|
||||
lang varchar2(5) NOT NULL,
|
||||
content varchar2(4000) NOT NULL,
|
||||
PRIMARY KEY (message_id,app_name,lang)
|
||||
);
|
||||
|
||||
COMMIT;
|
||||
|
Loading…
Reference in New Issue
Block a user