~openerp-groupes/openobject-server/6.0-fix-setup-windows

« back to all changes in this revision

Viewing changes to bin/addons/base/base.sql

  • Committer: pinky
  • Date: 2006-12-07 13:41:40 UTC
  • Revision ID: pinky-3f10ee12cea3c4c75cef44ab04ad33ef47432907
New trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
-------------------------------------------------------------------------
 
2
-- Pure SQL
 
3
-------------------------------------------------------------------------
 
4
 
 
5
CREATE TABLE perm (
 
6
    id serial NOT NULL,
 
7
    level smallint DEFAULT 4 NOT NULL,
 
8
    uid int default null,
 
9
    gid int default null,
 
10
    primary key(id)
 
11
);
 
12
insert into perm (id,uid,gid) values (1,1,1);
 
13
 
 
14
CREATE TABLE inherit (
 
15
    obj_type varchar(128) not null,
 
16
    obj_id int not null,
 
17
    inst_type varchar(128) not null,
 
18
    inst_id int not null
 
19
);
 
20
 
 
21
-------------------------------------------------------------------------
 
22
-- IR dictionary
 
23
-------------------------------------------------------------------------
 
24
 
 
25
create table ir_values
 
26
(
 
27
    id serial,
 
28
    perm_id int references perm on delete set null,
 
29
    name varchar(128) not null,
 
30
    key varchar(128) not null,
 
31
    key2 varchar(128) not null,
 
32
    model varchar(128) not null,
 
33
    value text,
 
34
    meta text default NULL,
 
35
    res_id integer default null,
 
36
    primary key (id)
 
37
);
 
38
 
 
39
-------------------------------------------------------------------------
 
40
-- Modules Description
 
41
-------------------------------------------------------------------------
 
42
 
 
43
CREATE TABLE ir_model (
 
44
  id serial,
 
45
  model varchar(64) DEFAULT ''::varchar NOT NULL,
 
46
  name varchar(64),
 
47
  info text,
 
48
  primary key(id)
 
49
);
 
50
 
 
51
CREATE TABLE ir_model_fields (
 
52
  id serial,
 
53
  model varchar(64) DEFAULT ''::varchar NOT NULL,
 
54
  model_id int references ir_model,
 
55
  name varchar(64) DEFAULT ''::varchar NOT NULL,
 
56
  relation varchar(64),
 
57
  field_description varchar(256),
 
58
  ttype varchar(64),
 
59
  group_name varchar(64),
 
60
  view_load boolean,
 
61
  relate boolean default False,
 
62
  primary key(id)
 
63
);
 
64
 
 
65
 
 
66
-------------------------------------------------------------------------
 
67
-- Actions
 
68
-------------------------------------------------------------------------
 
69
 
 
70
CREATE TABLE ir_actions (
 
71
    id serial NOT NULL,
 
72
    perm_id int references perm on delete set null,
 
73
    name varchar(64) DEFAULT ''::varchar NOT NULL,
 
74
    "type" varchar(64) DEFAULT 'window'::varchar NOT NULL,
 
75
    usage varchar(32) DEFAULT null,
 
76
    primary key(id)
 
77
);
 
78
 
 
79
CREATE TABLE ir_act_window (
 
80
    view_id integer,
 
81
    res_model varchar(64),
 
82
    view_type varchar(16),
 
83
    "domain" varchar(127),
 
84
    primary key(id)
 
85
)
 
86
INHERITS (ir_actions);
 
87
 
 
88
CREATE TABLE ir_act_report_xml (
 
89
    model varchar(64) NOT NULL,
 
90
    report_name varchar(64) NOT NULL,
 
91
    report_xsl varchar(64),
 
92
    report_xml varchar(64),
 
93
        auto boolean default true
 
94
)
 
95
INHERITS (ir_actions);
 
96
 
 
97
create table ir_act_report_custom (
 
98
    report_id int
 
99
--  report_id int references ir_report_custom
 
100
)
 
101
INHERITS (ir_actions);
 
102
 
 
103
CREATE TABLE ir_act_group (
 
104
    exec_type varchar(64) DEFAULT 'serial'::varchar NOT NULL
 
105
)
 
106
INHERITS (ir_actions);
 
107
 
 
108
CREATE TABLE ir_act_group_link (
 
109
    aid integer NOT NULL,
 
110
    gid integer NOT NULL
 
111
);
 
112
 
 
113
CREATE TABLE ir_act_execute (
 
114
    func_name varchar(64) NOT NULL,
 
115
    func_arg varchar(64)
 
116
)
 
117
INHERITS (ir_actions);
 
118
 
 
119
CREATE TABLE ir_act_wizard (
 
120
    wiz_name varchar(64) NOT NULL
 
121
)
 
122
INHERITS (ir_actions);
 
123
 
 
124
CREATE TABLE ir_ui_view (
 
125
        id serial NOT NULL,
 
126
        perm_id int references perm on delete set null,
 
127
        name varchar(64) DEFAULT ''::varchar NOT NULL,
 
128
        model varchar(64) DEFAULT ''::varchar NOT NULL,
 
129
        "type" varchar(64) DEFAULT 'form'::varchar NOT NULL,
 
130
        arch text NOT NULL,
 
131
        field_parent varchar(64),
 
132
        priority integer DEFAULT 5 NOT NULL,
 
133
        primary key(id),
 
134
        CONSTRAINT ir_ui_view_type CHECK (((("type")::text = ('form'::varchar)::text) OR (("type")::text = ('tree'::varchar)::text)))
 
135
);
 
136
 
 
137
CREATE TABLE ir_ui_menu (
 
138
        id serial NOT NULL,
 
139
        perm_id int references perm on delete set null,
 
140
        parent_id int references ir_ui_menu on delete set null,
 
141
        name varchar(64) DEFAULT ''::varchar NOT NULL,
 
142
        icon varchar(64) DEFAULT ''::varchar,
 
143
        primary key (id)
 
144
);
 
145
 
 
146
select setval('ir_ui_menu_id_seq', 2);
 
147
 
 
148
---------------------------------
 
149
-- Res users
 
150
---------------------------------
 
151
 
 
152
-- level:
 
153
--   0  RESTRICT TO USER
 
154
--   1  RESTRICT TO GROUP
 
155
--   2  PUBLIC
 
156
 
 
157
CREATE TABLE res_users (
 
158
    id serial NOT NULL,
 
159
    perm_id int references perm on delete set null,
 
160
    name varchar(64) not null,
 
161
    active boolean default True,
 
162
    login varchar(64) NOT NULL UNIQUE,
 
163
    password varchar(32) default null,
 
164
    perm_default int references perm on delete set null,
 
165
--  action_id int references ir_act_window on delete set null,
 
166
    action_id int,
 
167
    primary key(id)
 
168
);
 
169
alter table res_users add constraint res_users_login_uniq unique (login);
 
170
 
 
171
insert into res_users (id,login,password,name,action_id,perm_id,active) values (1,'root',NULL,'Administrator',NULL,1,False);
 
172
select setval('res_users_id_seq', 2);
 
173
 
 
174
CREATE TABLE res_groups (
 
175
    id serial NOT NULL,
 
176
    perm_id int references perm on delete set null,
 
177
    name varchar(32) NOT NULL,
 
178
    primary key(id)
 
179
);
 
180
 
 
181
create table res_roles (
 
182
    id serial NOT NULL,
 
183
    perm_id int references perm on delete set null,
 
184
    parent_id int references res_roles on delete set null,
 
185
    name varchar(32) NOT NULL,
 
186
    primary key(id)
 
187
);
 
188
 
 
189
CREATE TABLE res_roles_users_rel (
 
190
        uid integer NOT NULL references res_users on delete cascade,
 
191
        rid integer NOT NULL references res_roles on delete cascade
 
192
);
 
193
 
 
194
CREATE TABLE res_groups_users_rel (
 
195
        uid integer NOT NULL references res_users on delete cascade,
 
196
        gid integer NOT NULL references res_groups on delete cascade
 
197
);
 
198
 
 
199
---------------------------------
 
200
-- Workflows
 
201
---------------------------------
 
202
 
 
203
create table wkf
 
204
(
 
205
    id serial,
 
206
    perm_id int references perm on delete set null,
 
207
    name varchar(64),
 
208
    osv varchar(64),
 
209
    on_create bool default False,
 
210
    primary key(id)
 
211
);
 
212
 
 
213
create table wkf_activity
 
214
(
 
215
    id serial,
 
216
    perm_id int references perm on delete set null,
 
217
    wkf_id int references wkf on delete cascade,
 
218
    subflow_id int references wkf on delete set null,
 
219
    split_mode varchar(3) default 'XOR',
 
220
    join_mode varchar(3) default 'XOR',
 
221
    kind varchar(16) not null default 'dummy',
 
222
    name varchar(64),
 
223
    signal_send varchar(32) default null,
 
224
    flow_start boolean default False,
 
225
    flow_stop boolean default False,
 
226
    action varchar(64) default null,
 
227
    primary key(id)
 
228
);
 
229
 
 
230
create table wkf_transition
 
231
(
 
232
    id serial,
 
233
    perm_id int references perm on delete set null,
 
234
    act_from int references wkf_activity on delete cascade,
 
235
    act_to int references wkf_activity on delete cascade,
 
236
    condition varchar(128) default NULL,
 
237
 
 
238
    trigger_type varchar(128) default NULL,
 
239
    trigger_expr_id varchar(128) default NULL,
 
240
 
 
241
    signal varchar(64) default null,
 
242
    role_id int references res_roles on delete set null,
 
243
 
 
244
    primary key(id)
 
245
);
 
246
 
 
247
create table wkf_instance
 
248
(
 
249
    id serial,
 
250
    wkf_id int references wkf on delete set null,
 
251
    uid int default null,
 
252
    res_id int not null,
 
253
    res_type varchar(64) not null,
 
254
    state varchar(32) not null default 'active',
 
255
    primary key(id)
 
256
);
 
257
 
 
258
create table wkf_workitem
 
259
(
 
260
    id serial,
 
261
    act_id int not null references wkf_activity on delete cascade,
 
262
    inst_id int not null references wkf_instance on delete cascade,
 
263
    subflow_id int references wkf_instance on delete cascade,
 
264
    state varchar(64) default 'blocked',
 
265
    primary key(id)
 
266
);
 
267
 
 
268
create table wkf_witm_trans
 
269
(
 
270
    trans_id int not null references wkf_transition on delete cascade,
 
271
    inst_id int not null references wkf_instance on delete cascade
 
272
);
 
273
 
 
274
create table wkf_logs
 
275
(
 
276
    id serial,
 
277
    res_type varchar(128) not null,
 
278
    res_id int not null,
 
279
    uid int references res_users on delete set null,
 
280
    act_id int references wkf_activity on delete set null,
 
281
    time time not null,
 
282
    info varchar(128) default NULL,
 
283
    primary key(id)
 
284
);
 
285
 
 
286
---------------------------------
 
287
-- Modules
 
288
---------------------------------
 
289
 
 
290
CREATE TABLE ir_module_category (
 
291
    id serial NOT NULL,
 
292
    perm_id integer,
 
293
    create_uid integer references res_users on delete set null,
 
294
    create_date timestamp without time zone,
 
295
    write_date timestamp without time zone,
 
296
    write_uid integer references res_users on delete set null,
 
297
    parent_id integer REFERENCES ir_module_category ON DELETE SET NULL,
 
298
    name character varying(128) NOT NULL,
 
299
    primary key(id)
 
300
);
 
301
 
 
302
 
 
303
CREATE TABLE ir_module_module (
 
304
    id serial NOT NULL,
 
305
    perm_id integer,
 
306
    create_uid integer references res_users on delete set null,
 
307
    create_date timestamp without time zone,
 
308
    write_date timestamp without time zone,
 
309
    write_uid integer references res_users on delete set null,
 
310
    website character varying(256),
 
311
    name character varying(128) NOT NULL,
 
312
    author character varying(128),
 
313
    url character varying(128),
 
314
    state character varying(16),
 
315
    latest_version character varying(64),
 
316
    shortdesc character varying(256),
 
317
    category_id integer REFERENCES ir_module_category ON DELETE SET NULL,
 
318
    description text,
 
319
    demo boolean default False,
 
320
    primary key(id)
 
321
);
 
322
 
 
323
CREATE TABLE ir_module_module_dependency (
 
324
    id serial NOT NULL,
 
325
    perm_id integer,
 
326
    create_uid integer references res_users on delete set null,
 
327
    create_date timestamp without time zone,
 
328
    write_date timestamp without time zone,
 
329
    write_uid integer references res_users on delete set null,
 
330
    name character varying(128),
 
331
    version_pattern character varying(128) default NULL,
 
332
    module_id integer REFERENCES ir_module_module ON DELETE cascade,
 
333
    primary key(id)
 
334
);
 
335