๐Ÿ“ฆ darrachequesne / spring-samples

๐Ÿ“„ README.md ยท 38 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Spring sample - schema versioning

It seems you shouldn't use `hibernate.hbm2ddl.auto: update` to handle your schema migrations (see http://stackoverflow.com/questions/221379/hibernate-hbm2ddl-auto-update-in-production).

Yet this feature is **really** handy in development. Soooo, your (main) options are:

- [Liquibase](http://www.liquibase.org/)
- [Flyway](https://flywaydb.org/)
- ...
- this repository? :innocent:

##ย How to

`docker-compose up -d` will create a MariaDB container

`mvn test` will run the unit tests, which will *miserably* fail if your schema (located in /src/main/resources/sql) do not match your @Entity mappings 

**BUT** Hibernate will kindly tell you what script to run to solve them :heart_eyes:

## Structure

    โ”œโ”€โ”€ src/main/java
    โ”‚   โ”œโ”€โ”€ AbstractEntity.java
    โ”‚   โ”œโ”€โ”€ Project.java
    โ”‚   โ””โ”€โ”€ Task.java
    โ”œโ”€โ”€ src/main/resources
    โ”‚   โ”œโ”€โ”€ schema_v0_to_v1.sql
    โ”‚   โ”œโ”€โ”€ schema_v0.sql
    โ”‚   โ”œโ”€โ”€ schema_v1_to_v2.sql
    โ”‚   โ”œโ”€โ”€ schema_v1.sql
    โ”‚   โ””โ”€โ”€ schema_v2.sql
    โ”œโ”€โ”€ src/test/java
    โ”‚   โ”œโ”€โ”€ ConfigTest.java
    โ”‚   โ””โ”€โ”€ DatabaseTest.java
    โ”œโ”€โ”€ docker-compose.yml
    โ””โ”€โ”€ pom.xml