Demonstrates how to add custom database tables alongside App Server tables using Liquibase migrations.
For tables with foreign keys to
SHOPWARE_SHOP, see db-shop-reference-example.
- Custom Database Tables - Create your own tables alongside App Server tables
- Liquibase Integration - Manage schema changes with user-defined migrations
- JPA Entities & Repositories - Complete Spring Data JPA integration
custom-db-migration/
├── src/main/java/com/appbackend/
│ ├── AppBackendApplication.java
│ ├── MyShopwareBackend.java
│ ├── entity/SystemMessage.java
│ └── repository/SystemMessageRepository.java
├── src/main/resources/
│ ├── application.yaml
│ └── db/changelog/
│ ├── user-changelog-master.xml
│ └── changesets/0001-add-my-table.xml
└── build.gradle
cd examples/custom-db-migration
./gradlew bootRunVerify tables were created:
sqlite3 shopware_app.db ".tables"
# Shows: DATABASECHANGELOG, DATABASECHANGELOGLOCK, SHOPWARE_SHOP, SYSTEM_MESSAGEIn application.yaml:
app-server:
database:
user-migrations: trueThis tells App Server not to create its own Liquibase bean, so you can define your own.
In src/main/resources/db/changelog/user-changelog-master.xml:
<databaseChangeLog ...>
<!-- REQUIRED: Include App Server migrations first -->
<include file="db/changelog/app-server-changelog-master.xml"/>
<!-- Your custom migrations -->
<include file="changesets/0001-add-my-table.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>Important: Always include app-server-changelog-master.xml first.
spring:
liquibase:
change-log: classpath:db/changelog/user-changelog-master.xmlAdd @EnableJpaRepositories and @EntityScan to your main class.
See AppBackendApplication.java.
- Create a new changeset:
changesets/0002-add-another-table.xml - Include it in your master changelog after the first changeset
- Never modify existing changesets - Liquibase tracks them by ID
- Number changesets sequentially - Makes tracking easier
- Add rollback instructions - Support migration reversals
| Problem | Solution |
|---|---|
| Tables not created | Verify app-server.database.user-migrations: true is set |
| SHOPWARE_SHOP missing | Ensure app-server-changelog-master.xml is included first |
| Migration runs twice | Check DATABASECHANGELOG table for duplicates |