Skip to content
Permalink
Browse files

Apply database migration. Remove generating database schema with Hibe…

…rnate. Remove saving DDL script into a file. Update README.
  • Loading branch information
little-pinecone committed Mar 11, 2020
1 parent 84a88ff commit 7054d3618811346871ba97ad153f7f185d695319
Showing with 14 additions and 8 deletions.
  1. +4 −3 README.md
  2. +4 −0 pom.xml
  3. +0 −5 src/main/resources/application-dev.properties
  4. +6 −0 src/main/resources/db/migration/V1_2020_03_11.sql
@@ -8,20 +8,21 @@ It can be built into a single jar file using Maven.
If you want to build a project like this check out the following articles:
* [Set up a PostgreSQL database with Docker](https://keepgrowing.in/tools/set-up-a-postgresql-database-with-docker/)
* [Add a PostgreSQL database to your Spring Boot project](https://keepgrowing.in/java/springboot/add-a-postgresql-database-to-your-spring-boot-project/)
* [Add Flyway migrations to your Spring Boot project](https://keepgrowing.in/java/springboot/add-flyway-migrations-to-your-spring-boot-project/)

## Overview and technical features

* One endpoint enabling saving baked goods data.
* One endpoint enabling saving data of some baked goods (flavour).
* PostgreSQL database run from a Docker container.
* Hibernate DDL schema is saved in a file.
* Database schema is created automatically on the application startup.
* Database schema is created automatically on the application startup with a Flyway SQL-based migration.

## Getting Started

To clone this repository, execute the following in the command line:
```bash
$ git clone https://github.com/little-pinecone/spring-boot-postgres-flyway.git
```
Start the database that will be used by the app.

You can build the application with:
```bash
@@ -27,6 +27,10 @@
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
@@ -1,8 +1,3 @@
spring.jpa.properties.javax.persistence.schema-generation.database.action=create
spring.jpa.properties.javax.persistence.schema-generation.scripts.action=create
spring.jpa.properties.javax.persistence.schema-generation.scripts.create-target=schema.sql
spring.jpa.properties.hibernate.format_sql=true

spring.datasource.url=jdbc:postgresql://localhost:5432/springbootpostgresflyway
spring.datasource.username=db
spring.datasource.password=admin
@@ -0,0 +1,6 @@

create table cookie (
id bigserial not null,
flavour varchar(255),
primary key (id)
)

0 comments on commit 7054d36

Please sign in to comment.
You can’t perform that action at this time.