Add initial database migration script to create tables and seed data.
Add Dockerfile and docker-compose.yml for containerizing the Spring Boot application with PostgreSQL
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
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"))
|
||||
);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.jambotronGroup.jambotron;
|
||||
package com.jambotronGroup.jambotron.configuretions;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.jambotronGroup.jambotron;
|
||||
package com.jambotronGroup.jambotron.configuretions;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -9,7 +9,7 @@ import jakarta.persistence.*;
|
||||
public class Tutorial {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private long id;
|
||||
|
||||
@Column(name = "title")
|
||||
|
||||
@@ -18,7 +18,7 @@ import java.util.Set;
|
||||
})
|
||||
public class User {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private long id;
|
||||
|
||||
@Column(name = "username")
|
||||
|
||||
Reference in New Issue
Block a user