Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in
  • Labrador Labrador
  • Subgroup information
    • Subgroup information
    • Activity
    • Labels
    • Members
  • Epics 8
    • Epics 8
    • List
    • Boards
    • Roadmap
  • Issues 313
    • Issues 313
    • List
    • Boards
    • Milestones
    • Iterations
  • Merge requests 26
    • Merge requests 26
  • Security and Compliance
    • Security and Compliance
    • Security dashboard
    • Vulnerability report
  • Packages and registries
    • Packages and registries
    • Package Registry
  • Analytics
    • Analytics
    • Insights
    • Issue
  • Wiki
    • Wiki
Collapse sidebar
  • EIPEIP
  • LabradorLabrador
  • Wiki
  • Migrations

Migrations · Changes

Page history
Separate contributing into multiple files authored Jul 20, 2022 by Ruben Backx's avatar Ruben Backx
Hide whitespace changes
Inline Side-by-side
Migrations.md 0 → 100644
View page @ c769754e
# Migrations
When an application is already deployed and changes to the database are necessary, a migration needs to be written. This can be done as follows. If you have never written a migration before, obtain `h2-1.3.176.jar` and `liquibase.zip` from another developer. Then add liquibase to your path. When this is done, run the development branch with the following settings:
```
spring:
jpa:
hibernate:
ddl-auto: create
datasource:
url: jdbc:h2:file:./testdb-old;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;DATABASE_TO_UPPER=false;
username: sa
password:
```
Then run your branch, but change `testdb-old` to `testdb-new`. Afterwards, you can generate a changelog with the following script:
```
PROJ_DIR=$1
RESOURCES_DIR=$PROJ_DIR/src/main/resources
liquibase \
--username=sa \
--password= \
--changeLogFile=$RESOURCES_DIR/changes.yaml \
--driver=org.h2.Driver \
--url=jdbc:h2:$PROJ_DIR/testdb-old \
--classpath=/usr/local/apps/h2/h2-1.3.176.jar \
--logLevel=info \
diffChangeLog \
--referenceUrl=jdbc:h2:$PROJ_DIR/testdb-new \
--referenceUsername=sa \
--referencePassword=
```
Finally, copy your changes from `changes.yaml` to the bottom of `migrations.yaml`. Double check whether the generated changelog makes sense. Sometimes, you might need to add default values or change column types.
Clone repository
  • Common Issues
  • General Overview
  • Guidelines
  • LabraCore
  • Labradoor
  • Librador
  • Migrations
  • Setup
  • Test Data
  • _sidebar
  • Home