diff --git a/src/main/resources/application-prod.properties b/src/main/resources/application-prod.properties index 292a868..bf204a5 100644 --- a/src/main/resources/application-prod.properties +++ b/src/main/resources/application-prod.properties @@ -8,4 +8,7 @@ spring.datasource.password=${DATABASE_PASSWORD} spring.datasource.driver-class-name=org.mariadb.jdbc.Driver spring.jpa.hibernate.ddl-auto=validate spring.jpa.show-sql=false -spring.jpa.open-in-view=false \ No newline at end of file +spring.jpa.open-in-view=false + +# In prod mode, never add the test data to the database +spring.sql.init.mode=never \ No newline at end of file diff --git a/src/main/resources/application-test.properties b/src/main/resources/application-test.properties index 9306521..535b5ba 100644 --- a/src/main/resources/application-test.properties +++ b/src/main/resources/application-test.properties @@ -2,7 +2,6 @@ server.port=${PORT:8080} logging.level.org.atmosphere = warn spring.mustache.check-template-location = false -spring.datasource.url=jdbc:h2:file:./data spring.datasource.driver-class-name=org.h2.Driver spring.datasource.username=sa spring.datasource.password= diff --git a/src/main/resources/data.sql b/src/main/resources/data.sql new file mode 100644 index 0000000..4c2d6ec --- /dev/null +++ b/src/main/resources/data.sql @@ -0,0 +1,231 @@ +INSERT INTO spieler (id, name, elo1vs1, elo2vs2, elo_alt) VALUES + (1, 'Alfons', 1500, 1500, 0), + (2, 'Bertha', 1500, 1500, 0), + (3, 'Claude', 1500, 1500, 0), + (4, 'Doris', 1500, 1500, 0), + (5, 'Emil', 1500, 1500, 0), + (6, 'Friederike', 1500, 1500, 0), + (7, 'Gisela', 1500, 1500, 0), + (8, 'Heinrich', 1500, 1500, 0), + (9, 'Ingrid', 1500, 1500, 0), + (10, 'Johann', 1500, 1500, 0), + (11, 'Käthe', 1500, 1500, 0), + (12, 'Lorenz', 1500, 1500, 0), + (13, 'Marie', 1500, 1500, 0), + (14, 'Noah', 1500, 1500, 0), + (15, 'Odile', 1500, 1500, 0), + (16, 'Paula', 1500, 1500, 0), + (17, 'Quirin', 1500, 1500, 0), + (18, 'Roland', 1500, 1500, 0), + (19, 'Sophie', 1500, 1500, 0), + (20, 'Torsten', 1500, 1500, 0), + (21, 'Ulrich', 1500, 1500, 0), + (22, 'Veronika', 1500, 1500, 0), + (23, 'Werner', 1500, 1500, 0), + (24, 'Xaver', 1500, 1500, 0), + (25, 'Yseult', 1500, 1500, 0), + (26, 'Zacharias', 1500, 1500, 0); + +INSERT INTO ergebnis1vs1 (id, gewinner, verlierer, tore_verlierer, zeitpunkt) VALUES + (1, 5, 12, 2, '2024-11-01 10:00:00'), + (2, 18, 7, 1, '2024-11-02 11:30:00'), + (3, 3, 25, 0, '2024-11-03 13:45:00'), + (4, 22, 1, 3, '2024-11-04 15:00:00'), + (5, 10, 15, 2, '2024-11-05 16:15:00'), + (6, 7, 20, 4, '2024-11-06 17:30:00'), + (7, 2, 14, 1, '2024-11-07 10:45:00'), + (8, 11, 23, 0, '2024-11-08 12:00:00'), + (9, 26, 9, 5, '2024-11-09 14:15:00'), + (10, 16, 4, 3, '2024-11-10 16:30:00'), + (11, 13, 21, 2, '2024-11-11 10:00:00'), + (12, 8, 19, 1, '2024-11-12 11:30:00'), + (13, 1, 6, 0, '2024-11-13 13:45:00'), + (14, 24, 17, 3, '2024-11-14 15:00:00'), + (15, 20, 5, 2, '2024-11-15 16:15:00'), + (16, 9, 2, 4, '2024-11-16 17:30:00'), + (17, 14, 10, 1, '2024-11-17 10:45:00'), + (18, 23, 18, 0, '2024-11-18 12:00:00'), + (19, 4, 11, 5, '2024-11-19 14:15:00'), + (20, 21, 3, 3, '2024-11-20 16:30:00'), + (21, 19, 26, 2, '2024-11-21 10:00:00'), + (22, 6, 16, 1, '2024-11-22 11:30:00'), + (23, 17, 13, 0, '2024-11-23 13:45:00'), + (24, 5, 24, 3, '2024-11-24 15:00:00'), + (25, 12, 7, 2, '2024-11-25 16:15:00'), + (26, 25, 22, 4, '2024-11-26 17:30:00'), + (27, 15, 1, 1, '2024-11-27 10:45:00'), + (28, 2, 10, 0, '2024-11-28 12:00:00'), + (29, 23, 14, 5, '2024-11-29 14:15:00'), + (30, 11, 20, 3, '2024-11-30 16:30:00'), + (31, 18, 9, 2, '2024-12-01 10:00:00'), + (32, 26, 13, 1, '2024-12-02 11:30:00'), + (33, 4, 19, 0, '2024-12-03 13:45:00'), + (34, 21, 6, 3, '2024-12-04 15:00:00'), + (35, 16, 17, 2, '2024-12-05 16:15:00'), + (36, 7, 24, 4, '2024-12-06 17:30:00'), + (37, 1, 12, 1, '2024-12-07 10:45:00'), + (38, 10, 25, 0, '2024-12-08 12:00:00'), + (39, 14, 3, 5, '2024-12-09 14:15:00'), + (40, 20, 2, 3, '2024-12-10 16:30:00'), + (41, 9, 23, 2, '2024-12-11 10:00:00'), + (42, 13, 11, 1, '2024-12-12 11:30:00'), + (43, 22, 18, 0, '2024-12-13 13:45:00'), + (44, 24, 15, 3, '2024-12-14 15:00:00'), + (45, 5, 16, 2, '2024-12-15 16:15:00'), + (46, 17, 26, 4, '2024-12-16 17:30:00'), + (47, 3, 19, 1, '2024-12-17 10:45:00'), + (48, 6, 4, 0, '2024-12-18 12:00:00'), + (49, 11, 21, 5, '2024-12-19 14:15:00'), + (50, 25, 7, 3, '2024-12-20 16:30:00'), + (51, 12, 1, 2, '2024-12-21 10:00:00'), + (52, 15, 18, 1, '2024-12-22 11:30:00'), + (53, 2, 22, 0, '2024-12-23 13:45:00'), + (54, 10, 20, 3, '2024-12-24 15:00:00'), + (55, 14, 9, 2, '2024-12-25 16:15:00'), + (56, 23, 26, 4, '2024-12-26 17:30:00'), + (57, 19, 16, 1, '2024-12-27 10:45:00'), + (58, 4, 13, 0, '2024-12-28 12:00:00'), + (59, 21, 17, 5, '2024-12-29 14:15:00'), + (60, 6, 5, 3, '2024-12-30 16:30:00'), + (61, 20, 12, 2, '2025-01-01 10:00:00'), + (62, 7, 10, 1, '2025-01-02 11:30:00'), + (63, 1, 2, 0, '2025-01-03 13:45:00'), + (64, 25, 14, 3, '2025-01-04 15:00:00'), + (65, 18, 11, 2, '2025-01-05 16:15:00'), + (66, 22, 23, 4, '2025-01-06 17:30:00'), + (67, 9, 4, 1, '2025-01-07 10:45:00'), + (68, 16, 19, 0, '2025-01-08 12:00:00'), + (69, 13, 21, 5, '2025-01-09 14:15:00'), + (70, 26, 3, 3, '2025-01-10 16:30:00'), + (71, 5, 17, 2, '2025-01-11 10:00:00'), + (72, 12, 24, 1, '2025-01-12 11:30:00'), + (73, 15, 6, 0, '2025-01-13 13:45:00'), + (74, 2, 20, 3, '2025-01-14 15:00:00'), + (75, 10, 1, 2, '2025-01-15 16:15:00'), + (76, 14, 7, 4, '2025-01-16 17:30:00'), + (77, 23, 18, 1, '2025-01-17 10:45:00'), + (78, 11, 9, 0, '2025-01-18 12:00:00'), + (79, 21, 22, 5, '2025-01-19 14:15:00'), + (80, 4, 25, 3, '2025-01-20 16:30:00'), + (81, 19, 13, 2, '2025-02-01 10:00:00'), + (82, 6, 16, 1, '2025-02-02 11:30:00'), + (83, 17, 26, 0, '2025-02-03 13:45:00'), + (84, 1, 5, 3, '2025-02-04 15:00:00'), + (85, 24, 12, 2, '2025-02-05 16:15:00'), + (86, 7, 15, 4, '2025-02-06 17:30:00'), + (87, 2, 10, 1, '2025-02-07 10:45:00'), + (88, 20, 14, 0, '2025-02-08 12:00:00'), + (89, 9, 23, 5, '2025-02-09 14:15:00'), + (90, 18, 11, 3, '2025-02-10 16:30:00'), + (91, 3, 21, 2, '2025-03-01 10:00:00'), + (92, 25, 19, 1, '2025-03-02 11:30:00'), + (93, 16, 4, 0, '2025-03-03 13:45:00'), + (94, 22, 6, 3, '2025-03-04 15:00:00'), + (95, 13, 17, 2, '2025-03-05 16:15:00'), + (96, 26, 1, 4, '2025-03-06 17:30:00'), + (97, 5, 2, 1, '2025-03-07 10:45:00'), + (98, 10, 24, 0, '2025-03-08 12:00:00'), + (99, 14, 12, 5, '2025-03-09 14:15:00'), + (100, 23, 7, 3, '2025-03-10 16:30:00'); + +INSERT INTO ergebnis2vs2 (id, gewinner_vorn, gewinner_hinten, verlierer_vorn, verlierer_hinten, tore_verlierer, zeitpunkt) VALUES + (1, 5, 12, 1, 18, 2, '2024-11-01 10:00:00'), + (2, 7, 20, 3, 25, 1, '2024-11-02 11:30:00'), + (3, 22, 1, 10, 15, 0, '2024-11-03 13:45:00'), + (4, 11, 23, 2, 14, 3, '2024-11-04 15:00:00'), + (5, 26, 9, 16, 4, 2, '2024-11-05 16:15:00'), + (6, 13, 21, 8, 19, 4, '2024-11-06 17:30:00'), + (7, 1, 6, 24, 17, 1, '2024-11-07 10:45:00'), + (8, 20, 5, 9, 2, 0, '2024-11-08 12:00:00'), + (9, 14, 10, 23, 18, 5, '2024-11-09 14:15:00'), + (10, 4, 11, 21, 3, 3, '2024-11-10 16:30:00'), + (11, 19, 26, 6, 16, 2, '2024-11-11 10:00:00'), + (12, 17, 13, 5, 24, 1, '2024-11-12 11:30:00'), + (13, 12, 7, 25, 22, 0, '2024-11-13 13:45:00'), + (14, 15, 1, 2, 10, 3, '2024-11-14 15:00:00'), + (15, 23, 14, 11, 20, 2, '2024-11-15 16:15:00'), + (16, 18, 9, 26, 13, 4, '2024-11-16 17:30:00'), + (17, 4, 19, 21, 6, 1, '2024-11-17 10:45:00'), + (18, 16, 17, 7, 24, 0, '2024-11-18 12:00:00'), + (19, 1, 12, 10, 25, 5, '2024-11-19 14:15:00'), + (20, 14, 3, 20, 2, 3, '2024-11-20 16:30:00'), + (21, 9, 23, 13, 11, 2, '2024-11-21 10:00:00'), + (22, 22, 18, 24, 15, 1, '2024-11-22 11:30:00'), + (23, 5, 16, 17, 26, 0, '2024-11-23 13:45:00'), + (24, 3, 19, 6, 4, 3, '2024-11-24 15:00:00'), + (25, 11, 21, 25, 7, 2, '2024-11-25 16:15:00'), + (26, 12, 1, 15, 18, 4, '2024-11-26 17:30:00'), + (27, 2, 22, 10, 20, 1, '2024-11-27 10:45:00'), + (28, 14, 9, 23, 26, 0, '2024-11-28 12:00:00'), + (29, 19, 16, 4, 13, 5, '2024-11-29 14:15:00'), + (30, 21, 17, 6, 5, 3, '2024-11-30 16:30:00'), + (31, 20, 12, 7, 10, 2, '2024-12-01 10:00:00'), + (32, 1, 2, 25, 14, 1, '2024-12-02 11:30:00'), + (33, 18, 11, 22, 23, 0, '2024-12-03 13:45:00'), + (34, 9, 4, 16, 19, 3, '2024-12-04 15:00:00'), + (35, 13, 21, 26, 3, 2, '2024-12-05 16:15:00'), + (36, 5, 17, 12, 24, 4, '2024-12-06 17:30:00'), + (37, 15, 6, 2, 20, 1, '2024-12-07 10:45:00'), + (38, 10, 1, 14, 7, 0, '2024-12-08 12:00:00'), + (39, 23, 18, 11, 9, 5, '2024-12-09 14:15:00'), + (40, 21, 22, 4, 25, 3, '2024-12-10 16:30:00'), + (41, 19, 13, 6, 16, 2, '2024-12-11 10:00:00'), + (42, 17, 26, 1, 5, 1, '2024-12-12 11:30:00'), + (43, 24, 12, 7, 15, 0, '2024-12-13 13:45:00'), + (44, 2, 10, 20, 14, 3, '2024-12-14 15:00:00'), + (45, 9, 23, 18, 11, 2, '2024-12-15 16:15:00'), + (46, 3, 21, 25, 19, 4, '2024-12-16 17:30:00'), + (47, 16, 4, 22, 6, 1, '2024-12-17 10:45:00'), + (48, 13, 17, 26, 1, 0, '2024-12-18 12:00:00'), + (49, 5, 2, 10, 24, 5, '2024-12-19 14:15:00'), + (50, 14, 12, 23, 7, 3, '2024-12-20 16:30:00'), + (51, 18, 25, 15, 3, 2, '2024-12-21 10:00:00'), + (52, 22, 1, 7, 11, 1, '2024-12-22 11:30:00'), + (53, 20, 9, 13, 24, 0, '2024-12-23 13:45:00'), + (54, 4, 16, 2, 21, 3, '2024-12-24 15:00:00'), + (55, 6, 19, 17, 10, 2, '2024-12-25 16:15:00'), + (56, 26, 5, 1, 14, 4, '2024-12-26 17:30:00'), + (57, 12, 23, 11, 18, 1, '2024-12-27 10:45:00'), + (58, 2, 25, 20, 3, 0, '2024-12-28 12:00:00'), + (59, 15, 22, 7, 13, 5, '2024-12-29 14:15:00'), + (60, 24, 9, 16, 21, 3, '2024-12-30 16:30:00'), + (61, 10, 17, 4, 6, 2, '2025-01-01 10:00:00'), + (62, 1, 26, 19, 5, 1, '2025-01-02 11:30:00'), + (63, 11, 12, 14, 2, 0, '2025-01-03 13:45:00'), + (64, 18, 20, 23, 25, 3, '2025-01-04 15:00:00'), + (65, 3, 7, 21, 16, 2, '2025-01-05 16:15:00'), + (66, 22, 13, 1, 24, 4, '2025-01-06 17:30:00'), + (67, 5, 9, 17, 18, 1, '2025-01-07 10:45:00'), + (68, 10, 15, 2, 26, 0, '2025-01-08 12:00:00'), + (69, 14, 11, 20, 4, 5, '2025-01-09 14:15:00'), + (70, 23, 19, 12, 21, 3, '2025-01-10 16:30:00'), + (71, 6, 25, 3, 1, 2, '2025-01-11 10:00:00'), + (72, 16, 7, 22, 10, 1, '2025-01-12 11:30:00'), + (73, 17, 13, 14, 15, 0, '2025-01-13 13:45:00'), + (74, 18, 24, 5, 2, 3, '2025-01-14 15:00:00'), + (75, 11, 20, 23, 26, 2, '2025-01-15 16:15:00'), + (76, 9, 21, 4, 19, 4, '2025-01-16 17:30:00'), + (77, 12, 1, 6, 17, 1, '2025-01-17 10:45:00'), + (78, 25, 10, 3, 22, 0, '2025-01-18 12:00:00'), + (79, 7, 13, 15, 14, 5, '2025-01-19 14:15:00'), + (80, 2, 18, 24, 20, 3, '2025-01-20 16:30:00'), + (81, 16, 11, 5, 23, 2, '2025-02-01 10:00:00'), + (82, 1, 4, 9, 26, 1, '2025-02-02 11:30:00'), + (83, 19, 21, 12, 17, 0, '2025-02-03 13:45:00'), + (84, 6, 22, 13, 2, 3, '2025-02-04 15:00:00'), + (85, 20, 7, 10, 14, 2, '2025-02-05 16:15:00'), + (86, 25, 15, 1, 18, 4, '2025-02-06 17:30:00'), + (87, 23, 3, 24, 11, 1, '2025-02-07 10:45:00'), + (88, 5, 26, 16, 9, 0, '2025-02-08 12:00:00'), + (89, 12, 4, 17, 21, 5, '2025-02-09 14:15:00'), + (90, 13, 6, 2, 19, 3, '2025-02-10 16:30:00'), + (91, 10, 22, 18, 7, 2, '2025-03-01 10:00:00'), + (92, 14, 25, 11, 1, 1, '2025-03-02 11:30:00'), + (93, 20, 23, 3, 16, 0, '2025-03-03 13:45:00'), + (94, 9, 17, 26, 13, 3, '2025-03-04 15:00:00'), + (95, 21, 5, 24, 12, 2, '2025-03-05 16:15:00'), + (96, 4, 15, 2, 10, 4, '2025-03-06 17:30:00'), + (97, 6, 1, 18, 14, 1, '2025-03-07 10:45:00'), + (98, 19, 23, 7, 25, 0, '2025-03-08 12:00:00'), + (99, 11, 26, 22, 3, 5, '2025-03-09 14:15:00'), + (100, 16, 12, 5, 17, 3, '2025-03-10 16:30:00'); \ No newline at end of file diff --git a/src/main/resources/schema.sql b/src/main/resources/schema.sql new file mode 100644 index 0000000..c056b5d --- /dev/null +++ b/src/main/resources/schema.sql @@ -0,0 +1,58 @@ +CREATE SEQUENCE ergebnis1vs1_seq INCREMENT BY 50 START WITH 1; + +CREATE SEQUENCE ergebnis2vs2_seq INCREMENT BY 50 START WITH 1; + +CREATE SEQUENCE spieler_seq INCREMENT BY 50 START WITH 1; + +CREATE TABLE ergebnis1vs1 +( + id BIGINT NOT NULL, + gewinner INT NOT NULL, + verlierer INT NOT NULL, + tore_verlierer SMALLINT NOT NULL, + zeitpunkt datetime NULL, + CONSTRAINT pk_ergebnis1vs1 PRIMARY KEY (id) +); + +CREATE TABLE ergebnis2vs2 +( + id BIGINT NOT NULL, + gewinner_vorn INT NOT NULL, + gewinner_hinten INT NOT NULL, + verlierer_vorn INT NOT NULL, + verlierer_hinten INT NOT NULL, + tore_verlierer SMALLINT NOT NULL, + zeitpunkt datetime NOT NULL, + CONSTRAINT pk_ergebnis2vs2 PRIMARY KEY (id) +); + +CREATE TABLE spieler +( + id INT NOT NULL, + name VARCHAR(255) NOT NULL, + elo1vs1 FLOAT NOT NULL, + elo2vs2 FLOAT NOT NULL, + elo_alt FLOAT NULL, + CONSTRAINT pk_spieler PRIMARY KEY (id) +); + +ALTER TABLE spieler + ADD CONSTRAINT uc_spieler_name UNIQUE (name); + +ALTER TABLE ergebnis1vs1 + ADD CONSTRAINT FK_ERGEBNIS1VS1_ON_GEWINNER FOREIGN KEY (gewinner) REFERENCES spieler (id); + +ALTER TABLE ergebnis1vs1 + ADD CONSTRAINT FK_ERGEBNIS1VS1_ON_VERLIERER FOREIGN KEY (verlierer) REFERENCES spieler (id); + +ALTER TABLE ergebnis2vs2 + ADD CONSTRAINT FK_ERGEBNIS2VS2_ON_GEWINNER_HINTEN FOREIGN KEY (gewinner_hinten) REFERENCES spieler (id); + +ALTER TABLE ergebnis2vs2 + ADD CONSTRAINT FK_ERGEBNIS2VS2_ON_GEWINNER_VORN FOREIGN KEY (gewinner_vorn) REFERENCES spieler (id); + +ALTER TABLE ergebnis2vs2 + ADD CONSTRAINT FK_ERGEBNIS2VS2_ON_VERLIERER_HINTEN FOREIGN KEY (verlierer_hinten) REFERENCES spieler (id); + +ALTER TABLE ergebnis2vs2 + ADD CONSTRAINT FK_ERGEBNIS2VS2_ON_VERLIERER_VORN FOREIGN KEY (verlierer_vorn) REFERENCES spieler (id); \ No newline at end of file