fix init data with flyway and fix init data with flyway in docker-compose
This commit is contained in:
+11
-1
@@ -2,6 +2,7 @@ plugins {
|
|||||||
id 'java'
|
id 'java'
|
||||||
id 'org.springframework.boot' version '3.5.0'
|
id 'org.springframework.boot' version '3.5.0'
|
||||||
id 'io.spring.dependency-management' version '1.1.7'
|
id 'io.spring.dependency-management' version '1.1.7'
|
||||||
|
id 'org.flywaydb.flyway' version '10.4.1'
|
||||||
}
|
}
|
||||||
|
|
||||||
group = 'com.jambotronGroup'
|
group = 'com.jambotronGroup'
|
||||||
@@ -21,7 +22,6 @@ dependencies {
|
|||||||
implementation 'org.springframework.boot:spring-boot-starter-web'
|
implementation 'org.springframework.boot:spring-boot-starter-web'
|
||||||
implementation 'org.springframework.boot:spring-boot-starter'
|
implementation 'org.springframework.boot:spring-boot-starter'
|
||||||
implementation 'org.projectlombok:lombok:1.18.26'
|
implementation 'org.projectlombok:lombok:1.18.26'
|
||||||
implementation 'org.projectlombok:lombok:1.18.26'
|
|
||||||
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
||||||
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
|
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
|
||||||
implementation 'jakarta.persistence:jakarta.persistence-api:3.1.0'
|
implementation 'jakarta.persistence:jakarta.persistence-api:3.1.0'
|
||||||
@@ -56,6 +56,16 @@ tasks.register('copyResources', Copy) {
|
|||||||
}
|
}
|
||||||
processResources.dependsOn(copyResources)
|
processResources.dependsOn(copyResources)
|
||||||
compileJava.dependsOn(copyResources)
|
compileJava.dependsOn(copyResources)
|
||||||
|
//bootRun.dependsOn("flywayMigrate")
|
||||||
|
|
||||||
|
//flyway {
|
||||||
|
// user='admin'
|
||||||
|
// password= 'postgrespw'
|
||||||
|
// url = 'jdbc:postgresql://localhost:5432/jambotronDB'
|
||||||
|
// driver = 'org.postgresql.Driver'
|
||||||
|
// baselineOnMigrate = true
|
||||||
|
// locations = ['filesystem:src/main/resources/db.migration/']
|
||||||
|
//}
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
main {
|
main {
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<h2>Comments</h2>
|
||||||
|
<p class="comment">
|
||||||
|
Building for the web is fantastic!
|
||||||
|
</p>
|
||||||
|
<p class="comment">
|
||||||
|
The new template syntax is great
|
||||||
|
</p>
|
||||||
|
<p class="comment">
|
||||||
|
I agree with the other comments!
|
||||||
|
</p>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
.comment {
|
||||||
|
padding: 15px;
|
||||||
|
margin-left: 30px;
|
||||||
|
background-color: paleturquoise;
|
||||||
|
border-radius: 20px;
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { ArticleComments } from './article-comments';
|
||||||
|
|
||||||
|
describe('ArticleComments', () => {
|
||||||
|
let component: ArticleComments;
|
||||||
|
let fixture: ComponentFixture<ArticleComments>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
imports: [ArticleComments]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
|
||||||
|
fixture = TestBed.createComponent(ArticleComments);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import { Component } from '@angular/core';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-article-comments',
|
||||||
|
imports: [],
|
||||||
|
templateUrl: './article-comments.html',
|
||||||
|
styleUrl: './article-comments.scss'
|
||||||
|
})
|
||||||
|
export class ArticleComments {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -13,11 +13,12 @@ services:
|
|||||||
SPRING_DATASOURCE_URL: jdbc:postgresql://postgres_jambotron:5432/jambotronDB
|
SPRING_DATASOURCE_URL: jdbc:postgresql://postgres_jambotron:5432/jambotronDB
|
||||||
SPRING_DATASOURCE_USERNAME: admin
|
SPRING_DATASOURCE_USERNAME: admin
|
||||||
SPRING_DATASOURCE_PASSWORD: postgrespw
|
SPRING_DATASOURCE_PASSWORD: postgrespw
|
||||||
SPRING_FLYWAY_LOCATIONS: classpath:db.migration
|
SPRING_FLYWAY_BASELINE-ON-MIGRATE: true
|
||||||
FLYWAY_USER: admin
|
SPRING_FLYWAY_VALIDATE-ON-MIGRATE: true
|
||||||
FLYWAY_PASSWORD: postgrespw
|
|
||||||
FLYWAY_SCHEMAS: jambotronDB
|
SPRING_FLYWAY_USER: admin
|
||||||
FLYWAY_URL: jdbc:postgresql://postgres_jambotron:5432/jambotronDB
|
SPRING_FLYWAY_PASSWORD: postgrespw
|
||||||
|
SPRING_FLYWAY_URL: jdbc:postgresql://postgres_jambotron:5432/jambotronDB
|
||||||
|
|
||||||
# SPRING_DATASOURCE_PASSWORD: /run/secrets/db_password
|
# SPRING_DATASOURCE_PASSWORD: /run/secrets/db_password
|
||||||
# secrets:
|
# secrets:
|
||||||
|
|||||||
@@ -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.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
|
spring.jpa.properties.hibernate.dialect= org.hibernate.dialect.PostgreSQLDialect
|
||||||
|
|
||||||
# Hibernate ddl auto (create, create-drop, validate, update)
|
# 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 Properties
|
||||||
app.jwtSecret= ======================spring=back====================
|
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.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
|
spring.flyway.user=admin
|
||||||
flyway.password=postgrespw
|
spring.flyway.password=postgrespw
|
||||||
flyway.schemas=jambotronDB
|
spring.flyway.url=jdbc:postgresql://localhost:5432/jambotronDB
|
||||||
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);
|
||||||
@@ -3,11 +3,11 @@ package com.jambotronGroup.jambotron;
|
|||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
@SpringBootTest
|
|
||||||
class JambotronApplicationTests {
|
class JambotronApplicationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void contextLoads() {
|
void contextLoads() {
|
||||||
}
|
// Test will pass if the application context loads successfully
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user