Skip to content

Commit

Permalink
added support for a postgres Database with password sys
Browse files Browse the repository at this point in the history
also changed some table names from Tables to Board and from User to People
  • Loading branch information
OleSchima committed Jul 21, 2023
1 parent ec28077 commit 6fa71fb
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 86 deletions.
8 changes: 8 additions & 0 deletions java/mtsj/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,14 @@
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>

<!-- Postgres Database -->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.3.1</version>
</dependency>


<!-- Flyway for DB Schema version management and migration -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.devonfw.application.mtsj.general.dataaccess.api.ApplicationPersistenceEntity;

@Entity
@javax.persistence.Table(name = "\"Table\"")
@javax.persistence.Table(name = "Board")
public class TableEntity extends ApplicationPersistenceEntity implements Table {

private Integer seatsNumber;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import com.devonfw.application.mtsj.usermanagement.common.api.User;

@Entity
@Table(name = "User")
@Table(name = "People")
public class UserEntity extends ApplicationPersistenceEntity implements User {

private String username;
Expand Down
26 changes: 19 additions & 7 deletions java/mtsj/core/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ server.servlet.context-path=/mythaistar
client.port=4200
security.expose.error.details=false

spring.jpa.hibernate.ddl-auto=validate
spring.jpa.hibernate.ddl-auto=none
#show sql statement
logging.level.org.hibernate.SQL=debug

Expand All @@ -24,9 +24,11 @@ spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.Im
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl

# Flyway for Database Setup and Migrations
#spring.flyway.enabled=true
spring.flyway.enabled=true
spring.flyway.clean-on-validation-error=true
spring.flyway.locations=classpath:db/migration,classpath:db/specific/h2
#spring.flyway.locations=classpath:db/migration,classpath:db/specific/h2
spring.flyway.locations=classpath:db/specific/postgres,classpath:db/migration

# Requires spring 5.1 - see https://jira.spring.io/browse/SPR-16460
#uncomment below 4 properties for Sap hana
Expand All @@ -37,13 +39,23 @@ spring.flyway.locations=classpath:db/migration,classpath:db/specific/h2


#Comment the following profile 'h2mem' if the database used is other than in-memory database H2
spring.profiles.active=h2mem
#spring.profiles.active=h2mem


spring.datasource.username=sa
spring.datasource.password=
spring.datasource.url=jdbc:h2:C:/data/sampledata

#spring.datasource.username=sa
#spring.datasource.password=
#spring.datasource.url=jdbc:h2:C:/data/sampledata2;MODE=PostgreSQL

#Comment the following lines to deactivate the postgres Database
spring.datasource.url=jdbc:postgresql://localhost:5432/postgres
spring.datasource.username=postgres
spring.datasource.password=sys
spring.datasource.driver-class-name=org.postgresql.Driver
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect

#spring.datasource.url=jdbc:postgresql://localhost:5432/postgres
#spring.datasource.username=postgres
#spring.datasource.password=


#UnComment the following profile 'hana' if the database used is SAP HANA
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ security.basic.enabled=false
## Flyway for Database Setup and Migrations
spring.flyway.enabled=true
spring.flyway.clean-on-validation-error=true
spring.flyway.locations=classpath:db/migration,classpath:db/specific/h2
spring.flyway.locations=classpath:db/specific/postgres,classpath:db/migration

spring.profiles.active=${mts.database.profile}
#spring.profiles.active=${mts.database.profile}
## The following configs need to be set in config/application.properties on your specific environment
#spring.datasource.url=TODO
#spring.datasource.username=TODO
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,18 @@ INSERT INTO UserRole(id, modificationCounter, name, active) VALUES (0, 1, 'Custo
INSERT INTO UserRole(id, modificationCounter, name, active) VALUES (1, 1, 'Waiter', true);
INSERT INTO UserRole(id, modificationCounter, name, active) VALUES (2, 1, 'Manager', true);

INSERT INTO User(id, modificationCounter, username, password, twoFactorStatus, email, idRole) VALUES (0, 1, 'user0', '{bcrypt}$2a$10$qPM1WjcRKAffHxWXYEfPJOh2vGPlT/Fdv.hJX/LaZjzg/Wtj2csqO', false, 'user0@mail.com', 0);
INSERT INTO User(id, modificationCounter, username, password, twoFactorStatus, email, idRole) VALUES (1, 1, 'waiter', '{bcrypt}$2a$10$1CAKyUHbX6RJqT5cUP6/aOMTIlYYvGIO/a3Dt/erbYKKgmbgJMGsG', false, 'waiter@mail.com', 1);
INSERT INTO User(id, modificationCounter, username, password, twoFactorStatus, email, idRole) VALUES (2, 1, 'manager', '{bcrypt}$2a$10$IsTlZemkiPKE2gjtnSMlJOX5.uitNHXNRpLYyvyxNbHEhjpY.XdTq', false, 'manager@mail.com', 2);
INSERT INTO People(id, modificationCounter, username, password, twoFactorStatus, email, idRole) VALUES (0, 1, 'user0', '{bcrypt}$2a$10$qPM1WjcRKAffHxWXYEfPJOh2vGPlT/Fdv.hJX/LaZjzg/Wtj2csqO', false, 'user0@mail.com', 0);
INSERT INTO People(id, modificationCounter, username, password, twoFactorStatus, email, idRole) VALUES (1, 1, 'waiter', '{bcrypt}$2a$10$1CAKyUHbX6RJqT5cUP6/aOMTIlYYvGIO/a3Dt/erbYKKgmbgJMGsG', false, 'waiter@mail.com', 1);
INSERT INTO People(id, modificationCounter, username, password, twoFactorStatus, email, idRole) VALUES (2, 1, 'manager', '{bcrypt}$2a$10$IsTlZemkiPKE2gjtnSMlJOX5.uitNHXNRpLYyvyxNbHEhjpY.XdTq', false, 'manager@mail.com', 2);


INSERT INTO "Table"(id, modificationCounter, seatsNumber) VALUES (0, 1, 4);
INSERT INTO "Table"(id, modificationCounter, seatsNumber) VALUES (1, 1, 4);
INSERT INTO "Table"(id, modificationCounter, seatsNumber) VALUES (2, 1, 4);
INSERT INTO "Table"(id, modificationCounter, seatsNumber) VALUES (3, 1, 4);
INSERT INTO "Table"(id, modificationCounter, seatsNumber) VALUES (4, 1, 6);
INSERT INTO "Table"(id, modificationCounter, seatsNumber) VALUES (5, 1, 6);
INSERT INTO "Table"(id, modificationCounter, seatsNumber) VALUES (6, 1, 6);
INSERT INTO "Table"(id, modificationCounter, seatsNumber) VALUES (7, 1, 8);
INSERT INTO "Table"(id, modificationCounter, seatsNumber) VALUES (8, 1, 8);
INSERT INTO Board(id, modificationCounter, seatsNumber) VALUES (0, 1, 4);
INSERT INTO Board(id, modificationCounter, seatsNumber) VALUES (1, 1, 4);
INSERT INTO Board(id, modificationCounter, seatsNumber) VALUES (2, 1, 4);
INSERT INTO Board(id, modificationCounter, seatsNumber) VALUES (3, 1, 4);
INSERT INTO Board(id, modificationCounter, seatsNumber) VALUES (4, 1, 6);
INSERT INTO Board(id, modificationCounter, seatsNumber) VALUES (5, 1, 6);
INSERT INTO Board(id, modificationCounter, seatsNumber) VALUES (6, 1, 6);
INSERT INTO Board(id, modificationCounter, seatsNumber) VALUES (7, 1, 8);
INSERT INTO Board(id, modificationCounter, seatsNumber) VALUES (8, 1, 8);



-- Common Booking with already created orders
INSERT INTO Booking(id, modificationCounter, idUser, name, bookingToken, comment, email, bookingDate, expirationDate, creationDate, canceled, bookingType, idTable, idOrder, assistants) VALUES(0, 1, 0, 'user0', 'CB_20170509_123502555Z', 'Booking Type CSR', 'user0@mail.com', DATEADD('DAY', 5, CURRENT_TIMESTAMP), DATEADD('DAY', 5, DATEADD('HOUR', -1, CURRENT_TIMESTAMP)), CURRENT_TIMESTAMP, false, 0, 0, 0, 3);
INSERT INTO Booking(id, modificationCounter, idUser, name, bookingToken, comment, email, bookingDate, expirationDate, creationDate, canceled, bookingType, idTable, idOrder, assistants) VALUES(1, 1, 0, 'user1', 'CB_20170510_123502575Z', 'Booking Type GSR', 'user1@mail.com', DATEADD('DAY', 5, CURRENT_TIMESTAMP), DATEADD('DAY', 5, DATEADD('HOUR', -1, CURRENT_TIMESTAMP)), CURRENT_TIMESTAMP, false, 1, 1, 1, null);
-- Common Booking without orders
INSERT INTO Booking(id, modificationCounter, idUser, name, bookingToken, comment, email, bookingDate, expirationDate, creationDate, canceled, bookingType, idTable, idOrder, assistants) VALUES(2, 1, 0, 'user2', 'CB_20170510_123502595Z', 'Booking Type GSR', 'user2@mail.com', DATEADD('DAY', 5, CURRENT_TIMESTAMP), DATEADD('DAY', 5, DATEADD('HOUR', -1, CURRENT_TIMESTAMP)), CURRENT_TIMESTAMP, false, 0, 2, null, 5);

-- Guest Booking
INSERT INTO Booking(id, modificationCounter, idUser, name, bookingToken, comment, email, bookingDate, expirationDate, creationDate, canceled, bookingType, idTable, idOrder) VALUES(3, 1, 0, 'host1', 'CB_20170510_123502655Z', 'Booking Type GSR', 'host1@mail.com', DATEADD('DAY', 5, CURRENT_TIMESTAMP), DATEADD('DAY', 5, DATEADD('HOUR', -1, CURRENT_TIMESTAMP)), CURRENT_TIMESTAMP, false, 1, 3, null);
-- guests for booking with id 3
INSERT INTO InvitedGuest(id, modificationCounter, idBooking, guestToken, email, accepted, modificationDate) VALUES(0, 1, 3, 'GB_20170510_02350266501Z', 'guest0@mail.com', true, DATEADD('DAY', 5, CURRENT_TIMESTAMP));
INSERT INTO InvitedGuest(id, modificationCounter, idBooking, guestToken, email, accepted, modificationDate) VALUES(1, 1, 3, 'GB_20170510_12350266501Z', 'guest1@mail.com', true, DATEADD('DAY', 5, CURRENT_TIMESTAMP));
INSERT INTO InvitedGuest(id, modificationCounter, idBooking, guestToken, email, accepted, modificationDate) VALUES(2, 1, 3, 'GB_20170510_22350266501Z', 'guest2@mail.com', false, DATEADD('DAY', 5, CURRENT_TIMESTAMP));
INSERT INTO InvitedGuest(id, modificationCounter, idBooking, guestToken, email, accepted, modificationDate) VALUES(3, 1, 3, 'GB_20170510_32350266501Z', 'guest3@mail.com', true, DATEADD('DAY', 5, CURRENT_TIMESTAMP));
INSERT INTO InvitedGuest(id, modificationCounter, idBooking, guestToken, email, accepted, modificationDate) VALUES(4, 1, 3, 'GB_20170510_42350266501Z', 'guest4@mail.com', false, DATEADD('DAY', 5, CURRENT_TIMESTAMP));

---- Guest Booking
INSERT INTO Booking(id, modificationCounter, idUser, name, bookingToken, comment, email, bookingDate, expirationDate, creationDate, canceled, bookingType, idTable, idOrder) VALUES(4, 1, 0, 'host1', 'CB_20170510_123503600Z', 'Booking Type GSR', 'host1@mail.com', DATEADD('DAY', 5, CURRENT_TIMESTAMP), DATEADD('DAY', 5, DATEADD('HOUR', -1, CURRENT_TIMESTAMP)), CURRENT_TIMESTAMP, false, 1, 3, null);
---- guests for booking with id 4
INSERT INTO InvitedGuest(id, modificationCounter, idBooking, guestToken, email, accepted, modificationDate) VALUES(5, 1, 4, 'GB_20170510_52350266501Z', 'guest5@mail.com', true, DATEADD('DAY', 5, CURRENT_TIMESTAMP));
INSERT INTO InvitedGuest(id, modificationCounter, idBooking, guestToken, email, accepted, modificationDate) VALUES(6, 1, 4, 'GB_20170510_62350266501Z', 'guest6@mail.com', false, DATEADD('DAY', 5, CURRENT_TIMESTAMP));
INSERT INTO InvitedGuest(id, modificationCounter, idBooking, guestToken, email, accepted, modificationDate) VALUES(7, 1, 4, 'GB_20170510_72350266501Z', 'guest7@mail.com', true, DATEADD('DAY', 5, CURRENT_TIMESTAMP));
INSERT INTO InvitedGuest(id, modificationCounter, idBooking, guestToken, email, accepted, modificationDate) VALUES(8, 1, 4, 'GB_20170510_82350266501Z', 'guest0@mail.com', true, DATEADD('DAY', 5, CURRENT_TIMESTAMP));
INSERT INTO InvitedGuest(id, modificationCounter, idBooking, guestToken, email, accepted, modificationDate) VALUES(9, 1, 4, 'GB_20170510_92350266501Z', 'guest1@mail.com', false, DATEADD('DAY', 5, CURRENT_TIMESTAMP));

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
CREATE SEQUENCE HIBERNATE_SEQUENCE START WITH 1000000;

-- *** Table ***
CREATE TABLE "Table" (
CREATE TABLE Board (
id BIGINT NOT NULL AUTO_INCREMENT,
modificationCounter INTEGER NOT NULL,
seatsNumber INTEGER NOT NULL,
Expand All @@ -23,7 +23,7 @@ CREATE TABLE UserRole (
);

-- *** User ***
CREATE TABLE User (
CREATE TABLE People (
id BIGINT NOT NULL AUTO_INCREMENT,
modificationCounter INTEGER NOT NULL,
username VARCHAR (255) UNIQUE NOT NULL,
Expand Down Expand Up @@ -54,8 +54,8 @@ CREATE TABLE Booking (
idOrder BIGINT,
assistants INTEGER,
CONSTRAINT PK_Booking PRIMARY KEY(id),
CONSTRAINT FK_Booking_idUser FOREIGN KEY(idUser) REFERENCES User(id) NOCHECK,
CONSTRAINT FK_Booking_idTable FOREIGN KEY(idTable) REFERENCES "Table"(id) NOCHECK
CONSTRAINT FK_Booking_idUser FOREIGN KEY(idUser) REFERENCES People(id) NOCHECK,
CONSTRAINT FK_Booking_idTable FOREIGN KEY(idTable) REFERENCES Board(id) NOCHECK
);

-- *** InvitedGuest ***
Expand Down Expand Up @@ -180,7 +180,7 @@ CREATE TABLE UserFavourite (
idUser BIGINT NOT NULL,
idDish BIGINT NOT NULL,
CONSTRAINT PK_UserFavourite PRIMARY KEY(id),
CONSTRAINT FK_UserFavourite_idUser FOREIGN KEY(idUser) REFERENCES User(id) NOCHECK,
CONSTRAINT FK_UserFavourite_idUser FOREIGN KEY(idUser) REFERENCES People(id) NOCHECK,
CONSTRAINT FK_UserFavourite_idDish FOREIGN KEY(idDish) REFERENCES Dish(id) NOCHECK
);

Expand Down

0 comments on commit 6fa71fb

Please sign in to comment.