Skip to content

Commit

Permalink
[RSN-45] - Change parameters architecture, replaced role, status, obj…
Browse files Browse the repository at this point in the history
…ect type with enum (#31)

* Changed role, status and object_type tables into enum

* Update init-dev-data.sql

* Added status constraints for event and participant tables.
  • Loading branch information
mkoper02 authored May 11, 2024
1 parent 82b1862 commit 29e69e0
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 129 deletions.
Empty file removed Database/.gitkeep
Empty file.
31 changes: 8 additions & 23 deletions Database/init-constraints.sql
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
CREATE OR REPLACE FUNCTION
common.check_fk_exists(object_id INT, object_type_id INT)
common.check_fk_exists(object_id INT, object_type common.object_type)
RETURNS BOOLEAN AS $$
BEGIN
IF object_type_id = 1 THEN
IF object_type = 'User' THEN
RETURN EXISTS (SELECT 1 FROM users.user WHERE "id" = object_id);
ELSIF object_type_id = 2 THEN RETURN EXISTS (SELECT 1 FROM events.event WHERE "id" = object_id);
ELSIF object_type = 'Event' THEN RETURN EXISTS (SELECT 1 FROM events.event WHERE "id" = object_id);
ELSE RETURN FALSE;
END IF;
END;
$$ LANGUAGE plpgsql STABLE;

ALTER TABLE common.image ADD CONSTRAINT chk_object_fk
CHECK (common.check_fk_exists(object_id, object_type_id));
CHECK (common.check_fk_exists(object_id, object_type));

ALTER TABLE common.address ADD CONSTRAINT chk_address_street CHECK (street ~ '^[[:alnum:]]+(?:(\s)[[:alpha:]]+)*(\s(?:(\d+|\d+/\d+)))?$');

Expand Down Expand Up @@ -45,25 +45,10 @@ ALTER TABLE events.parameter ADD CONSTRAINT chk_parameter_value CHECK (value ~ '

ALTER TABLE events.parameter ADD CONSTRAINT chk_parameter_key CHECK (key ~ '^[[:alpha:]]+(?:\s[[:alpha:]]+)*$');

ALTER TABLE users.role ADD CONSTRAINT chk_three_roles CHECK (id <= 3);
ALter TABLE events.event ADD CONSTRAINT chk_event_status CHECK (status in ('Completed', 'In progress', 'Waiting for approval'));

ALTER TABLE users.role ADD CONSTRAINT chk_role_name CHECK (name ~ '^(Organizer|Admin|User)$');

ALTER TABLE common.status ADD CONSTRAINT chk_five_statuses CHECK (id <= 5);

ALTER TABLE common.status ADD CONSTRAINT chk_status_name CHECK (name ~ '^(Interested|Participating|Completed|In progress|Waiting for approval)$');

ALTER TABLE common.object_type ADD CONSTRAINT chk_two_object_types CHECK (id <= 2);

ALTER TABLE common.object_type ADD CONSTRAINT chk_object_type_name CHECK (name ~ '^(Event|User)$');

ALTER TABLE common.status
ADD CONSTRAINT chk_object_type_for_status
CHECK (
(name IN ('Interested', 'Participating') AND object_type_id = 2) OR
(name IN ('Completed', 'In progress', 'Waiting for approval') AND object_type_id = 1)
);
ALTER TABLE events.participant ADD CONSTRAINT chk_participant_status CHECK (status in ('Interested', 'Participating'));

CREATE UNIQUE INDEX unique_image_for_user
ON common.image ("object_type_id", "object_id")
WHERE ("object_type_id" = 2);
ON common.image ("object_type", "object_id")
WHERE ("object_type" = 'User');
59 changes: 9 additions & 50 deletions Database/init-db.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ CREATE SCHEMA events;
CREATE SCHEMA users;
CREATE SCHEMA common;

CREATE TYPE common.status AS ENUM ('Interested', 'Participating', 'Completed', 'In progress', 'Waiting for approval');
CREATE TYPE users.role AS ENUM ('User', 'Organizer', 'Admin');
CREATE TYPE common.object_type AS ENUM ('Event', 'User');

CREATE TABLE IF NOT EXISTS events.event (
"id" SERIAL PRIMARY KEY,
"name" text NOT NULL CONSTRAINT events_event_name_maxlength CHECK (LENGTH("name") <= 64),
Expand All @@ -13,23 +17,17 @@ CREATE TABLE IF NOT EXISTS events.event (
"created_at" timestamptz NOT NULL,
"updated_at" timestamptz NOT NULL,
"slug" text NOT NULL CONSTRAINT events_event_slug_maxlength CHECK (LENGTH("slug") <= 128),
"status_id" integer NOT NULL
"status" common.status NOT NULL
);

CREATE TABLE IF NOT EXISTS events.participant (
"id" SERIAL PRIMARY KEY,
"event_id" integer NOT NULL,
"user_id" integer NOT NULL,
"status_id" integer NOT NULL,
"status" common.status NOT NULL,
UNIQUE ("event_id", "user_id")
);

CREATE TABLE IF NOT EXISTS common.status (
"id" SERIAL PRIMARY KEY,
"name" text NOT NULL CONSTRAINT common_status_name_maxlength CHECK (LENGTH("name") <= 32) UNIQUE,
"object_type_id" integer NOT NULL
);

CREATE TABLE IF NOT EXISTS events.tag (
"id" SERIAL PRIMARY KEY,
"name" text NOT NULL CONSTRAINT events_tag_name_maxlength CHECK (LENGTH("name") <= 64) UNIQUE
Expand All @@ -49,7 +47,7 @@ CREATE TABLE IF NOT EXISTS users.user (
"password" text NOT NULL,
"created_at" timestamptz NOT NULL,
"updated_at" timestamptz NOT NULL,
"role_id" integer NOT NULL,
"role" users.role NOT NULL,
"email" text NOT NULL CONSTRAINT users_user_email_maxlength CHECK (LENGTH("email") <= 255) UNIQUE,
"is_active" boolean NOT NULL,
"address_id" integer NOT NULL,
Expand All @@ -69,11 +67,6 @@ CREATE TABLE IF NOT EXISTS events.event_parameter (
PRIMARY KEY (parameter_id, event_id)
);

CREATE TABLE IF NOT EXISTS users.role (
"id" SERIAL PRIMARY KEY,
"name" text NOT NULL CHECK (LENGTH("name") <= 32) UNIQUE
);

CREATE TABLE IF NOT EXISTS events.comment (
"id" SERIAL PRIMARY KEY,
"event_id" integer NOT NULL,
Expand All @@ -94,15 +87,10 @@ CREATE TABLE IF NOT EXISTS common.address (
CREATE TABLE IF NOT EXISTS common.image (
"id" SERIAL PRIMARY KEY,
"image_data" bytea NOT NULL,
"object_type_id" integer NOT NULL,
"object_type" common.object_type NOT NULL,
"object_id" integer NOT NULL
);

CREATE TABLE IF NOT EXISTS common.object_type (
"id" SERIAL PRIMARY KEY,
"name" text NOT NULL CONSTRAINT common_object_type_name_maxlength CHECK (LENGTH("name") <= 32) UNIQUE
);

CREATE TABLE IF NOT EXISTS users.user_interest (
"user_id" integer NOT NULL,
"interest_id" integer NOT NULL,
Expand All @@ -115,8 +103,6 @@ CREATE TABLE IF NOT EXISTS users.interest (
"name" text NOT NULL CONSTRAINT users_interest_name_maxlength CHECK (LENGTH("name") <= 32) UNIQUE
);

ALTER TABLE users.user ADD FOREIGN KEY ("role_id") REFERENCES users.role ("id");

ALTER TABLE events.event ADD FOREIGN KEY ("address_id") REFERENCES common.address ("id");

ALTER TABLE events.comment ADD FOREIGN KEY ("event_id") REFERENCES events.event ("id");
Expand All @@ -129,14 +115,10 @@ ALTER TABLE events.participant ADD FOREIGN KEY ("user_id") REFERENCES users.user

ALTER TABLE events.comment ADD FOREIGN KEY ("user_id") REFERENCES users.user ("id");

ALTER TABLE common.image ADD FOREIGN KEY ("object_type_id") REFERENCES common.object_type ("id");

ALTER TABLE users.user_interest ADD FOREIGN KEY ("user_id") REFERENCES users.user ("id");

ALTER TABLE users.user ADD FOREIGN KEY ("address_id") REFERENCES common.address ("id");

ALTER TABLE events.participant ADD FOREIGN KEY ("status_id") REFERENCES common.status ("id");

ALTER TABLE events.event_parameter ADD FOREIGN KEY ("parameter_id") REFERENCES events.parameter ("id");

ALTER TABLE events.event_parameter ADD FOREIGN KEY ("event_id") REFERENCES events.event ("id");
Expand All @@ -145,31 +127,8 @@ ALTER TABLE events.event_tag ADD FOREIGN KEY ("tag_id") REFERENCES events.tag ("

ALTER TABLE events.event_tag ADD FOREIGN KEY ("event_id") REFERENCES events.event ("id");

ALTER TABLE common.status ADD FOREIGN KEY ("object_type_id") REFERENCES common.object_type ("id");

ALTER TABLE events.event ADD FOREIGN KEY ("status_id") REFERENCES common.status ("id");

ALTER TABLE users.user_interest ADD FOREIGN KEY ("interest_id") REFERENCES users.interest ("id");

INSERT INTO users.role ("id", "name") VALUES
(1, 'User'),
(2, 'Organizer'),
(3, 'Admin');
SELECT setval('common.address_id_seq', (SELECT MAX(id) FROM users.role));

INSERT INTO common.object_type ("id", "name") VALUES
(1, 'Event'),
(2, 'User');
SELECT setval('common.address_id_seq', (SELECT MAX(id) FROM common.object_type));

INSERT INTO common.status ("id", "name", "object_type_id") VALUES
(1, 'Interested', 2),
(2, 'Participating', 2),
(3, 'Completed', 1),
(4, 'In progress', 1),
(5, 'Waiting for approval', 1);
SELECT setval('common.address_id_seq', (SELECT MAX(id) FROM common.status));


INSERT INTO events.tag ("id", "name") VALUES
(1, 'Technologia'),
(2, 'Sport'),
Expand Down
96 changes: 41 additions & 55 deletions Database/init-dev-data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,30 @@ INSERT INTO common.address ("id", "city", "country", "street", "state", "zip_cod
(10, 'Wrocław', 'Polska', 'Legnicka 420', 'Dolnośląskie', '51-702');
SELECT setval('common.address_id_seq', (SELECT MAX(id) FROM common.address));

INSERT INTO users.user ("id", "name", "surname", "username", "password", "created_at", "updated_at", "role_id", "email", "is_active", "address_id", "phone") VALUES
(1, 'Kamil', 'Owczarski', 'bilimigus', 'password', '2023-03-20 08:00:00', '2023-03-20 08:00:00', 1, '[email protected]', true, 1, '+48 123456789'),
(2, 'Kamil', 'Owczarzyński', 'bilililimigosu', '12345', '2023-03-21 09:00:00', '2023-03-21 09:00:00', 2, '[email protected]', true, 2, '+48 696969691'),
(3, 'Jan', 'Kowalski', 'jkowalski', 'hasło123', '2022-03-21 16:00:00', '2023-1-21 09:21:14', 1, '[email protected]', false, 1, '+48 123456119'),
(4, 'Adam', 'Nowak', 'anowak', 'haslo123', '2022-01-05 10:30:00', '2022-02-15 14:20:45', 2, '[email protected]', false, 2, '+48 987654321'),
(5, 'Ewa', 'Kowalska', 'ekowalska', 'tajnehaslo', '2022-02-10 08:15:00', '2022-03-25 12:45:30', 1, '[email protected]', false, 3, '+48 654321987'),
(6, 'Piotr', 'Wiśniewski', 'pwiśniewski', 'password123', '2022-03-15 11:45:00', '2022-04-30 16:10:20', 3, '[email protected]', false, 4, '+48 321654987'),
(7, 'Anna', 'Lis', 'alis', '123456', '2022-04-20 13:20:00', '2022-05-10 09:55:15', 2, '[email protected]', true, 5, '+48 789456123'),
(8, 'Tomasz', 'Zieliński', 'tzielinski', 'qwerty', '2022-05-25 15:00:00', '2022-06-20 11:30:10', 1, '[email protected]', true, 6, '+48 456123789'),
(9, 'Magdalena', 'Kowalczyk', 'mkowalczyk', 'mojehaslo', '2022-06-30 17:10:00', '2022-07-15 13:15:25', 3, '[email protected]', true, 7, '+48 987654123'),
(10, 'Marcin', 'Szymański', 'mszymanski', 'password', '2022-07-05 09:00:00', '2022-08-05 08:20:35', 2, '[email protected]', true, 8, '+48 321789654');
SELECT setval('users.user_id_seq', (SELECT MAX(id) FROM users.user));
INSERT INTO users.user ("id", "name", "surname", "username", "password", "created_at", "updated_at", "role", "email", "is_active", "address_id", "phone") VALUES
(1, 'Kamil', 'Owczarski', 'bilimigus', 'password', '2023-03-20 08:00:00', '2023-03-20 08:00:00', 'User', '[email protected]', true, 1, '+48 123456789'),
(2, 'Kamil', 'Owczarzyński', 'bilililimigosu', '12345', '2023-03-21 09:00:00', '2023-03-21 09:00:00', 'Organizer', '[email protected]', true, 2, '+48 696969691'),
(3, 'Jan', 'Kowalski', 'jkowalski', 'hasło123', '2022-03-21 16:00:00', '2023-1-21 09:21:14', 'User', '[email protected]', false, 1, '+48 123456119'),
(4, 'Adam', 'Nowak', 'anowak', 'haslo123', '2022-01-05 10:30:00', '2022-02-15 14:20:45', 'Organizer', '[email protected]', false, 2, '+48 987654321'),
(5, 'Ewa', 'Kowalska', 'ekowalska', 'tajnehaslo', '2022-02-10 08:15:00', '2022-03-25 12:45:30', 'User', '[email protected]', false, 3, '+48 654321987'),
(6, 'Piotr', 'Wiśniewski', 'pwiśniewski', 'password123', '2022-03-15 11:45:00', '2022-04-30 16:10:20', 'Admin', '[email protected]', false, 4, '+48 321654987'),
(7, 'Anna', 'Lis', 'alis', '123456', '2022-04-20 13:20:00', '2022-05-10 09:55:15', 'Organizer', '[email protected]', true, 5, '+48 789456123'),
(8, 'Tomasz', 'Zieliński', 'tzielinski', 'qwerty', '2022-05-25 15:00:00', '2022-06-20 11:30:10', 'User', '[email protected]', true, 6, '+48 456123789'),
(9, 'Magdalena', 'Kowalczyk', 'mkowalczyk', 'mojehaslo', '2022-06-30 17:10:00', '2022-07-15 13:15:25', 'Admin', '[email protected]', true, 7, '+48 987654123'),
(10, 'Marcin', 'Szymański', 'mszymanski', 'password', '2022-07-05 09:00:00', '2022-08-05 08:20:35', 'Organizer', '[email protected]', true, 8, '+48 321789654');

INSERT INTO events.event ("id", "name", "address_id", "description", "organizer_id", "start_at", "end_at", "created_at", "updated_at", "slug", "status_id") VALUES
(1, 'Tech Conference', 1, 'Annual tech conference', 1, '2023-10-01 09:00:00', '2023-10-02 17:00:00', '2023-09-01 08:00:00', '2023-09-01 08:00:00', 'tech-conference', 1),
(2, 'Health Symposium', 2, 'Health and wellness symposium', 2, '2023-11-05 09:00:00', '2023-11-06 17:00:00', '2023-10-05 08:00:00', '2023-10-05 08:00:00', 'health-symposium', 2),
(3, 'Koncert Rockowy', 3, 'Występ ulubionych zespołów rockowych', 2, CURRENT_TIMESTAMP - '1 day'::INTERVAL, CURRENT_TIMESTAMP + '4 hours'::INTERVAL, '2023-09-01 08:00:00', '2023-09-01 08:00:00', 'koncert-rockowy', 1),
(4, 'Konferencja IT', 4, 'Coroczna konferencja technologiczna', 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP + '3 hours'::INTERVAL, '2023-10-02 17:00:00', '2023-10-02 18:00:00', 'konferencja-it', 1),
(5, 'Mecz Piłki Nożnej', 5, 'Mecz drużynowej rywalizacji w piłce nożnej', 3, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP + '3 hours'::INTERVAL, '2022-12-01 08:00:00', '2023-09-01 08:30:00', 'mecz-pilki-noznej', 1),
(6, 'Festiwal Elektroniczny', 6, 'Największe hity muzyki elektronicznej', 4, CURRENT_TIMESTAMP - '4 day'::INTERVAL, CURRENT_TIMESTAMP - '2 days'::INTERVAL, '2023-09-01 08:00:00', '2023-09-02 08:00:00', 'festiwal-elektroniczny', 1),
(7, 'Koncert Hip-Hopowy', 7, 'Najnowsze hity hip-hopu w wykonaniu gwiazd', 6, CURRENT_TIMESTAMP + '2 days'::INTERVAL, CURRENT_TIMESTAMP + '2 days'::INTERVAL + '4 hours'::INTERVAL, '2023-10-08 17:00:00', '2023-11-01 09:19:22', 'koncert-hip-hopowy', 1),
(8, 'Wieczór Jazzowy', 8, 'Relaksujące dźwięki jazzu w kameralnej atmosferze', 8, CURRENT_TIMESTAMP + '1 day'::INTERVAL, CURRENT_TIMESTAMP + '1 day'::INTERVAL + '5 hours'::INTERVAL, '2023-09-01 08:00:00', '2023-09-01 08:00:00', 'wieczor-jazzowy', 1),
(9, 'Koncert Klasyczny', 9, 'Muzyka klasyczna w wykonaniu renomowanych artystów', 10, CURRENT_TIMESTAMP + '1 day'::INTERVAL, CURRENT_TIMESTAMP + '1 day'::INTERVAL + '3 hours'::INTERVAL, '2023-01-01 15:00:00', '2023-02-01 08:00:00', 'koncert-klasyczny', 1),
(10, 'Turniej w League of Legends', 10, 'Turniej LAN dla miłośnikow esportu i gry League of Legends', 10, CURRENT_TIMESTAMP - '1 day'::INTERVAL, CURRENT_TIMESTAMP - '3 hours'::INTERVAL, '2023-01-01 15:00:00', '2023-02-01 08:00:00', 'turniej-lol', 1);
SELECT setval('events.event_id_seq', (SELECT MAX(id) FROM events.event));
INSERT INTO events.event ("id", "name", "address_id", "description", "organizer_id", "start_at", "end_at", "created_at", "updated_at", "slug", "status") VALUES
(1, 'Tech Conference', 1, 'Annual tech conference', 1, '2023-10-01 09:00:00', '2023-10-02 17:00:00', '2023-09-01 08:00:00', '2023-09-01 08:00:00', 'tech-conference', 'Completed'),
(2, 'Health Symposium', 2, 'Health and wellness symposium', 2, '2023-11-05 09:00:00', '2023-11-06 17:00:00', '2023-10-05 08:00:00', '2023-10-05 08:00:00', 'health-symposium', 'In progress'),
(3, 'Koncert Rockowy', 3, 'Występ ulubionych zespołów rockowych', 2, CURRENT_TIMESTAMP - '1 day'::INTERVAL, CURRENT_TIMESTAMP + '4 hours'::INTERVAL, '2023-09-01 08:00:00', '2023-09-01 08:00:00', 'koncert-rockowy', 'Waiting for approval'),
(4, 'Konferencja IT', 4, 'Coroczna konferencja technologiczna', 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP + '3 hours'::INTERVAL, '2023-10-02 17:00:00', '2023-10-02 18:00:00', 'konferencja-it', 'Completed'),
(5, 'Mecz Piłki Nożnej', 5, 'Mecz drużynowej rywalizacji w piłce nożnej', 3, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP + '3 hours'::INTERVAL, '2022-12-01 08:00:00', '2023-09-01 08:30:00', 'mecz-pilki-noznej', 'In progress'),
(6, 'Festiwal Elektroniczny', 6, 'Największe hity muzyki elektronicznej', 4, CURRENT_TIMESTAMP - '4 day'::INTERVAL, CURRENT_TIMESTAMP - '2 days'::INTERVAL, '2023-09-01 08:00:00', '2023-09-02 08:00:00', 'festiwal-elektroniczny', 'Waiting for approval'),
(7, 'Koncert Hip-Hopowy', 7, 'Najnowsze hity hip-hopu w wykonaniu gwiazd', 6, CURRENT_TIMESTAMP + '2 days'::INTERVAL, CURRENT_TIMESTAMP + '2 days'::INTERVAL + '4 hours'::INTERVAL, '2023-10-08 17:00:00', '2023-11-01 09:19:22', 'koncert-hip-hopowy', 'Completed'),
(8, 'Wieczór Jazzowy', 8, 'Relaksujące dźwięki jazzu w kameralnej atmosferze', 8, CURRENT_TIMESTAMP + '1 day'::INTERVAL, CURRENT_TIMESTAMP + '1 day'::INTERVAL + '5 hours'::INTERVAL, '2023-09-01 08:00:00', '2023-09-01 08:00:00', 'wieczor-jazzowy', 'In progress'),
(9, 'Koncert Klasyczny', 9, 'Muzyka klasyczna w wykonaniu renomowanych artystów', 10, CURRENT_TIMESTAMP + '1 day'::INTERVAL, CURRENT_TIMESTAMP + '1 day'::INTERVAL + '3 hours'::INTERVAL, '2023-01-01 15:00:00', '2023-02-01 08:00:00', 'koncert-klasyczny', 'Waiting for approval'),
(10, 'Turniej w League of Legends', 10, 'Turniej LAN dla miłośnikow esportu i gry League of Legends', 10, CURRENT_TIMESTAMP - '1 day'::INTERVAL, CURRENT_TIMESTAMP - '3 hours'::INTERVAL, '2023-01-01 15:00:00', '2023-02-01 08:00:00', 'turniej-lol', 'Completed');

INSERT INTO events.event_tag ("event_id", "tag_id") VALUES
(1, 1),
Expand All @@ -52,44 +51,32 @@ INSERT INTO events.event_tag ("event_id", "tag_id") VALUES
(10, 8),
(10, 9);

INSERT INTO events.participant ("id", "event_id", "user_id", "status_id") VALUES
(1, 1, 1, 2),
(2, 2, 2, 2),
(3, 3, 3, 2),
(4, 4, 4, 2),
(5, 5, 5, 2),
(6, 6, 6, 2),
(7, 7, 7, 2),
(8, 7, 8, 2),
(9, 9, 9, 2),
(10, 10, 10, 2);
SELECT setval('events.participant_id_seq', (SELECT MAX(id) FROM events.participant));
INSERT INTO events.participant ("id", "event_id", "user_id", "status") VALUES
(1, 1, 1, 'Interested'),
(2, 2, 2, 'Participating'),
(3, 3, 3, 'Interested'),
(4, 4, 4, 'Participating'),
(5, 5, 5, 'Interested'),
(6, 6, 6, 'Participating'),
(7, 7, 7, 'Interested'),
(8, 7, 8, 'Participating'),
(9, 9, 9, 'Interested'),
(10, 10, 10, 'Participating');

INSERT INTO events.parameter ("id", "key", "value") VALUES
(1, 'Liczba Uczestników', '1000'),
(1, 'Płatne', '500zl'),
(2, 'Długość Trasy', '10 km'),
(3, 'Temperatura', '25 C'),
(4, 'Czas Trwania', '2 godziny'),
(5, 'Poziom Trudności', 'Średni'),
(6, 'Rozdawane Nagrody', '500 USD'),
(7, 'Typ Wydarzenia', 'Bezpośrednie'),
(8, 'Czas Trwania', '3 dni'),
(9, 'Czas Trwania', '10 dni'),
(10, 'Miejsce Wydarzenia', 'Plenerowe');
SELECT setval('events.parameter_id_seq', (SELECT MAX(id) FROM events.parameter));
(3, 'Stream link', 'url com'),
(4, 'Rejestracja', 'Tak'),
(5, 'Poziom Trudności', 'Średni');

INSERT INTO events.event_parameter ("parameter_id", "event_id") VALUES
(1, 1),
(2, 2),
(3, 3),
(4, 4),
(5, 5),
(6, 6),
(7, 7),
(8, 8),
(9, 9),
(10, 10);

(5, 5);

INSERT INTO events.comment ("id", "event_id", "content", "created_at", "user_id") VALUES
(1, 1, 'Nie mogę się doczekać!', '2023-09-10', 1),
(2, 2, 'Trochę nudne...', '2023-10-15', 2),
Expand All @@ -100,8 +87,7 @@ INSERT INTO events.comment ("id", "event_id", "content", "created_at", "user_id"
(7, 7, 'Bardzo ciekawe!', '2024-03-21', 7),
(8, 8, 'Jestem zachwycony!', '2024-04-30', 8),
(9, 9, 'To będzie świetna zabawa!', '2024-05-18', 9),
(10, 10, 'jd orka', '2024-06-25', 10);
SELECT setval('events.comment_id_seq', (SELECT MAX(id) FROM events.comment));
(10, 10, 'Oki', '2024-06-25', 10);

INSERT INTO users.interest ("id", "name") VALUES
(1, 'Programowanie'),
Expand Down
2 changes: 1 addition & 1 deletion Database/init-users.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-E
GRANT SELECT ON ALL TABLES IN SCHEMA events TO $POSTGRES_CLIENT_USER;
GRANT SELECT ON ALL TABLES IN SCHEMA common TO $POSTGRES_CLIENT_USER;
GRANT SELECT, UPDATE, INSERT, DELETE ON ALL TABLES IN SCHEMA users TO $POSTGRES_CLIENT_USER;
GRANT UPDATE, INSERT ON events.event, events.tag, events.parameter, common.status, common.image TO $POSTGRES_CLIENT_USER;
GRANT UPDATE, INSERT ON events.event, events.tag, events.parameter, common.image TO $POSTGRES_CLIENT_USER;
EOSQL

0 comments on commit 29e69e0

Please sign in to comment.