diff --git a/src/main/resources/application-dev.properties b/src/main/resources/application-dev.properties index 44397a8..9e659a0 100644 --- a/src/main/resources/application-dev.properties +++ b/src/main/resources/application-dev.properties @@ -1,5 +1,4 @@ spring.datasource.username=sa -spring.datasource.url=jdbc:h2:mem:testdb;MODE=PostgreSQL +spring.datasource.url=jdbc:h2:mem:testdb;MODE=PostgreSQL;DATABASE_TO_LOWER=TRUE;DEFAULT_NULL_ORDERING=HIGH logging.level.web=DEBUG -logging.level.sql=DEBUG -spring.sql.init.mode=always \ No newline at end of file +logging.level.sql=DEBUG \ No newline at end of file diff --git a/src/main/resources/application-prod.properties b/src/main/resources/application-prod.properties index ba82142..b0ad889 100644 --- a/src/main/resources/application-prod.properties +++ b/src/main/resources/application-prod.properties @@ -1,4 +1,3 @@ spring.datasource.username=${DB_LOGIN} spring.datasource.password=${DB_PASSWORD} -spring.datasource.url=jdbc:postgresql://${DB_URL} -spring.sql.init.mode=always \ No newline at end of file +spring.datasource.url=jdbc:postgresql://${DB_URL} \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 9373df8..3b79c9c 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -4,12 +4,18 @@ server.port=8080 ## spring.jackson.property-naming-strategy=SNAKE_CASE ## -spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect +spring.jpa.database-platform=org.hibernate.dialect.PostgreSQL95Dialect spring.h2.console.enabled=true spring.h2.console.path=/h2 -spring.jpa.hibernate.ddl-auto=none +spring.jpa.hibernate.ddl-auto=create-drop +## +spring.jpa.properties.javax.persistence.schema-generation.scripts.action=create-drop +spring.jpa.properties.javax.persistence.schema-generation.scripts.create-target=create.sql +spring.jpa.properties.javax.persistence.schema-generation.scripts.create-source=metadata +## +spring.jpa.properties.javax.persistence.schema-generation.scripts.drop-target=drop.sql +spring.jpa.properties.javax.persistence.schema-generation.scripts.drop-source=metadata +## ##DEFAULT PAGE PROPS page-config.default-page-num=0 page-config.default-page-size=5 -## - diff --git a/src/main/resources/schema.sql b/src/main/resources/schema.sql index 7292adc..2b9255d 100644 --- a/src/main/resources/schema.sql +++ b/src/main/resources/schema.sql @@ -1,109 +1,19 @@ -drop table IF EXISTS talent CASCADE ; -drop table IF EXISTS talent_description CASCADE ; -drop table IF EXISTS talent_link CASCADE ; -drop table IF EXISTS talent_contact CASCADE ; -drop table IF EXISTS talent_attached_file CASCADE ; -drop table IF EXISTS talent_talents CASCADE ; -drop table IF EXISTS user_info CASCADE ; -drop table IF EXISTS user_authorities CASCADE ; -drop table IF EXISTS talent_talents CASCADE ; -drop table IF EXISTS authority CASCADE ; -drop table IF EXISTS talent_proofs CASCADE ; - -create TABLE talent ( - id BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL, - first_name VARCHAR(20) NOT NULL, - last_name VARCHAR(20) NOT NULL, - specialization VARCHAR(30) NOT NULL, - image VARCHAR(100), - CONSTRAINT pk_talent PRIMARY KEY (id) -); - -create TABLE talent_description ( - id BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL, - talent_id BIGINT NOT NULL, - BIO VARCHAR(255) NOT NULL, - addition_info VARCHAR(255) NOT NULL, - CONSTRAINT pk_talent_description PRIMARY KEY (id) -); - -alter table talent_description add CONSTRAINT FK_TALENT_DESCRIPTION_ON_TALENT FOREIGN KEY (talent_id) REFERENCES talent (id); - -create TABLE talent_link ( - id BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL, - talent_id BIGINT NOT NULL, - link VARCHAR(255) NOT NULL, - CONSTRAINT pk_talent_link PRIMARY KEY (id) -); - -alter table talent_link add CONSTRAINT FK_TALENT_LINK_ON_TALENT FOREIGN KEY (talent_id) REFERENCES talent (id); - -CREATE TABLE talent_talents -( - id BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL, - talent_id BIGINT NOT NULL, - talent_name VARCHAR(255), - CONSTRAINT pk_talent_talents PRIMARY KEY (id) -); - -ALTER TABLE talent_talents - ADD CONSTRAINT FK_TALENT_TALENTS_ON_TALENT FOREIGN KEY (talent_id) REFERENCES talent (id); - -create TABLE talent_contact ( - id BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL, - talent_id BIGINT NOT NULL, - contact VARCHAR(255) NOT NULL, - CONSTRAINT pk_talent_contact PRIMARY KEY (id) -); - -alter table talent_contact add CONSTRAINT FK_TALENT_CONTACT_ON_TALENT FOREIGN KEY (talent_id) REFERENCES talent (id); - -create TABLE talent_attached_file ( - id BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL, - talent_id BIGINT NOT NULL, - attached_file VARCHAR(100) NOT NULL, - CONSTRAINT pk_talent_attached_file PRIMARY KEY (id) -); - -alter table talent_attached_file add CONSTRAINT FK_TALENT_ATTACHED_FILE_ON_TALENT FOREIGN KEY (talent_id) REFERENCES talent (id); - -CREATE TABLE talent_proofs ( - id BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL, - talent_id BIGINT NOT NULL, - link VARCHAR(100), - text VARCHAR(255), - status VARCHAR(20), - created TIMESTAMP, - CONSTRAINT pk_talent_proofs PRIMARY KEY (id) -); - -ALTER TABLE talent_proofs ADD CONSTRAINT FK_TALENT_PROOFS_ON_TALENT FOREIGN KEY (talent_id) REFERENCES talent (id); ---user tables-- -CREATE TABLE authority -( - id BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL, - authority VARCHAR(20) NOT NULL, - CONSTRAINT pk_authority PRIMARY KEY (id) -); - -CREATE TABLE user_info -( - id BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL, - talent_id BIGINT NOT NULL, - login VARCHAR(100) NOT NULL, - password VARCHAR(255) NOT NULL, - CONSTRAINT pk_user_info PRIMARY KEY (id) -); - -CREATE TABLE user_authorities -( - user_id BIGINT NOT NULL, - authority_id BIGINT NOT NULL, - CONSTRAINT pk_user_authorities PRIMARY KEY (user_id, authority_id) -); - -ALTER TABLE user_info ADD CONSTRAINT FK_USER_INFO_ON_USER_ID FOREIGN KEY (talent_id) REFERENCES talent (id); - -ALTER TABLE user_authorities ADD CONSTRAINT fk_useaut_on_authority FOREIGN KEY (authority_id) REFERENCES authority (id); - -ALTER TABLE user_authorities ADD CONSTRAINT fk_useaut_on_user_info FOREIGN KEY (user_id) REFERENCES user_info (id); +create table authority (id bigserial not null, authority varchar(20) not null, primary key (id)); +create table talent (id bigserial not null, first_name varchar(20), image varchar(100), last_name varchar(20), specialization varchar(30), primary key (id)); +create table talent_attached_file (id bigserial not null, attached_file varchar(100), talent_id bigint not null, primary key (id)); +create table talent_contact (id bigserial not null, contact varchar(255), talent_id bigint not null, primary key (id)); +create table talent_description (id bigserial not null, addition_info varchar(255), bio varchar(255), talent_id bigint not null, primary key (id)); +create table talent_link (id bigserial not null, link varchar(255), talent_id bigint not null, primary key (id)); +create table talent_proofs (id bigserial not null, created timestamp(6), link varchar(100), status varchar(20) not null, talent_id bigint not null, text varchar(255), primary key (id)); +create table talent_talents (id bigserial not null, talent_id bigint not null, talent_name varchar(255), primary key (id)); +create table user_authorities (user_id bigint not null, authority_id bigint not null, primary key (user_id, authority_id)); +create table user_info (id bigserial not null, login varchar(100) not null, password varchar(255) not null, talent_id bigint not null, primary key (id)); +alter table if exists talent_attached_file add constraint FKdtjomr27q99ufe065trf8jr7b foreign key (talent_id) references talent; +alter table if exists talent_contact add constraint FKkftncuyutiv4ac4s16ru8tg8x foreign key (talent_id) references talent; +alter table if exists talent_description add constraint FKcswnowkosgq1rnj1s1b3gnk8q foreign key (talent_id) references talent; +alter table if exists talent_link add constraint FKp64n3c44eqoremntcxemdiy1c foreign key (talent_id) references talent; +alter table if exists talent_proofs add constraint FKotnc7wmkq7f6g758vkr29lyi5 foreign key (talent_id) references talent; +alter table if exists talent_talents add constraint FK1q9cywkek4g3o4femq0n6ecl1 foreign key (talent_id) references talent; +alter table if exists user_authorities add constraint FK2n9bab2v62l3y2jgu3qup4etw foreign key (authority_id) references authority; +alter table if exists user_authorities add constraint FKhrxn11h0wl1txiaukxjp01uji foreign key (user_id) references user_info; +alter table if exists user_info add constraint FKng34qd4ikmdcwg4f8bcpghar9 foreign key (talent_id) references talent;