Skip to content
Snippets Groups Projects
Commit c0340bd9 authored by Petr Kabourek's avatar Petr Kabourek
Browse files

somewhat fix db seeding

parent e20aac82
No related branches found
No related tags found
1 merge request!21Db
#!/bin/bash
docker exec -i hr psql -u root -p'123' airports-hr-service < ./db-management/seed/seed-hr-service.sql
docker exec -i hr psql -u root -p'123' airports-service < ./db-management/seed/seed-airports-service.sql
docker exec -i hr psql -u root -p'123' airports-flights-service < ./db-management/seed/seed-flights-service.sql
docker exec -i hr psql -u root -p'123' airports-planes-service < ./db-management/seed/seed-planes-service.sql
\ No newline at end of file
cat ./db-management/seed/seed-hr-service.sql | docker-compose exec -T hr-service-db psql -U postgres -d hr -p 5432
cat ./db-management/seed/seed-airports-service.sql | docker-compose exec -T airports-service-db psql -U postgres -d airports -p 5432
#cat ./db-management/seed/seed-flights-service.sql | docker-compose exec -T flights-service-db psql -U postgres -d flights -p 5432
cat ./db-management/seed/seed-planes-service.sql | docker-compose exec -T planes-service-db psql -U postgres -d planes -p 5432
\ No newline at end of file
INSERT INTO airport (id, name, capacity, landingPrice, longitude, latitude, city, country)
VALUES ('a88c9865-3a35-4a89-a5f0-d02b8fbef0bb', 'John F. Kennedy International Airport', 'Large', 50000.00, -73.7781, 40.6413, 'New York City', 'United States');
SET search_path TO airport;
INSERT INTO airport (id, name, capacity, landingPrice, longitude, latitude, city, country)
VALUES ('9248cf6e-fd96-4dd6-af68-4d0c6ed24d2d', 'Heathrow Airport', 'Large', 55000.00, -0.4610, 51.4700, 'London', 'United Kingdom');
INSERT INTO airport (id, name, capacity, landingPrice, longitude, latitude, city, country)
VALUES ('a1df2c89-0d4a-4e47-80e7-c7f542f0d62b', 'Los Angeles International Airport', 'Large', 48000.00, -118.4079, 33.9416, 'Los Angeles', 'United States');
INSERT INTO airport (id, name, capacity, landing_price, longitude, latitude, city, country)
VALUES ('a88c9865-3a35-4a89-a5f0-d02b8fbef0bb', 'John F. Kennedy International Airport', 'Large', 50000.00, -73.7781, 40.6413, 'New York City', 'United States') ON CONFLICT (id) DO NOTHING;
INSERT INTO airport (id, name, capacity, landingPrice, longitude, latitude, city, country)
VALUES ('35a1a2c3-68b8-4b45-a43a-54d08fa611d3', 'Beijing Capital International Airport', 'Large', 60000.00, 116.5871, 40.0799, 'Beijing', 'China');
INSERT INTO airport (id, name, capacity, landing_price, longitude, latitude, city, country)
VALUES ('9248cf6e-fd96-4dd6-af68-4d0c6ed24d2d', 'Heathrow Airport', 'Large', 55000.00, -0.4610, 51.4700, 'London', 'United Kingdom') ON CONFLICT (id) DO NOTHING;
INSERT INTO airport (id, name, capacity, landingPrice, longitude, latitude, city, country)
VALUES ('b9d3f4a5-6e5d-4e54-ae79-7dc78e2a9bfb', 'Dubai International Airport', 'Large', 70000.00, 55.3644, 25.2532, 'Dubai', 'United Arab Emirates');
INSERT INTO airport (id, name, capacity, landing_price, longitude, latitude, city, country)
VALUES ('a1df2c89-0d4a-4e47-80e7-c7f542f0d62b', 'Los Angeles International Airport', 'Large', 48000.00, -118.4079, 33.9416, 'Los Angeles', 'United States') ON CONFLICT (id) DO NOTHING;
INSERT INTO airport (id, name, capacity, landing_price, longitude, latitude, city, country)
VALUES ('35a1a2c3-68b8-4b45-a43a-54d08fa611d3', 'Beijing Capital International Airport', 'Large', 60000.00, 116.5871, 40.0799, 'Beijing', 'China') ON CONFLICT (id) DO NOTHING;
INSERT INTO airport (id, name, capacity, landing_price, longitude, latitude, city, country)
VALUES ('b9d3f4a5-6e5d-4e54-ae79-7dc78e2a9bfb', 'Dubai International Airport', 'Large', 70000.00, 55.3644, 25.2532, 'Dubai', 'United Arab Emirates') ON CONFLICT (id) DO NOTHING;
INSERT INTO language (id, language)
VALUES ('f1d6b0f0-5d1f-4a97-9db1-7c9d582dd73b', 'English');
INSERT INTO language (id, language)
VALUES ('0a8d76c1-ff1f-42a1-8058-1c78e2b7e738', 'Spanish');
INSERT INTO language (id, language)
VALUES ('fb5d7a2c-06ef-4d0e-8e18-4a90f79dfd57', 'French');
INSERT INTO language (id, language)
VALUES ('64b3e0b6-9fa7-4f2e-8d41-9931d5f094b4', 'German');
INSERT INTO language (id, language)
VALUES ('2f89df7d-f7d8-4c84-b8e4-b6b3b3ed4c4e', 'Chinese');
INSERT INTO pilot_licence (id, type)
VALUES ('2f6d9f29-4d36-411a-86ed-f53c16fc8f2c', 0); -- CESSNA
INSERT INTO pilot_licence (id, type)
VALUES ('c2b4e354-5e45-4f7f-87d2-c0a8e8b45010', 1); -- AIRBUS_A380
INSERT INTO pilot_licence (id, type)
VALUES ('fa1c35d4-00df-41b1-b45e-ecbd57b823bb', 2); -- AIRBUS_A350
INSERT INTO pilot_licence (id, type)
VALUES ('ae8d4a27-0d56-4b8f-8d1e-9461d1a6a8f0', 3); -- AIRBUS_A320
INSERT INTO pilot_licence (id, type)
VALUES ('1a4b99a2-512c-4e89-846b-91f3e5a1b6c2', 4); -- AIRBUS_A310
INSERT INTO employee (id, name, surname, gender, dateOfBirth, hired)
VALUES ('1d2a647c-8c3a-4e6f-814a-6a7f1c58c97e', 'James', 'Smith', TRUE, '1980-05-22', '2010-04-12');
INSERT INTO pilot (employee_id)
VALUES ('1d2a647c-8c3a-4e6f-814a-6a7f1c58c97e');
INSERT INTO employee (id, name, surname, gender, dateOfBirth, hired)
VALUES ('5e8b8d1a-531d-45e3-8efc-7e2f437b5f28', 'Linda', 'Taylor', FALSE, '1985-08-14', '2012-11-09');
INSERT INTO pilot (employee_id)
VALUES ('5e8b8d1a-531d-45e3-8efc-7e2f437b5f28');
INSERT INTO employee (id, name, surname, gender, dateOfBirth, hired)
VALUES ('73f9c9d5-718f-4fae-9910-49cfcd1b4503', 'Samantha', 'Brown', FALSE, '1990-02-10', '2015-06-18');
INSERT INTO steward (employee_id)
VALUES ('73f9c9d5-718f-4fae-9910-49cfcd1b4503');
INSERT INTO employee (id, name, surname, gender, dateOfBirth, hired)
VALUES ('4a7e9390-8e54-4b15-9db3-3a945b1e0216', 'Michael', 'Wilson', TRUE, '1987-11-30', '2013-09-27');
INSERT INTO steward (employee_id)
VALUES ('4a7e9390-8e54-4b15-9db3-3a945b1e0216');
INSERT INTO steward (steward_id, language_id)
VALUES ('73f9c9d5-718f-4fae-9910-49cfcd1b4503', 'f1d6b0f0-5d1f-4a97-9db1-7c9d582dd73b'); -- Samantha knows English
INSERT INTO steward (steward_id, language_id)
VALUES ('73f9c9d5-718f-4fae-9910-49cfcd1b4503', '0a8d76c1-ff1f-42a1-8058-1c78e2b7e738'); -- Samantha knows Spanish
INSERT INTO steward (steward_id, language_id)
VALUES ('4a7e9390-8e54-4b15-9db3-3a945b1e0216', 'fb5d7a2c-06ef-4d0e-8e18-4a90f79dfd57'); -- Michael knows French
INSERT INTO steward (steward_id, language_id)
VALUES ('4a7e9390-8e54-4b15-9db3-3a945b1e0216', '64b3e0b6-9fa7-4f2e-8d41-9931d5f094b4'); -- Michael knows German
INSERT INTO pilot (pilot_id, pilot_licence_id)
VALUES ('1d2a647c-8c3a-4e6f-814a-6a7f1c58c97e', '2f6d9f29-4d36-411a-86ed-f53c16fc8f2c'); -- James has CESSNA license
INSERT INTO pilot (pilot_id, pilot_licence_id)
VALUES ('1d2a647c-8c3a-4e6f-814a-6a7f1c58c97e', 'c2b4e354-5e45-4f7f-87d2-c0a8e8b45010'); -- James has AIRBUS_A380 license
INSERT INTO pilot (pilot_id, pilot_licence_id)
VALUES ('5e8b8d1a-531d-45e3-8efc-7e2f437b5f28', 'fa1c35d4-00df-41b1-b45e-ecbd57b823bb'); -- Linda has AIRBUS_A350 license
INSERT INTO pilot (pilot_id, pilot_licence_id)
VALUES ('5e8b8d1a-531d-45e3-8efc-7e2f437b5f28', 'ae8d4a27-0d56-4b8f-8d1e-9461d1a6a8f0'); -- Linda has AIRBUS_A320 license
\ No newline at end of file
SET search_path TO hr;
-- Insert into language table
INSERT INTO language (id, language) VALUES
('73f9c9d5-718f-4fae-9910-49cfcd1b4503', 'English'),
('73f9c9d5-718f-4fae-9910-49cfcd1b4503', 'Spanish'),
('4a7e9390-8e54-4b15-9db3-3a945b1e0216', 'French'),
('4a7e9390-8e54-4b15-9db3-3a945b1e0216', 'German'),
('4a7e9390-8e54-4b15-9db3-3a945b1e0216', 'Chinese')
ON CONFLICT (id) DO NOTHING;
-- Insert into pilot_licence table
INSERT INTO pilot_licence (id, type) VALUES
('1d2a647c-8c3a-4e6f-814a-6a7f1c58c97e', 0), -- CESSNA
('1d2a647c-8c3a-4e6f-814a-6a7f1c58c97e', 1), -- AIRBUS_A380
('5e8b8d1a-531d-45e3-8efc-7e2f437b5f28', 2), -- AIRBUS_A350
('5e8b8d1a-531d-45e3-8efc-7e2f437b5f28', 3), -- AIRBUS_A320
('5e8b8d1a-531d-45e3-8efc-7e2f437b5f28', 4) -- AIRBUS_A310
ON CONFLICT (id) DO NOTHING;
-- Insert into employee table
INSERT INTO employee (id, name, surname, gender, date_of_birth, hired) VALUES
('1d2a647c-8c3a-4e6f-814a-6a7f1c58c97e', 'James', 'Smith', TRUE, '1980-05-22', '2010-04-12'),
('5e8b8d1a-531d-45e3-8efc-7e2f437b5f28', 'Linda', 'Taylor', FALSE, '1985-08-14', '2012-11-09'),
('73f9c9d5-718f-4fae-9910-49cfcd1b4503', 'Samantha', 'Brown', FALSE, '1990-02-10', '2015-06-18'),
('4a7e9390-8e54-4b15-9db3-3a945b1e0216', 'Michael', 'Wilson', TRUE, '1987-11-30', '2013-09-27')
ON CONFLICT (id) DO NOTHING;
-- Insert into pilots table
INSERT INTO pilots (employee_id) VALUES
('1d2a647c-8c3a-4e6f-814a-6a7f1c58c97e'),
('5e8b8d1a-531d-45e3-8efc-7e2f437b5f28')
ON CONFLICT (employee_id) DO NOTHING;
-- Insert into stewards table
INSERT INTO stewards (employee_id) VALUES
('73f9c9d5-718f-4fae-9910-49cfcd1b4503'),
('4a7e9390-8e54-4b15-9db3-3a945b1e0216')
ON CONFLICT (employee_id) DO NOTHING;
\ No newline at end of file
INSERT INTO plane (id, name, planeType, maxCapacity, pilotsRequired)
VALUES ('1b0d6f25-1a5e-4b98-ae1b-0249f4b4d1d2', 0, 0, 4, 1);
SET search_path TO planes;
INSERT INTO plane (id, name, planeType, maxCapacity, pilotsRequired)
VALUES ('5c2aaf75-17d4-4e90-a9e4-62027f48f4b3', 1, 1, 853, 4);
INSERT INTO plane (id, name, plane_type, max_capacity, pilots_required)
VALUES ('1b0d6f25-1a5e-4b98-ae1b-0249f4b4d1d2', 0, 0, 4, 1) ON CONFLICT (id) DO NOTHING;
INSERT INTO plane (id, name, planeType, maxCapacity, pilotsRequired)
VALUES ('7e7bde34-2f7e-4d2d-9178-07d1d42e1f85', 2, 2, 440, 2);
INSERT INTO plane (id, name, plane_type, max_capacity, pilots_required)
VALUES ('5c2aaf75-17d4-4e90-a9e4-62027f48f4b3', 1, 1, 853, 4) ON CONFLICT (id) DO NOTHING;
INSERT INTO plane (id, name, planeType, maxCapacity, pilotsRequired)
VALUES ('9d5f4a2b-4f6d-4c78-8b92-8315a6c2e8d2', 3, 3, 240, 2);
INSERT INTO plane (id, name, plane_type, max_capacity, pilots_required)
VALUES ('7e7bde34-2f7e-4d2d-9178-07d1d42e1f85', 2, 2, 440, 2) ON CONFLICT (id) DO NOTHING;
INSERT INTO plane (id, name, planeType, maxCapacity, pilotsRequired)
VALUES ('e2a3d1e4-60a5-456c-8b8f-5295f6d4d8e9', 4, 4, 280, 2);
\ No newline at end of file
INSERT INTO plane (id, name, plane_type, max_capacity, pilots_required)
VALUES ('9d5f4a2b-4f6d-4c78-8b92-8315a6c2e8d2', 3, 3, 240, 2) ON CONFLICT (id) DO NOTHING;
INSERT INTO plane (id, name, plane_type, max_capacity, pilots_required)
VALUES ('e2a3d1e4-60a5-456c-8b8f-5295f6d4d8e9', 4, 4, 280, 2) ON CONFLICT (id) DO NOTHING;
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment