-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
db: added new file with func, more data and not nulls in columns
- Loading branch information
Showing
5 changed files
with
174 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,138 @@ | ||
INSERT INTO users_schema.address ("id", "city", "country", "street", "state", "zip_code") VALUES | ||
(1, 'Kalisz', 'Polska', 'Stawiszyńska', 'Wielkopolskie', '62-800'), | ||
(2, 'Wrocław', 'Polska', 'Legnicka', 'Dolnośląskie', '51-702'); | ||
(1, 'Stawiszyn', 'Polska', 'Pleszewska 2', 'Wielkopolskie', '62-820'), | ||
(2, 'Kalisz', 'Polska', 'Stawiszyńska 4', 'Wielkopolskie', '62-800'), | ||
(3, 'Bydgoszcz', 'Polska', 'Jagielońska 12', 'Kujawsko-Pomorskie', '85-097'), | ||
(4, 'Poznań', 'Polska', 'Bułgarska 17', 'Wielkopolskie', '60-320'), | ||
(5, 'Koźminek', 'Polska', 'Mikołaja Kopernika', 'Wielkopolskie', '62-840'), | ||
(6, 'Kalisz', 'Polska', 'Górnośląska 2', 'Wielkopolskie', '62-800'), | ||
(7, 'Warszawa', 'Polska', 'Aleje Jerozolimskie', 'Mazowieckie', '00-001'), | ||
(8, 'Kraków', 'Polska', 'ul. Floriańska 7', 'Małopolskie', '30-001'), | ||
(9, 'Gdańsk', 'Polska', 'ul. Długa 69', 'Pomorskie', '80-001'), | ||
(10, 'Wrocław', 'Polska', 'Legnicka 420', 'Dolnośląskie', '51-702'); | ||
|
||
INSERT INTO users_schema.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]', B'1', 1, '123456789'), | ||
(2, 'Kamil', 'Owczarzyński', 'bilililimigosu', '12345', '2023-03-21 09:00:00', '2023-03-21 09:00:00', 2, '[email protected]', B'1', 2, '696969691'); | ||
(2, 'Kamil', 'Owczarzyński', 'bilililimigosu', '12345', '2023-03-21 09:00:00', '2023-03-21 09:00:00', 2, '[email protected]', B'1', 2, '696969691'), | ||
(3, 'Jan', 'Kowalski', 'jkowalski', 'hasło123', '2022-03-21 16:00:00', '2023-1-21 09:21:14', 1, '[email protected]', B'0', 1, '123456789'), | ||
(4, 'Adam', 'Nowak', 'anowak', 'haslo123', '2022-01-05 10:30:00', '2022-02-15 14:20:45', 2, '[email protected]', B'0', 2, '987654321'), | ||
(5, 'Ewa', 'Kowalska', 'ekowalska', 'tajnehaslo', '2022-02-10 08:15:00', '2022-03-25 12:45:30', 1, '[email protected]', B'0', 3, '654321987'), | ||
(6, 'Piotr', 'Wiśniewski', 'pwiśniewski', 'password123', '2022-03-15 11:45:00', '2022-04-30 16:10:20', 3, '[email protected]', B'0', 4, '321654987'), | ||
(7, 'Anna', 'Lis', 'alis', '123456', '2022-04-20 13:20:00', '2022-05-10 09:55:15', 2, '[email protected]', B'1', 5, '789456123'), | ||
(8, 'Tomasz', 'Zieliński', 'tzielinski', 'qwerty', '2022-05-25 15:00:00', '2022-06-20 11:30:10', 1, '[email protected]', B'1', 6, '456123789'), | ||
(9, 'Magdalena', 'Kowalczyk', 'mkowalczyk', 'mojehaslo', '2022-06-30 17:10:00', '2022-07-15 13:15:25', 3, '[email protected]', B'1', 7, '987654123'), | ||
(10, 'Marcin', 'Szymański', 'mszymanski', 'password', '2022-07-05 09:00:00', '2022-08-05 08:20:35', 2, '[email protected]', B'1', 8, '321789654'); | ||
|
||
|
||
INSERT INTO events_schema.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); | ||
(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); | ||
|
||
|
||
INSERT INTO events_schema.event_tag ("event_id", "tag_id") VALUES | ||
(1, 1), | ||
(2, 2); | ||
(2, 10), | ||
(3, 5), | ||
(3, 4), | ||
(4, 1), | ||
(5, 2), | ||
(5, 3), | ||
(6, 4), | ||
(7, 7), | ||
(8, 4), | ||
(9, 4), | ||
(10, 8), | ||
(10, 9); | ||
|
||
|
||
INSERT INTO events_schema.participant ("id", "event_id", "user_id", "status_id") VALUES | ||
(1, 1, 1, 1), | ||
(2, 2, 2, 2); | ||
(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); | ||
|
||
INSERT INTO events_schema.parameter ("id", "key", "value") VALUES | ||
(1, 'Location', 'Virtual'), | ||
(2, 'SpeakerCount', '5'); | ||
(1, 'Liczba Uczestników', '1000'), | ||
(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'); | ||
|
||
INSERT INTO events_schema.event_parameter ("parameter_id", "event_id") VALUES | ||
(1, 1), | ||
(2, 2); | ||
(2, 2), | ||
(3, 3), | ||
(4, 4), | ||
(5, 5), | ||
(6, 6), | ||
(7, 7), | ||
(8, 8), | ||
(9, 9), | ||
(10, 10); | ||
|
||
INSERT INTO users_schema.comment ("id", "event_id", "content", "created_at", "user_id") VALUES | ||
(1, 1, 'Looking forward to this!', '2023-09-10', 1), | ||
(2, 2, 'Boring...', '2023-10-15', 2); | ||
(1, 1, 'Nie mogę się doczekać!', '2023-09-10', 1), | ||
(2, 2, 'Trochę nudne...', '2023-10-15', 2), | ||
(3, 3, 'Super wydarzenie!', '2023-11-20', 3), | ||
(4, 4, 'Fantastyczne doświadczenie!', '2023-12-05', 4), | ||
(5, 5, 'Zapowiada się świetnie!', '2024-01-02', 5), | ||
(6, 6, 'Jestem podekscytowany!', '2024-02-14', 6), | ||
(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); | ||
|
||
INSERT INTO users_schema.interest ("id", "name", "level") VALUES | ||
(1, 'Programming', 5), | ||
(2, 'Reading', 4); | ||
(1, 'Programowanie', 5), | ||
(2, 'Sport', 4), | ||
(3, 'Muzyka', 3), | ||
(4, 'Film', 3), | ||
(5, 'Taniec', 4), | ||
(6, 'Fitness', 3), | ||
(7, 'Sztuka', 4), | ||
(8, 'Kulinaria', 3), | ||
(9, 'Podróże', 4), | ||
(10, 'Gry komputerowe', 5); | ||
|
||
INSERT INTO users_schema.user_interest ("user_id", "interest_id") VALUES | ||
(1, 1), | ||
(2, 2); | ||
(2, 2), | ||
(3, 3), | ||
(4, 4), | ||
(5, 5), | ||
(6, 6), | ||
(7, 7), | ||
(8, 8), | ||
(9, 9), | ||
(10, 10); | ||
|
||
INSERT INTO general_schema.image (image_data, object_type_id, object_id) | ||
VALUES | ||
(('path to image'), 1, 1), | ||
(('path to image2'), 2, 2); | ||
(('path to image2'), 2, 2), | ||
(('path to image3'), 1, 3), | ||
(('path to image4'), 2, 4), | ||
(('path to image5'), 1, 5), | ||
(('path to image6'), 2, 6), | ||
(('path to image7'), 1, 7), | ||
(('path to image8'), 2, 8), | ||
(('path to image9'), 1, 9), | ||
(('path to image10'), 2, 10); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
CREATE OR REPLACE FUNCTION | ||
general_schema.check_fk_exists(object_id INT, object_type_id INT) | ||
RETURNS BOOLEAN AS $$ | ||
BEGIN | ||
IF object_type_id = 1 THEN | ||
RETURN EXISTS (SELECT 1 FROM users_schema.user WHERE "id" = object_id); | ||
ELSIF object_type_id = 2 THEN RETURN EXISTS (SELECT 1 FROM events_schema.event WHERE "id" = object_id); | ||
ELSE RETURN FALSE; | ||
END IF; | ||
END; | ||
$$ LANGUAGE plpgsql STABLE; | ||
|
||
ALTER TABLE general_schema.image ADD CONSTRAINT chech_object_fk | ||
CHECK (general_schema.check_fk_exists(object_id, object_type_id)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters