schema.pgsql.sql 3.27 KB
Newer Older
Cyril Vazquez's avatar
Cyril Vazquez committed
1
2
DROP SCHEMA IF EXISTS "medona" CASCADE;

3
CREATE SCHEMA "medona";
Cyril Vazquez's avatar
Cyril Vazquez committed
4
5
6
7
8
9
10
11
12
13
14

-- Table: "medona"."archivalAgreement"

-- DROP TABLE "medona"."archivalAgreement";

CREATE TABLE "medona"."archivalAgreement"
(
  "archivalAgreementId" text NOT NULL,
  "name" text NOT NULL,
  "reference" text NOT NULL,
  "description" text,
15

Cyril Vazquez's avatar
Cyril Vazquez committed
16
17
  "archivalProfileReference" text,
  "serviceLevelReference" text,
18

Cyril Vazquez's avatar
Cyril Vazquez committed
19
20
21
22
23
24
25
  "archiverOrgRegNumber" text NOT NULL,
  "depositorOrgRegNumber" text NOT NULL,
  "originatorOrgIds" text,

  "beginDate" date,
  "endDate" date,
  "enabled" boolean,
26

Cyril Vazquez's avatar
Cyril Vazquez committed
27
  "allowedFormats" text,
28

Cyril Vazquez's avatar
Cyril Vazquez committed
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
  "maxSizeAgreement" integer,
  "maxSizeTransfer" integer,
  "maxSizeDay" integer,
  "maxSizeWeek" integer,
  "maxSizeMonth" integer,
  "maxSizeYear" integer,

  "signed" boolean,
  "autoTransferAcceptance" boolean,
  "processSmallArchive" boolean,

  PRIMARY KEY ("archivalAgreementId"),
  UNIQUE ("reference")
)
 WITH (
  OIDS=FALSE
);

-- Table: "medona"."message"

-- DROP TABLE "medona"."message";

CREATE TABLE "medona"."message"
(
  "messageId" text NOT NULL,
  "schema" text,
  "type" text NOT NULL,
  "status" text NOT NULL,
57

Cyril Vazquez's avatar
Cyril Vazquez committed
58
59
  "date" timestamp NOT NULL,
  "reference" text NOT NULL,
60

Cyril Vazquez's avatar
Cyril Vazquez committed
61
62
63
64
65
66
67
68
69
70
  "accountId" text,
  "senderOrgRegNumber" text NOT NULL,
  "senderOrgName" text,
  "recipientOrgRegNumber" text NOT NULL,
  "recipientOrgName" text,

  "archivalAgreementReference" text,
  "replyCode" text,
  "operationDate" timestamp,
  "receptionDate" timestamp,
71

Cyril Vazquez's avatar
Cyril Vazquez committed
72
73
74
75
76
77
78
79
  "relatedReference" text,
  "requestReference" text,
  "replyReference" text,
  "authorizationReference" text,
  "authorizationReason" text,
  "authorizationRequesterOrgRegNumber" text,

  "derogation" boolean,
80

Cyril Vazquez's avatar
Cyril Vazquez committed
81
82
  "dataObjectCount" integer,
  "size" numeric,
83

Cyril Vazquez's avatar
Cyril Vazquez committed
84
85
86
87
88
89
90
  "data" text,
  "path" text,

  "active" boolean,
  "archived" boolean,
  "isIncoming" boolean,

Cyril Vazquez's avatar
Cyril Vazquez committed
91
92
  "comment" text,

Cyril Vazquez's avatar
Cyril Vazquez committed
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
  PRIMARY KEY ("messageId"),
  UNIQUE ("type", "reference", "senderOrgRegNumber")
)
WITH (
  OIDS=FALSE
);


-- Table: medona."messageComment"

-- DROP TABLE medona."messageComment";

CREATE TABLE medona."messageComment"
(
  "messageId" text,
  "comment" text,
  "commentId" text NOT NULL,
  PRIMARY KEY ("commentId"),
  UNIQUE ("messageId", comment),
  FOREIGN KEY ("messageId")
      REFERENCES "medona"."message" ("messageId") MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION
)
WITH (
  OIDS=FALSE
);

CREATE TABLE medona."unitIdentifier"
(
  "messageId" text NOT NULL,
  "objectClass" text NOT NULL,
  "objectId" text NOT NULL,
  FOREIGN KEY ("messageId")
      REFERENCES "medona"."message" ("messageId") MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION,
  UNIQUE ("messageId", "objectClass", "objectId")
);

CREATE TABLE medona."controlAuthority"
(
  "originatorOrgUnitId" text NOT NULL,
  "controlAuthorityOrgUnitId" text NOT NULL,
  PRIMARY KEY ("originatorOrgUnitId")
136
137
138
139
140
141
142
143
144
145
146
);

CREATE INDEX "medona_message_recipientOrgRegNumber_idx" ON "medona"."message" USING btree ("recipientOrgRegNumber");

CREATE INDEX "medona_message_date_idx" ON "medona"."message" USING btree ("date");

CREATE INDEX "medona_message_status_active_idx" ON "medona"."message" USING btree ("status", "active");

CREATE INDEX "medona_unitIdentifier_messageId_idx" ON "medona"."unitIdentifier" USING btree ("messageId");

CREATE INDEX "medona_unitIdentifier_objectClass_idx" ON "medona"."unitIdentifier" USING btree ("objectClass", "objectId");