summaryrefslogtreecommitdiffstats
path: root/database/database.pgsql
blob: 5ebe4b76944af938c542a4e6232f6462ebb5ad5c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
-- Do not show NOTICE: messages, it's hard to spot errors.
set client_min_messages = 'warning';

--
-- Table structure for access
--

CREATE TABLE access (
  aid SERIAL,
  mask varchar(255) NOT NULL default '',
  type varchar(255) NOT NULL default '',
  status smallint NOT NULL default '0',
  PRIMARY KEY (aid)
);

--
-- Table structure for accesslog
--

CREATE TABLE accesslog (
  aid SERIAL,
  sid varchar(32) NOT NULL default '',
  title varchar(255) default NULL,
  path text default NULL,
  url text default NULL,
  hostname varchar(128) default NULL,
  uid integer default '0',
  timer integer NOT NULL default '0',
  timestamp integer NOT NULL default '0',
  PRIMARY KEY (aid)
);
CREATE INDEX accesslog_timestamp_idx ON accesslog (timestamp);

--
-- Table structure for table 'aggregator_category'
--

CREATE TABLE aggregator_category (
  cid serial,
  title varchar(255) NOT NULL default '',
  description text,
  block smallint NOT NULL default '0',
  PRIMARY KEY (cid),
  UNIQUE (title)
);

--
-- Table structure for table 'aggregator_category_feed'
--

CREATE TABLE aggregator_category_feed (
  fid integer NOT NULL default '0',
  cid integer NOT NULL default '0',
  PRIMARY KEY (fid,cid)
);

--
-- Table structure for table 'aggregator_category_item'
--

CREATE TABLE aggregator_category_item (
  iid integer NOT NULL default '0',
  cid integer NOT NULL default '0',
  PRIMARY KEY (iid,cid)
);

--
-- Table structure for table 'aggregator_feed'
--

CREATE TABLE aggregator_feed (
  fid serial,
  title varchar(255) NOT NULL default '',
  url varchar(255) NOT NULL default '',
  refresh integer NOT NULL default '0',
  checked integer NOT NULL default '0',
  link varchar(255) NOT NULL default '',
  description text,
  image text,
  etag varchar(255) NOT NULL default '',
  modified integer NOT NULL default '0',
  block smallint NOT NULL default '0',
  PRIMARY KEY (fid),
  UNIQUE (url),
  UNIQUE (title)
);

--
-- Table structure for table 'aggregator_item'
--

CREATE TABLE aggregator_item (
  iid SERIAL,
  fid integer NOT NULL default '0',
  title varchar(255) NOT NULL default '',
  link varchar(255) NOT NULL default '',
  author varchar(255) NOT NULL default '',
  description text,
  timestamp integer default NULL,
  PRIMARY KEY (iid)
);

--
-- Table structure for authmap
--

CREATE TABLE authmap (
  aid SERIAL,
  uid integer NOT NULL default '0',
  authname varchar(128) NOT NULL default '',
  module varchar(128) NOT NULL default '',
  PRIMARY KEY (aid),
  UNIQUE (authname)
);

--
-- Table structure for blocks
--

CREATE TABLE blocks (
  module varchar(64) NOT NULL default '',
  delta varchar(32) NOT NULL default '0',
  theme varchar(255) NOT NULL default '',
  status smallint NOT NULL default '0',
  weight smallint NOT NULL default '0',
  region varchar(64) DEFAULT 'left' NOT NULL,
  custom smallint NOT NULL default '0',
  throttle smallint NOT NULL default '0',
  visibility smallint NOT NULL default '0',
  pages text NOT NULL default ''
);

--
-- Table structure for book
--

CREATE TABLE book (
  vid integer NOT NULL default '0',
  nid integer NOT NULL default '0',
  parent integer NOT NULL default '0',
  weight smallint NOT NULL default '0',
  PRIMARY KEY (vid)
);
CREATE INDEX book_nid_idx ON book(nid);
CREATE INDEX book_parent_idx ON book(parent);

--
-- Table structure for boxes
--

CREATE TABLE boxes (
  bid SERIAL,
  title varchar(64) NOT NULL default '',
  body text default '',
  info varchar(128) NOT NULL default '',
  format smallint NOT NULL default '0',
  PRIMARY KEY (bid),
  UNIQUE (info)
);

--
-- Table structure for cache
--

CREATE TABLE cache (
  cid varchar(255) NOT NULL default '',
  data bytea default '',
  expire integer NOT NULL default '0',
  created integer NOT NULL default '0',
  headers text default '',
  PRIMARY KEY (cid)
);
CREATE INDEX cache_expire_idx ON cache(expire);

--
-- Table structure for comments
--

CREATE TABLE comments (
  cid SERIAL,
  pid integer NOT NULL default '0',
  nid integer NOT NULL default '0',
  uid integer NOT NULL default '0',
  subject varchar(64) NOT NULL default '',
  comment text NOT NULL default '',
  hostname varchar(128) NOT NULL default '',
  timestamp integer NOT NULL default '0',
  score integer NOT NULL default '0',
  status smallint NOT NULL default '0',
  format smallint NOT NULL default '0',
  thread varchar(255) default '',
  users text default '',
  name varchar(60) default NULL,
  mail varchar(64) default NULL,
  homepage varchar(255) default NULL,
  PRIMARY KEY (cid)
);
CREATE INDEX comments_nid_idx ON comments(nid);

--
-- Table structre for table 'contact'
--

CREATE TABLE contact (
  cid SERIAL,
  category varchar(255) NOT NULL default '',
  recipients text NOT NULL default '',
  reply text NOT NULL default '',
  weight smallint NOT NULL default '0',
  selected smallint NOT NULL default '0',
  PRIMARY KEY (cid),
  UNIQUE (category)
);

--
-- Table structre for table 'node_comment_statistics'
--

CREATE TABLE node_comment_statistics (
  nid integer NOT NULL,
  last_comment_timestamp integer NOT NULL default '0',
  last_comment_name varchar(60) default NULL,
  last_comment_uid integer NOT NULL default '0',
  comment_count integer NOT NULL default '0',
  PRIMARY KEY (nid)
);
CREATE INDEX node_comment_statistics_last_comment_timestamp_idx ON node_comment_statistics(last_comment_timestamp);

--
-- Table structure for directory
--

CREATE TABLE client (
  cid SERIAL,
  link varchar(255) NOT NULL default '',
  name varchar(128) NOT NULL default '',
  mail varchar(128) NOT NULL default '',
  slogan text NOT NULL default '',
  mission text NOT NULL default '',
  users integer NOT NULL default '0',
  nodes integer NOT NULL default '0',
  version varchar(35) NOT NULL default'',
  created integer NOT NULL default '0',
  changed integer NOT NULL default '0',
  PRIMARY KEY (cid)
);

--
-- Table structure for table 'client_system'
--

CREATE TABLE client_system (
  cid integer NOT NULL,
  name varchar(255) NOT NULL default '',
  type varchar(255) NOT NULL default '',
  PRIMARY KEY (cid,name)
);

--
-- Table structure for table 'files'
--

CREATE TABLE files (
  fid SERIAL,
  nid integer NOT NULL default 0,
  filename varchar(255) NOT NULL default '',
  filepath varchar(255) NOT NULL default '',
  filemime varchar(255) NOT NULL default '',
  filesize integer NOT NULL default 0,
  PRIMARY KEY (fid)
);

--
-- Table structure for table 'file_revisions'
--

CREATE TABLE file_revisions (
  fid integer NOT NULL default 0,
  vid integer NOT NULL default 0,
  description varchar(255) NOT NULL default '',
  list smallint NOT NULL default 0,
  PRIMARY KEY (fid, vid)
);

--
-- Table structure for table 'filter_formats'
--

CREATE TABLE filter_formats (
  format SERIAL,
  name varchar(255) NOT NULL default '',
  roles varchar(255) NOT NULL default '',
  cache smallint NOT NULL default '0',
  PRIMARY KEY (format),
  UNIQUE (name)
);

--
-- Table structure for table 'filters'
--

CREATE TABLE filters (
  format integer NOT NULL DEFAULT '0',
  module varchar(64) NOT NULL DEFAULT '',
  delta smallint NOT NULL DEFAULT 0,
  weight smallint DEFAULT '0' NOT NULL
);
CREATE INDEX filters_weight_idx ON filters(weight);

--
-- Table structure for table 'flood'
--

CREATE TABLE flood (
  event varchar(64) NOT NULL default '',
  hostname varchar(128) NOT NULL default '',
  timestamp integer NOT NULL default '0'
);

--
-- Table structure for table 'forum'
--

CREATE TABLE forum (
  nid integer NOT NULL default '0',
  vid integer NOT NULL default '0',
  tid integer NOT NULL default '0',
  PRIMARY KEY (vid)
);
CREATE INDEX forum_tid_idx ON forum(tid);
CREATE INDEX forum_nid_idx ON forum(nid);

--
-- Table structure for history
--

CREATE TABLE history (
  uid integer NOT NULL default '0',
  nid integer NOT NULL default '0',
  timestamp integer NOT NULL default '0',
  PRIMARY KEY (uid,nid)
);

--
-- Table structure for locales_meta
--

CREATE TABLE locales_meta (
  locale varchar(12) NOT NULL default '',
  name varchar(64) NOT NULL default '',
  enabled int4 NOT NULL default '0',
  isdefault int4 NOT NULL default '0',
  plurals int4 NOT NULL default '0',
  formula varchar(128) NOT NULL default '',
  PRIMARY KEY (locale)
);

--
-- Table structure for locales_source
--


CREATE TABLE locales_source (
  lid SERIAL,
  location varchar(255) NOT NULL default '',
  source text NOT NULL,
  PRIMARY KEY (lid)
);

--
-- Table structure for locales_target
--

CREATE TABLE locales_target (
  lid int4 NOT NULL default '0',
  translation text DEFAULT '' NOT NULL,
  locale varchar(12) NOT NULL default '',
  plid int4 NOT NULL default '0',
  plural int4 NOT NULL default '0'
);
CREATE INDEX locales_target_lid_idx ON locales_target(lid);
CREATE INDEX locales_target_locale_idx ON locales_target(locale);
CREATE INDEX locales_target_plid_idx ON locales_target(plid);
CREATE INDEX locales_target_plural_idx ON locales_target(plural);

--
-- Table structure for table 'menu'
--


CREATE SEQUENCE menu_mid_seq START 2;
CREATE TABLE menu (
  mid integer NOT NULL DEFAULT nextval('menu_mid_seq'),
  pid integer NOT NULL default '0',
  path varchar(255) NOT NULL default '',
  title varchar(255) NOT NULL default '',
  description varchar(255) NOT NULL default '',
  weight smallint NOT NULL default '0',
  type smallint NOT NULL default '0',
  PRIMARY KEY (mid)
);

--
-- Table structure for node
--

CREATE TABLE node (
  nid SERIAL,
  vid integer NOT NULL default '0',
  type varchar(32) NOT NULL default '',
  title varchar(128) NOT NULL default '',
  uid integer NOT NULL default '0',
  status integer NOT NULL default '1',
  created integer NOT NULL default '0',
  changed integer NOT NULL default '0',
  comment integer NOT NULL default '0',
  promote integer NOT NULL default '0',
  moderate integer NOT NULL default '0',
  sticky integer NOT NULL default '0',
  PRIMARY KEY (nid, vid)
);
CREATE INDEX node_nid_idx ON node(nid);
CREATE INDEX node_type_idx ON node(type);
CREATE INDEX node_title_type_idx ON node(title,type);
CREATE INDEX node_status_idx ON node(status);
CREATE INDEX node_uid_idx ON node(uid);
CREATE UNIQUE INDEX node_vid_idx ON node(vid);
CREATE INDEX node_moderate_idx ON node (moderate);
CREATE INDEX node_promote_status_idx ON node (promote, status);
CREATE INDEX node_created_idx ON node(created);
CREATE INDEX node_changed_idx ON node(changed);
CREATE INDEX node_status_type_nid_idx ON node(status,type,nid);

--
-- Table structure for table `node_access`
--

CREATE TABLE node_access (
  nid SERIAL,
  gid integer NOT NULL default '0',
  realm varchar(255) NOT NULL default '',
  grant_view smallint NOT NULL default '0',
  grant_update smallint NOT NULL default '0',
  grant_delete smallint NOT NULL default '0',
  PRIMARY KEY (nid,gid,realm)
);

--
-- Table structure for table 'node_revisions'
--

CREATE TABLE node_revisions (
  nid integer NOT NULL default '0',
  vid integer NOT NULL default '0',
  uid integer NOT NULL default '0',
  title varchar(128) NOT NULL default '',
  body text NOT NULL default '',
  teaser text NOT NULL default '',
  log text NOT NULL default '',
  timestamp integer NOT NULL default '0',
  format int NOT NULL default '0',
  PRIMARY KEY  (vid)
);
CREATE INDEX node_revisions_nid_idx ON node_revisions(nid);
CREATE INDEX node_revisions_uid_idx ON node_revisions(uid);
CREATE SEQUENCE node_revisions_vid_seq INCREMENT 1 START 1;

--
-- Table structure for table 'url_alias'
--

CREATE TABLE profile_fields (
  fid serial,
  title varchar(255) default NULL,
  name varchar(128) default NULL,
  explanation TEXT default NULL,
  category varchar(255) default NULL,
  page varchar(255) default NULL,
  type varchar(128) default NULL,
  weight smallint DEFAULT '0' NOT NULL,
  required smallint DEFAULT '0' NOT NULL,
  register smallint DEFAULT '0' NOT NULL,
  visibility smallint DEFAULT '0' NOT NULL,
  autocomplete smallint DEFAULT '0' NOT NULL,
  options text,
  UNIQUE (name),
  PRIMARY KEY (fid)
);
CREATE INDEX profile_fields_category_idx ON profile_fields (category);

--
-- Table structure for table 'profile_values'
--

CREATE TABLE profile_values (
  fid integer default '0',
  uid integer default '0',
  value text
);
CREATE INDEX profile_values_uid ON profile_values (uid);
CREATE INDEX profile_values_fid ON profile_values (fid);

CREATE TABLE url_alias (
  pid serial,
  src varchar(128) NOT NULL default '',
  dst varchar(128) NOT NULL default '',
  PRIMARY KEY (pid)
);
CREATE UNIQUE INDEX url_alias_dst_idx ON url_alias(dst);
CREATE INDEX url_alias_src_idx ON url_alias(src);

--
-- Table structure for permission
--

CREATE TABLE permission (
  rid integer NOT NULL default '0',
  perm text default '',
  tid integer NOT NULL default '0'
);
CREATE INDEX permission_rid_idx ON permission(rid);

--
-- Table structure for poll
--

CREATE TABLE poll (
  nid integer NOT NULL default '0',
  runtime integer NOT NULL default '0',
  active integer NOT NULL default '0',
  PRIMARY KEY (nid)
);

--
-- Table structure for poll_votes
--

CREATE TABLE poll_votes (
  nid int NOT NULL,
  uid int NOT NULL default 0,
  hostname varchar(128) NOT NULL default ''
);
CREATE INDEX poll_votes_nid_idx ON poll_votes (nid);
CREATE INDEX poll_votes_uid_idx ON poll_votes (uid);
CREATE INDEX poll_votes_hostname_idx ON poll_votes (hostname);

--
-- Table structure for poll_choices
--

CREATE TABLE poll_choices (
  chid SERIAL,
  nid integer NOT NULL default '0',
  chtext varchar(128) NOT NULL default '',
  chvotes integer NOT NULL default '0',
  chorder integer NOT NULL default '0',
  PRIMARY KEY (chid)
);
CREATE INDEX poll_choices_nid_idx ON poll_choices(nid);

--
-- Table structure for role
--

CREATE TABLE role (
  rid SERIAL,
  name varchar(32) NOT NULL default '',
  PRIMARY KEY (rid),
  UNIQUE (name)
);

--
-- Table structure for table 'search_dataset'
--
CREATE TABLE search_dataset (
  sid integer NOT NULL default '0',
  type varchar(16) default NULL,
  data text NOT NULL default ''
);
CREATE INDEX search_dataset_sid_type_idx ON search_dataset(sid, type);

--
-- Table structure for search_index
--

CREATE TABLE search_index (
  word varchar(50) NOT NULL default '',
  sid integer NOT NULL default '0',
  type varchar(16) default NULL,
  fromsid integer NOT NULL default '0',
  fromtype varchar(16) default NULL,
  score float default NULL
);
CREATE INDEX search_index_sid_type_idx ON search_index(sid, type);
CREATE INDEX search_index_fromsid_fromtype_idx ON search_index(fromsid, fromtype);
CREATE INDEX search_index_word_idx ON search_index(word);

--
-- Table structures for search_total
--

CREATE TABLE search_total (
  word varchar(50) NOT NULL default '',
  count float default NULL,
  PRIMARY KEY(word)
);

--
-- Table structure for sessions
--

CREATE TABLE sessions (
  uid integer not null,
  sid varchar(32) NOT NULL default '',
  hostname varchar(128) NOT NULL default '',
  timestamp integer NOT NULL default '0',
  cache integer NOT NULL default '0',
  session text,
  PRIMARY KEY (sid)
);
CREATE INDEX sessions_uid_idx ON sessions(uid);
CREATE INDEX sessions_timestamp_idx ON sessions(timestamp);

--
-- Table structure for sequences
-- This is only used under MySQL, co commented out
--
--
-- CREATE TABLE sequences (
--   name varchar(255) NOT NULL,
--   id integer NOT NULL,
--   PRIMARY KEY (name)
-- );

--
-- Table structure for table 'node_counter'
--

CREATE TABLE node_counter (
  nid integer NOT NULL default '0',
  totalcount integer NOT NULL default '0',
  daycount integer NOT NULL default '0',
  timestamp integer NOT NULL default '0',
  PRIMARY KEY (nid)
);
CREATE INDEX node_counter_totalcount_idx ON node_counter(totalcount);
CREATE INDEX node_counter_daycount_idx ON node_counter(daycount);
CREATE INDEX node_counter_timestamp_idx ON node_counter(timestamp);

--
-- Table structure for system
--

CREATE TABLE system (
  filename varchar(255) NOT NULL default '',
  name varchar(255) NOT NULL default '',
  type varchar(255) NOT NULL default '',
  description varchar(255) NOT NULL default '',
  status integer NOT NULL default '0',
  throttle smallint NOT NULL default '0',
  bootstrap integer NOT NULL default '0',
  schema_version smallint NOT NULL default -1,
  weight smallint NOT NULL default 0,
  PRIMARY KEY (filename)
);
CREATE INDEX system_weight_idx ON system(weight);

--
-- Table structure for term_data
--

CREATE TABLE term_data (
  tid SERIAL,
  vid integer NOT NULL default '0',
  name varchar(255) NOT NULL default '',
  description text default '',
  weight smallint NOT NULL default '0',
  PRIMARY KEY (tid)
);
CREATE INDEX term_data_vid_idx ON term_data(vid);

--
-- Table structure for term_hierarchy
--

CREATE TABLE term_hierarchy (
  tid integer NOT NULL default '0',
  parent integer NOT NULL default '0',
  PRIMARY KEY (tid, parent)
);
CREATE INDEX term_hierarchy_tid_idx ON term_hierarchy(tid);
CREATE INDEX term_hierarchy_parent_idx ON term_hierarchy(parent);

--
-- Table structure for term_node
--

CREATE TABLE term_node (
  nid integer NOT NULL default '0',
  tid integer NOT NULL default '0',
  PRIMARY KEY (tid,nid)
);
CREATE INDEX term_node_nid_idx ON term_node(nid);
CREATE INDEX term_node_tid_idx ON term_node(tid);

--
-- Table structure for term_relation
--

CREATE TABLE term_relation (
  tid1 integer NOT NULL default '0',
  tid2 integer NOT NULL default '0'
);
CREATE INDEX term_relation_tid1_idx ON term_relation(tid1);
CREATE INDEX term_relation_tid2_idx ON term_relation(tid2);

--
-- Table structure for term_synonym
--

CREATE TABLE term_synonym (
  tid integer NOT NULL default '0',
  name varchar(255) NOT NULL default ''
);
CREATE INDEX term_synonym_tid_idx ON term_synonym(tid);
CREATE INDEX term_synonym_name_idx ON term_synonym(name);

--
-- Table structure for users
--

CREATE TABLE users (
  uid integer NOT NULL default '0',
  name varchar(60) NOT NULL default '',
  pass varchar(32) NOT NULL default '',
  mail varchar(64) default '',
  mode smallint NOT NULL default '0',
  sort smallint default '0',
  threshold smallint default '0',
  theme varchar(255) NOT NULL default '',
  signature varchar(255) NOT NULL default '',
  created integer NOT NULL default '0',
  access integer NOT NULL default '0',
  login integer NOT NULL default '0',
  status smallint NOT NULL default '0',
  timezone varchar(8) default NULL,
  language varchar(12) NOT NULL default '',
  picture varchar(255) NOT NULL DEFAULT '',
  init varchar(64) default '',
  data text default '',
  PRIMARY KEY (uid),
  UNIQUE (name)
);
CREATE INDEX users_access_idx ON users(access);

CREATE SEQUENCE users_uid_seq INCREMENT 1 START 1;

--
-- Table structure for users_roles
--

CREATE TABLE users_roles (
  uid integer NOT NULL default '0',
  rid integer NOT NULL default '0',
  PRIMARY KEY (uid, rid)
);

--
-- Table structure for variable
--

CREATE TABLE variable (
  name varchar(48) NOT NULL default '',
  value text NOT NULL default '',
  PRIMARY KEY (name)
);

--
-- Table structure for vocabulary
--

CREATE TABLE vocabulary (
  vid SERIAL,
  name varchar(255) NOT NULL default '',
  description text default '',
  help varchar(255) NOT NULL default '',
  relations smallint NOT NULL default '0',
  hierarchy smallint NOT NULL default '0',
  multiple smallint NOT NULL default '0',
  required smallint NOT NULL default '0',
  tags smallint NOT NULL default '0',
  module varchar(255) NOT NULL default '',
  weight smallint NOT NULL default '0',
  PRIMARY KEY (vid)
);

--
-- Table structure for vocabulary_node_types
--

CREATE TABLE vocabulary_node_types (
  vid integer NOT NULL default '0',
  type varchar(32) NOT NULL default '',
  PRIMARY KEY (vid, type)
);

--
-- Table structure for watchdog
--

CREATE TABLE watchdog (
  wid SERIAL,
  uid integer NOT NULL default '0',
  type varchar(16) NOT NULL default '',
  message text NOT NULL default '',
  severity smallint NOT NULL default '0',
  link text NOT NULL default '',
  location text NOT NULL default '',
  referer text NOT NULL default '',
  hostname varchar(128) NOT NULL default '',
  timestamp integer NOT NULL default '0',
  PRIMARY KEY (wid)
);

--
-- Insert some default values
--

INSERT INTO system (filename, name, type, description, status, throttle, bootstrap, schema_version) VALUES ('modules/block.module', 'block', 'module', '', 1, 0, 0, 0);
INSERT INTO system (filename, name, type, description, status, throttle, bootstrap, schema_version) VALUES ('modules/comment.module', 'comment', 'module', '', 1, 0, 0, 0);
INSERT INTO system (filename, name, type, description, status, throttle, bootstrap, schema_version) VALUES ('modules/filter.module', 'filter', 'module', '', 1, 0, 0, 0);
INSERT INTO system (filename, name, type, description, status, throttle, bootstrap, schema_version) VALUES ('modules/help.module', 'help', 'module', '', 1, 0, 0, 0);
INSERT INTO system (filename, name, type, description, status, throttle, bootstrap, schema_version) VALUES ('modules/menu.module', 'menu', 'module', '', 1, 0, 0, 0);
INSERT INTO system (filename, name, type, description, status, throttle, bootstrap, schema_version) VALUES ('modules/node.module', 'node', 'module', '', 1, 0, 0, 0);
INSERT INTO system (filename, name, type, description, status, throttle, bootstrap, schema_version) VALUES ('modules/page.module', 'page', 'module', '', 1, 0, 0, 0);
INSERT INTO system (filename, name, type, description, status, throttle, bootstrap, schema_version) VALUES ('modules/story.module', 'story', 'module', '', 1, 0, 0, 0);
INSERT INTO system (filename, name, type, description, status, throttle, bootstrap, schema_version) VALUES ('modules/system.module', 'system', 'module', '', 1, 0, 0, 0);
INSERT INTO system (filename, name, type, description, status, throttle, bootstrap, schema_version) VALUES ('modules/taxonomy.module', 'taxonomy', 'module', '', 1, 0, 0, 0);
INSERT INTO system (filename, name, type, description, status, throttle, bootstrap, schema_version) VALUES ('modules/user.module', 'user', 'module', '', 1, 0, 0, 0);
INSERT INTO system (filename, name, type, description, status, throttle, bootstrap, schema_version) VALUES ('modules/watchdog.module', 'watchdog', 'module', '', 1, 0, 0, 0);
INSERT INTO system (filename, name, type, description, status, throttle, bootstrap, schema_version) VALUES ('themes/engines/phptemplate/phptemplate.engine', 'phptemplate', 'theme_engine', '', 1, 0, 0, 0);
INSERT INTO system (filename, name, type, description, status, throttle, bootstrap, schema_version) VALUES ('themes/bluemarine/page.tpl.php', 'bluemarine', 'theme', 'themes/engines/phptemplate/phptemplate.engine', 1, 0, 0, 0);

INSERT INTO users(uid,name,mail) VALUES(0,'','');

INSERT INTO role (name) VALUES ('anonymous user');
INSERT INTO role (name) VALUES ('authenticated user');

INSERT INTO permission VALUES (1,'access content',0);
INSERT INTO permission VALUES (2,'access comments, access content, post comments, post comments without approval',0);

INSERT INTO variable(name,value) VALUES('theme_default', 's:10:"bluemarine";');

INSERT INTO blocks(module,delta,theme,status) VALUES('user', 0, 'bluemarine', 1);
INSERT INTO blocks(module,delta,theme,status) VALUES('user', 1, 'bluemarine', 1);

INSERT INTO node_access VALUES (0, 0, 'all', 1, 0, 0);

INSERT INTO filter_formats (name, roles, cache) VALUES ('Filtered HTML',',1,2,',1);
INSERT INTO filter_formats (name, roles, cache) VALUES ('PHP code','',0);
INSERT INTO filter_formats (name, roles, cache) VALUES ('Full HTML','',1);
INSERT INTO filters VALUES (1,'filter',0,0);
INSERT INTO filters VALUES (1,'filter',2,1);
INSERT INTO filters VALUES (2,'filter',1,0);
INSERT INTO filters VALUES (3,'filter',2,0);
INSERT INTO variable (name,value) VALUES ('filter_html_1','i:1;');

INSERT INTO locales_meta (locale, name, enabled, isdefault) VALUES ('en', 'English', '1', '1');

INSERT INTO variable (name, value) VALUES ('node_options_forum', 'a:1:{i:0;s:6:"status";}');

INSERT INTO menu(pid, path, title, description, weight, type) VALUES (0, '', 'Primary links', '', 0, 115);
INSERT INTO variable VALUES ('menu_primary_menu', 'i:2;');
INSERT INTO variable VALUES ('menu_secondary_menu', 'i:2;');

---
--- Functions
---

--- Always installed in 'public' as prefix isn't appended to function names
SET search_path TO public;

CREATE OR REPLACE FUNCTION "greatest"(numeric, numeric) RETURNS numeric AS '
  SELECT CASE WHEN (($1 > $2) OR ($2 IS NULL)) THEN $1 ELSE $2 END;
' LANGUAGE 'sql';

CREATE OR REPLACE FUNCTION "greatest"(numeric, numeric, numeric) RETURNS numeric AS '
  SELECT greatest($1, greatest($2, $3));
' LANGUAGE 'sql';

CREATE OR REPLACE FUNCTION "rand"() RETURNS float AS '
  SELECT random();
' LANGUAGE 'sql';

CREATE OR REPLACE FUNCTION "concat"(text, text) RETURNS text AS '
  SELECT $1 || $2;
' LANGUAGE 'sql';

CREATE OR REPLACE FUNCTION "if"(boolean, text, text) RETURNS text AS '
  SELECT CASE WHEN $1 THEN $2 ELSE $3 END;
' LANGUAGE 'sql';

CREATE OR REPLACE FUNCTION "if"(boolean, integer, integer) RETURNS integer AS '
  SELECT CASE WHEN $1 THEN $2 ELSE $3 END;
' LANGUAGE 'sql';