Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
Warden
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pavel Valach
Warden
Commits
a79deda8
Commit
a79deda8
authored
2 years ago
by
Jakub Maloštík
Browse files
Options
Downloads
Patches
Plain Diff
Make warden_3.0_postgres.sql idempotent
parent
e0b6cf88
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
warden_server/warden_3.0_postgres.sql
+17
-20
17 additions, 20 deletions
warden_server/warden_3.0_postgres.sql
with
17 additions
and
20 deletions
warden_server/warden_3.0_postgres.sql
+
17
−
20
View file @
a79deda8
SET
TimeZone
=
'+00:00'
;
SET
TimeZone
=
'+00:00'
;
CREATE
COLLATION
case_insensitive
(
CREATE
COLLATION
IF
NOT
EXISTS
case_insensitive
(
provider
=
icu
,
provider
=
icu
,
locale
=
'und-u-ks-level2'
,
locale
=
'und-u-ks-level2'
,
deterministic
=
false
deterministic
=
false
...
@@ -18,14 +18,14 @@ CREATE COLLATION case_insensitive (
...
@@ -18,14 +18,14 @@ CREATE COLLATION case_insensitive (
-- Table structure for table "categories"
-- Table structure for table "categories"
--
--
CREATE
TABLE
"categories"
(
CREATE
TABLE
IF
NOT
EXISTS
"categories"
(
"id"
int
NOT
NULL
UNIQUE
CHECK
(
"id"
>=
0
),
"id"
int
NOT
NULL
UNIQUE
CHECK
(
"id"
>=
0
),
"category"
text
NOT
NULL
COLLATE
case_insensitive
,
"category"
text
NOT
NULL
COLLATE
case_insensitive
,
"subcategory"
text
DEFAULT
NULL
COLLATE
case_insensitive
,
"subcategory"
text
DEFAULT
NULL
COLLATE
case_insensitive
,
"cat_subcat"
text
NOT
NULL
COLLATE
case_insensitive
"cat_subcat"
text
NOT
NULL
COLLATE
case_insensitive
);
);
CREATE
INDEX
"cat_sub"
ON
"categories"
(
"cat_subcat"
);
CREATE
INDEX
IF
NOT
EXISTS
"cat_sub"
ON
"categories"
(
"cat_subcat"
);
-- --------------------------------------------------------
-- --------------------------------------------------------
...
@@ -33,7 +33,7 @@ CREATE INDEX "cat_sub" ON "categories" ("cat_subcat");
...
@@ -33,7 +33,7 @@ CREATE INDEX "cat_sub" ON "categories" ("cat_subcat");
-- Table structure for table "clients"
-- Table structure for table "clients"
--
--
CREATE
TABLE
"clients"
(
CREATE
TABLE
IF
NOT
EXISTS
"clients"
(
"id"
SERIAL
PRIMARY
KEY
,
"id"
SERIAL
PRIMARY
KEY
,
"registered"
timestamp
NOT
NULL
DEFAULT
'1970-01-01 00:00:00'
,
"registered"
timestamp
NOT
NULL
DEFAULT
'1970-01-01 00:00:00'
,
"requestor"
text
NOT
NULL
COLLATE
case_insensitive
,
"requestor"
text
NOT
NULL
COLLATE
case_insensitive
,
...
@@ -48,8 +48,8 @@ CREATE TABLE "clients" (
...
@@ -48,8 +48,8 @@ CREATE TABLE "clients" (
"test"
smallint
NOT
NULL
DEFAULT
'0'
CHECK
(
"test"
>=
0
)
"test"
smallint
NOT
NULL
DEFAULT
'0'
CHECK
(
"test"
>=
0
)
);
);
CREATE
INDEX
"clients_1"
ON
"clients"
(
"valid"
,
"secret"
,
"hostname"
);
CREATE
INDEX
IF
NOT
EXISTS
"clients_1"
ON
"clients"
(
"valid"
,
"secret"
,
"hostname"
);
CREATE
INDEX
"clients_2"
ON
"clients"
(
"valid"
,
"name"
);
CREATE
INDEX
IF
NOT
EXISTS
"clients_2"
ON
"clients"
(
"valid"
,
"name"
);
-- --------------------------------------------------------
-- --------------------------------------------------------
...
@@ -57,18 +57,16 @@ CREATE INDEX "clients_2" ON "clients" ("valid", "name");
...
@@ -57,18 +57,16 @@ CREATE INDEX "clients_2" ON "clients" ("valid", "name");
-- Table structure for table "events"
-- Table structure for table "events"
--
--
CREATE
TABLE
"events"
(
CREATE
TABLE
IF
NOT
EXISTS
"events"
(
"id"
BIGSERIAL
PRIMARY
KEY
,
"id"
bigint
PRIMARY
KEY
GENERATED
ALWAYS
AS
IDENTITY
(
MINVALUE
2
)
,
"received"
timestamp
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
,
"received"
timestamp
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
,
"client_id"
int
NOT
NULL
REFERENCES
"clients"
(
"id"
),
"client_id"
int
NOT
NULL
REFERENCES
"clients"
(
"id"
),
"data"
bytea
NOT
NULL
,
"data"
bytea
NOT
NULL
,
"valid"
smallint
NOT
NULL
DEFAULT
'1'
CHECK
(
"valid"
>=
0
)
"valid"
smallint
NOT
NULL
DEFAULT
'1'
CHECK
(
"valid"
>=
0
)
);
);
CREATE
INDEX
"id"
ON
"events"
(
"id"
,
"client_id"
);
CREATE
INDEX
IF
NOT
EXISTS
"id"
ON
"events"
(
"id"
,
"client_id"
);
CREATE
INDEX
"received"
ON
"events"
(
"received"
);
CREATE
INDEX
IF
NOT
EXISTS
"received"
ON
"events"
(
"received"
);
SELECT
nextval
(
'events_id_seq'
);
-- AUTO_INCREMENT = 2
-- --------------------------------------------------------
-- --------------------------------------------------------
...
@@ -76,28 +74,27 @@ SELECT nextval('events_id_seq'); -- AUTO_INCREMENT = 2
...
@@ -76,28 +74,27 @@ SELECT nextval('events_id_seq'); -- AUTO_INCREMENT = 2
-- Table structure for table "event_category_mapping"
-- Table structure for table "event_category_mapping"
--
--
CREATE
TABLE
"event_category_mapping"
(
CREATE
TABLE
IF
NOT
EXISTS
"event_category_mapping"
(
"event_id"
bigint
NOT
NULL
REFERENCES
"events"
(
"id"
)
ON
DELETE
CASCADE
,
"event_id"
bigint
NOT
NULL
REFERENCES
"events"
(
"id"
)
ON
DELETE
CASCADE
,
"category_id"
int
NOT
NULL
,
"category_id"
int
NOT
NULL
,
PRIMARY
KEY
(
"event_id"
,
"category_id"
),
PRIMARY
KEY
(
"event_id"
,
"category_id"
),
CONSTRAINT
"event_category_mapping_category_id_fk"
FOREIGN
KEY
(
"category_id"
)
REFERENCES
"categories"
(
"id"
)
CONSTRAINT
"event_category_mapping_category_id_fk"
FOREIGN
KEY
(
"category_id"
)
REFERENCES
"categories"
(
"id"
)
);
);
-- --------------------------------------------------------
-- --------------------------------------------------------
--
--
-- Table structure for table "last_events"
-- Table structure for table "last_events"
--
--
CREATE
TABLE
"last_events"
(
CREATE
TABLE
IF
NOT
EXISTS
"last_events"
(
"id"
SERIAL
PRIMARY
KEY
,
"id"
SERIAL
PRIMARY
KEY
,
"client_id"
int
NOT
NULL
REFERENCES
"clients"
(
"id"
),
"client_id"
int
NOT
NULL
REFERENCES
"clients"
(
"id"
),
"event_id"
bigint
REFERENCES
"events"
(
"id"
),
"event_id"
bigint
REFERENCES
"events"
(
"id"
),
"timestamp"
timestamp
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
"timestamp"
timestamp
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
);
);
CREATE
INDEX
"client_id"
ON
"last_events"
(
"client_id"
,
"event_id"
);
CREATE
INDEX
IF
NOT
EXISTS
"client_id"
ON
"last_events"
(
"client_id"
,
"event_id"
);
-- --------------------------------------------------------
-- --------------------------------------------------------
...
@@ -105,13 +102,13 @@ CREATE INDEX "client_id" ON "last_events" ("client_id", "event_id");
...
@@ -105,13 +102,13 @@ CREATE INDEX "client_id" ON "last_events" ("client_id", "event_id");
-- Table structure for table "tags"
-- Table structure for table "tags"
--
--
CREATE
TABLE
"tags"
(
CREATE
TABLE
IF
NOT
EXISTS
"tags"
(
"id"
int
NOT
NULL
UNIQUE
CHECK
(
"id"
>=
0
),
"id"
int
NOT
NULL
UNIQUE
CHECK
(
"id"
>=
0
),
"tag"
text
NOT
NULL
COLLATE
case_insensitive
"tag"
text
NOT
NULL
COLLATE
case_insensitive
);
);
CREATE
INDEX
"id_tag_name"
ON
"tags"
(
"id"
,
"tag"
);
CREATE
INDEX
IF
NOT
EXISTS
"id_tag_name"
ON
"tags"
(
"id"
,
"tag"
);
CREATE
INDEX
"tag_name"
ON
"tags"
(
"tag"
);
CREATE
INDEX
IF
NOT
EXISTS
"tag_name"
ON
"tags"
(
"tag"
);
-- --------------------------------------------------------
-- --------------------------------------------------------
...
@@ -119,7 +116,7 @@ CREATE INDEX "tag_name" ON "tags" ("tag");
...
@@ -119,7 +116,7 @@ CREATE INDEX "tag_name" ON "tags" ("tag");
-- Table structure for table "event_tag_mapping"
-- Table structure for table "event_tag_mapping"
--
--
CREATE
TABLE
"event_tag_mapping"
(
CREATE
TABLE
IF
NOT
EXISTS
"event_tag_mapping"
(
"event_id"
bigint
NOT
NULL
REFERENCES
"events"
(
"id"
)
ON
DELETE
CASCADE
,
"event_id"
bigint
NOT
NULL
REFERENCES
"events"
(
"id"
)
ON
DELETE
CASCADE
,
"tag_id"
int
NOT
NULL
,
"tag_id"
int
NOT
NULL
,
PRIMARY
KEY
(
"event_id"
,
"tag_id"
),
PRIMARY
KEY
(
"event_id"
,
"tag_id"
),
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment