Skip to content

feat: migrate DB migrations from Hibernate ddl-auto to Liquibase - #6

Merged
cabrasky merged 1 commit into
mainfrom
feature/liquibase-migrations
Jul 1, 2026
Merged

cabrasky merged 1 commit into
mainfrom
feature/liquibase-migrations

Conversation

@cabrasky

@cabrasky cabrasky commented Jul 1, 2026

Copy link
Copy Markdown
Owner

Descripcion

Migracion del esquema de base de datos de Hibernate ddl-auto=update a Liquibase.

Cambios

Archivo Accion
pom.xml Añadida dependencia liquibase-core
application.properties ddl-auto=validate + config Liquibase
db/changelog/db.changelog-master.xml Nuevo — changelog master
db/changelog/001-initial-schema.xml Nuevo — schema completo
.env.example Añadido comentario Liquibase

Schema Liquibase (13 tablas + 7 join tables)

CambioSet 001 — Tablas base:

  • language, translation, app_privilege, app_user, app_group
  • Join: user_group, group_privilege, group_translation
  • allergen, join: allergen_translation
  • category (self-referencing FK), join: category_translation
  • menu_item, joins: menu_item_translation, menu_item_allergen

CambioSet 002 — Ordenes y servicios:

  • app_table, service, app_order, order_items, order_item_quantity
  • FK circular app_table.last_service → service.id

CambioSet 003 — Indices:

  • idx_service_table_id, idx_app_order_service_id, idx_oiq_order_id

Comportamiento

  • spring.jpa.hibernate.ddl-auto=validate — Hibernate solo valida que las entidades coincidan con la BD
  • Liquibase aplica el changelog al arrancar (crea tablas si no existen, inserta fila en DATABASECHANGELOG)
  • El seed data (idiomas, alergenos, menu) sigue gestionado por DataLoader.java desde defaultData.json

- Add liquibase-core dependency to pom.xml
- Create db.changelog-master.xml with changelog master file
- Create 001-initial-schema.xml with all 13 tables + 7 join tables + indexes
- Set spring.jpa.hibernate.ddl-auto=validate (Liquibase manages schema)
- Configure spring.liquibase.change-log and enabled properties
- Update .env.example with Liquibase comment

Schema includes: app_user, app_group, app_privilege, menu_item, category,
allergen, language, translation, app_order, order_items, order_item_quantity,
app_table, service, plus all M:N join tables and foreign keys.
Copilot AI review requested due to automatic review settings July 1, 2026 08:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates the backend database schema management from Hibernate ddl-auto=update to Liquibase, so schema creation/evolution is driven by versioned changelogs while Hibernate switches to ddl-auto=validate.

Changes:

  • Added Liquibase dependency and enabled Liquibase on startup via Spring Boot properties.
  • Introduced a Liquibase master changelog and an initial schema changelog covering core domain tables + order/service tables and indexes.
  • Updated .env.example with an (optional) Liquibase contexts hint.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/backend/src/main/resources/db/changelog/db.changelog-master.xml Adds the Liquibase master changelog and includes the initial schema changelog.
packages/backend/src/main/resources/db/changelog/001-initial-schema.xml Defines initial DB schema (tables, FKs, join tables) plus indexes.
packages/backend/src/main/resources/application.properties Switches Hibernate to validate and configures Liquibase changelog execution.
packages/backend/pom.xml Adds liquibase-core dependency (Spring Boot managed version).
.env.example Documents optional Liquibase contexts env var.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.27.xsd">

<include file="db/changelog/001-initial-schema.xml"/>
Comment on lines +13 to +14
spring.liquibase.change-log=classpath:db/changelog/db.changelog-master.xml
spring.liquibase.enabled=true
Comment on lines +8 to +10
<changeSet id="001-base-tables" author="table2taste">
<comment>Core tables: language, translation, privilege, user, group, table, allergen, category, menu_item</comment>

Comment on lines +268 to +276
<createTable tableName="service">
<column name="id" type="BIGINT" autoIncrement="true">
<constraints primaryKey="true" nullable="false"/>
</column>
<column name="table_id" type="BIGINT"/>
<column name="open_timestamp" type="TIMESTAMP"/>
<column name="close_timestamp" type="TIMESTAMP"/>
<column name="is_open" type="BOOLEAN" defaultValueBoolean="true"/>
</createTable>
@cabrasky
cabrasky merged commit ccb0446 into main Jul 1, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants