Skip to content

Commit

Permalink
Docker compose für Postgres 15 container, einige SQL-Init-Scripte kor…
Browse files Browse the repository at this point in the history
…rigiert
  • Loading branch information
commel committed Sep 30, 2023
1 parent fc38593 commit 74202e8
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 39 deletions.
3 changes: 0 additions & 3 deletions doc/Dockerfile

This file was deleted.

32 changes: 17 additions & 15 deletions doc/db2/01_schema/02_authentication.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,29 @@ create table if not exists roles(
id integer primary key default nextval('hibernate_sequence'),
code varchar(255) not null unique,

access_level integer check (level > 0),
access_level integer check (access_level > 0),

created timestamptz not null default CURRENT_TIMESTAMP,
updated timestamptz not null default CURRENT_TIMESTAMP
);

create type password_type as enum ('md5', 'bcrypt');

create table if not exists users (
id integer primary key default nextval('hibernate_sequence'),

login varchar(255) not null unique,
email varchar(255) not null unique,

drupalid integer,

hashtype password_type not null,
digest varchar(255) not null,

created timestamptz not null default CURRENT_TIMESTAMP,
updated timestamptz not null default CURRENT_TIMESTAMP
);

create table if not exists user_status(
id integer primary key not null default nextval('hibernate_sequence'),

Expand Down Expand Up @@ -41,20 +56,7 @@ create table if not exists user_data(
updated timestamptz not null default CURRENT_TIMESTAMP
);

create table if not exists users (
id integer primary key default nextval('hibernate_sequence'),

login varchar(255) not null unique,
email varchar(255) not null unique,

drupalid integer,

hashtype password_type not null,
digest varchar(255) not null,

created timestamptz not null default CURRENT_TIMESTAMP,
updated timestamptz not null default CURRENT_TIMESTAMP
);


create table if not exists user_roles (
userid integer not null references users(id),
Expand Down
6 changes: 3 additions & 3 deletions doc/db2/01_schema/10_search.sql
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ SELECT
setweight(to_tsvector(article_revisions.title7_lang::regconfig, coalesce(unaccent(article_revisions.title7), '')), 'A') || setweight(to_tsvector('german', coalesce(article_revisions.content, '')), 'B') -- content will be mostly german
-- setweight(to_tsvector(name_lang::regconfig, tags.name), 'C')
AS document,
'article' :: nodetype AS doctype
'article' :: node_type AS doctype
FROM article_revisions
INNER JOIN articles a on a.revisionid = article_revisions.id
LEFT JOIN node_tags ON node_tags.nodeid = article_revisions.nodeid
Expand Down Expand Up @@ -53,7 +53,7 @@ SELECT
setweight(to_tsvector(news_revisions.title_lang::regconfig, unaccent(news_revisions.title)), 'A') || setweight(to_tsvector('german', coalesce(news_revisions.content, '')), 'B') -- content will be mostly german
-- setweight(to_tsvector(name_lang::regconfig, tags.name), 'C')
AS document,
'news' :: nodetype AS doctype
'news' :: node_type AS doctype
FROM news_revisions
INNER JOIN news n on n.revisionid = news_revisions.id
LEFT JOIN node_tags ON node_tags.nodeid = news_revisions.nodeid
Expand Down Expand Up @@ -84,7 +84,7 @@ union -- ab hier forumthreads
'' as tags,
setweight(to_tsvector(ft.title_lang::regconfig, unaccent(ft.title)), 'A') || setweight(to_tsvector('german', coalesce(ft.content, '')), 'B') -- content will be mostly german
as document,
'thread' :: nodetype as doctype
'thread' :: node_type as doctype
from forum_threads ft
inner join forums on forums.id = ft.forumid
inner join node_status ns on ns.nodeid = ft.nodeid
Expand Down
38 changes: 20 additions & 18 deletions doc/db2/02_data/01_roles_taggroups_forums.sql
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
-- 1. Roles
INSERT INTO roles (id, code, level) VALUES (nextval('hibernate_sequence'), 'ADMIN', 1);
INSERT INTO roles (id, code, level) VALUES (nextval('hibernate_sequence'), 'HOLARSE-CORE', 10);
INSERT INTO roles (id, code, level) VALUES (nextval('hibernate_sequence'), 'MODERATOR', 100);
INSERT INTO roles (id, code, level) VALUES (nextval('hibernate_sequence'), 'REPORTER', 250);
INSERT INTO roles (id, code, level) VALUES (nextval('hibernate_sequence'), 'TRUSTED_USER', 500);
INSERT INTO roles (id, code, access_level) VALUES
(nextval('hibernate_sequence'), 'ADMIN', 1),
(nextval('hibernate_sequence'), 'HOLARSE-CORE', 10),
(nextval('hibernate_sequence'), 'MODERATOR', 100),
(nextval('hibernate_sequence'), 'REPORTER', 250),
(nextval('hibernate_sequence'), 'TRUSTED_USER', 500);

-- 2. Tag groups
INSERT INTO taggroups(id, name) VALUES (nextval('hibernate_sequence'), 'LICENSE');
INSERT INTO taggroups(id, name) VALUES (nextval('hibernate_sequence'), 'GENRE');
INSERT INTO taggroups(id, name) VALUES (nextval('hibernate_sequence'), 'MULTIPLAYER');
INSERT INTO taggroups(id, name) VALUES (nextval('hibernate_sequence'), 'STORE');
INSERT INTO taggroups(id, name) VALUES (nextval('hibernate_sequence'), 'FRANCHISE');
INSERT INTO taggroups(id, name) VALUES (nextval('hibernate_sequence'), 'COMPANY');
INSERT INTO taggroups(id, name) VALUES (nextval('hibernate_sequence'), 'DEVELOPER');
INSERT INTO taggroups(id, name) VALUES (nextval('hibernate_sequence'), 'PUBLISHER');
INSERT INTO taggroups(id, name) VALUES (nextval('hibernate_sequence'), 'PORTER');
INSERT INTO taggroups(id, name) VALUES (nextval('hibernate_sequence'), 'PLATFORM');
INSERT INTO taggroups(id, name) VALUES (nextval('hibernate_sequence'), 'TECHNICAL');
INSERT INTO taggroups(id, name) VALUES (nextval('hibernate_sequence'), 'ENGINE');
INSERT INTO taggroups(id, name) VALUES (nextval('hibernate_sequence'), 'PACKAGEMANAGER');
INSERT INTO taggroups(id, name) VALUES
(nextval('hibernate_sequence'), 'LICENSE'),
(nextval('hibernate_sequence'), 'GENRE'),
(nextval('hibernate_sequence'), 'MULTIPLAYER'),
(nextval('hibernate_sequence'), 'STORE'),
(nextval('hibernate_sequence'), 'FRANCHISE'),
(nextval('hibernate_sequence'), 'COMPANY'),
(nextval('hibernate_sequence'), 'DEVELOPER'),
(nextval('hibernate_sequence'), 'PUBLISHER'),
(nextval('hibernate_sequence'), 'PORTER'),
(nextval('hibernate_sequence'), 'PLATFORM'),
(nextval('hibernate_sequence'), 'TECHNICAL'),
(nextval('hibernate_sequence'), 'ENGINE'),
(nextval('hibernate_sequence'), 'PACKAGEMANAGER');


-- 3. Forums
Expand Down
19 changes: 19 additions & 0 deletions doc/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Use postgres/example user/password credentials
version: '3.1'

services:
db:
image: postgres:15
restart: always
environment:
POSTGRES_USER: holarse
POSTGRES_PASSWORD: geheim
POSTGRES_DB: holarse
ports:
- 5432:5432
volumes:
- my_pgdata:/var/lib/postgresql/data

volumes:
my_pgdata:

0 comments on commit 74202e8

Please sign in to comment.