fix init data with flyway and fix init data with flyway in docker-compose
This commit is contained in:
@@ -1,27 +0,0 @@
|
||||
package com.jambotronGroup.jambotron.configuretions;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.flywaydb.core.Flyway;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
@Configuration
|
||||
@RequiredArgsConstructor
|
||||
public class FlyWayConfiguration {
|
||||
|
||||
@Autowired
|
||||
private Environment environment;
|
||||
|
||||
@Bean(initMethod = "migrate")
|
||||
public Flyway flyway() {
|
||||
return new Flyway(Flyway.configure()
|
||||
.baselineOnMigrate(true)
|
||||
.dataSource(
|
||||
environment.getRequiredProperty("flyway.url"),
|
||||
environment.getRequiredProperty("flyway.user"),
|
||||
environment.getRequiredProperty("flyway.password"))
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -9,11 +9,14 @@ spring.datasource.password= postgrespw
|
||||
#spring.datasource.password=${SPRING_DATASOURCE_PASSWORD}
|
||||
|
||||
|
||||
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation= true
|
||||
#spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation= true
|
||||
spring.jpa.properties.hibernate.dialect= org.hibernate.dialect.PostgreSQLDialect
|
||||
|
||||
# Hibernate ddl auto (create, create-drop, validate, update)
|
||||
spring.jpa.hibernate.ddl-auto= update
|
||||
#spring.jpa.hibernate.ddl-auto= update
|
||||
|
||||
spring.jpa.show-sql=true
|
||||
|
||||
|
||||
# App Properties
|
||||
app.jwtSecret= ======================spring=back====================
|
||||
@@ -33,9 +36,9 @@ spa.default-file=classpath:/public/browser/index.html
|
||||
|
||||
spring.docker.compose.file=../Docker/docker-compose.yml
|
||||
|
||||
spring.flyway.locations=classpath:db.migration
|
||||
spring.flyway.baseline-on-migrate=true
|
||||
spring.flyway.validate-on-migrate=true
|
||||
|
||||
flyway.user=admin
|
||||
flyway.password=postgrespw
|
||||
flyway.schemas=jambotronDB
|
||||
flyway.url=jdbc:postgresql://localhost:5432/jambotronDB
|
||||
spring.flyway.user=admin
|
||||
spring.flyway.password=postgrespw
|
||||
spring.flyway.url=jdbc:postgresql://localhost:5432/jambotronDB
|
||||
@@ -0,0 +1,7 @@
|
||||
|
||||
CREATE TABLE IF NOT EXISTS roles
|
||||
(
|
||||
id INT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
name character varying(20) COLLATE pg_catalog."default"
|
||||
|
||||
);
|
||||
@@ -1,62 +0,0 @@
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS public.roles
|
||||
(
|
||||
id INT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
name character varying(20) COLLATE pg_catalog."default"
|
||||
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS public.users
|
||||
(
|
||||
id INT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
email character varying(50) COLLATE pg_catalog."default",
|
||||
password character varying(120) COLLATE pg_catalog."default",
|
||||
username character varying(20) COLLATE pg_catalog."default",
|
||||
|
||||
CONSTRAINT uk6dotkott2kjsp8vw4d0m25fb7 UNIQUE (email),
|
||||
CONSTRAINT ukr43af9ap4edm43mmtq01oddj6 UNIQUE (username)
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS public.user_roles
|
||||
(
|
||||
user_id bigint NOT NULL,
|
||||
role_id integer NOT NULL,
|
||||
CONSTRAINT user_roles_pkey PRIMARY KEY (user_id, role_id),
|
||||
CONSTRAINT fkh8ciramu9cc9q3qcqiv4ue8a6 FOREIGN KEY (role_id)
|
||||
REFERENCES public.roles (id) MATCH SIMPLE
|
||||
ON UPDATE NO ACTION
|
||||
ON DELETE NO ACTION,
|
||||
CONSTRAINT fkhfh9dx7w3ubf1co1vdev94g3f FOREIGN KEY (user_id)
|
||||
REFERENCES public.users (id) MATCH SIMPLE
|
||||
ON UPDATE NO ACTION
|
||||
ON DELETE NO ACTION
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS public.tutorials
|
||||
(
|
||||
id bigint NOT NULL,
|
||||
description character varying(255) COLLATE pg_catalog."default",
|
||||
published boolean,
|
||||
title character varying(255) COLLATE pg_catalog."default",
|
||||
CONSTRAINT tutorials_pkey PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
|
||||
INSERT INTO roles (id, name) VALUES (1, 'ROLE_USER');
|
||||
INSERT INTO roles (id, name) VALUES (2, 'ROLE_MODERATOR');
|
||||
INSERT INTO roles (id, name) VALUES (3, 'ROLE_ADMIN');
|
||||
|
||||
INSERT INTO users (id, email, password, username)
|
||||
VALUES (1, 'liosha84@gmail.com', '$2a$10$qyoKXYSukha6XCjorTzoweF4Os1pwmwyzbaSsb3RCVB0LK6WLQKPC', 'Admin');
|
||||
INSERT INTO users (id, email, password, username)
|
||||
VALUES (4, 'Moderator@gmail.com', '$2a$10$zLo5th8Xbfq.MM7y/dCRQu3Ud7HHyAwm.7.yS08ytJtkHMKrbOJlu', 'Moderator');
|
||||
INSERT INTO users (id, email, password, username)
|
||||
VALUES (5, 'user@gmail.com', '$2a$10$2EcwYffteBF3GhVaf5qPB.I7XiHepDEauU5D4fx9fpBXMTZI/QnnC', 'User');
|
||||
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id) VALUES (5, 1);
|
||||
INSERT INTO user_roles (user_id, role_id) VALUES (1, 3);
|
||||
INSERT INTO user_roles (user_id, role_id) VALUES (4, 2);
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS users
|
||||
(
|
||||
id INT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
email character varying(50) COLLATE pg_catalog."default",
|
||||
password character varying(120) COLLATE pg_catalog."default",
|
||||
username character varying(20) COLLATE pg_catalog."default",
|
||||
|
||||
CONSTRAINT uk6dotkott2kjsp8vw4d0m25fb7 UNIQUE (email),
|
||||
CONSTRAINT ukr43af9ap4edm43mmtq01oddj6 UNIQUE (username)
|
||||
);
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
|
||||
CREATE TABLE IF NOT EXISTS public.user_roles
|
||||
(
|
||||
user_id bigint NOT NULL,
|
||||
role_id integer NOT NULL,
|
||||
CONSTRAINT user_roles_pkey PRIMARY KEY (user_id, role_id),
|
||||
CONSTRAINT fkh8ciramu9cc9q3qcqiv4ue8a6 FOREIGN KEY (role_id)
|
||||
REFERENCES public.roles (id) MATCH SIMPLE
|
||||
ON UPDATE NO ACTION
|
||||
ON DELETE NO ACTION,
|
||||
CONSTRAINT fkhfh9dx7w3ubf1co1vdev94g3f FOREIGN KEY (user_id)
|
||||
REFERENCES public.users (id) MATCH SIMPLE
|
||||
ON UPDATE NO ACTION
|
||||
ON DELETE NO ACTION
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS public.tutorials
|
||||
(
|
||||
id bigint NOT NULL,
|
||||
description character varying(255) COLLATE pg_catalog."default",
|
||||
published boolean,
|
||||
title character varying(255) COLLATE pg_catalog."default",
|
||||
CONSTRAINT tutorials_pkey PRIMARY KEY (id)
|
||||
);
|
||||
@@ -0,0 +1,20 @@
|
||||
|
||||
INSERT INTO roles (id, name) OVERRIDING SYSTEM VALUE VALUES (1, 'ROLE_USER');
|
||||
INSERT INTO roles (id, name) OVERRIDING SYSTEM VALUE VALUES (2, 'ROLE_MODERATOR');
|
||||
INSERT INTO roles (id, name) OVERRIDING SYSTEM VALUE VALUES (3, 'ROLE_ADMIN');
|
||||
|
||||
|
||||
INSERT INTO users (id, email, password, username)
|
||||
OVERRIDING SYSTEM VALUE
|
||||
VALUES (1, 'liosha84@gmail.com', '$2a$10$qyoKXYSukha6XCjorTzoweF4Os1pwmwyzbaSsb3RCVB0LK6WLQKPC', 'Admin');
|
||||
INSERT INTO users (id, email, password, username)
|
||||
OVERRIDING SYSTEM VALUE
|
||||
VALUES (2, 'Moderator@gmail.com', '$2a$10$zLo5th8Xbfq.MM7y/dCRQu3Ud7HHyAwm.7.yS08ytJtkHMKrbOJlu', 'Moderator');
|
||||
INSERT INTO users (id, email, password, username)
|
||||
OVERRIDING SYSTEM VALUE
|
||||
VALUES (3, 'user@gmail.com', '$2a$10$2EcwYffteBF3GhVaf5qPB.I7XiHepDEauU5D4fx9fpBXMTZI/QnnC', 'User');
|
||||
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id) OVERRIDING SYSTEM VALUE VALUES (3, 1);
|
||||
INSERT INTO user_roles (user_id, role_id) OVERRIDING SYSTEM VALUE VALUES (1, 3);
|
||||
INSERT INTO user_roles (user_id, role_id) OVERRIDING SYSTEM VALUE VALUES (2, 2);
|
||||
Reference in New Issue
Block a user