mirror of
https://git.imnavajas.es/jjimenez/erp-imprimelibros.git
synced 2026-01-24 01:30:21 +00:00
añadido sistema de migraciones
This commit is contained in:
@ -92,3 +92,13 @@ spring.jpa.properties.hibernate.jdbc.time_zone=UTC
|
||||
# PDF Templates
|
||||
imprimelibros.pdf.templates.PRESUPUESTO_presupuesto-a4=imprimelibros/pdf/presupuesto-a4
|
||||
imprimelibros.pdf.templates.FACTURA_factura-a4=imprimelibros/pdf/factura-a4
|
||||
|
||||
# Liquibase
|
||||
spring.liquibase.enabled=true
|
||||
spring.liquibase.change-log=classpath:db/changelog/master.yml
|
||||
# Si quieres especificar el schema por defecto:
|
||||
# spring.liquibase.default-schema=imprimelibros
|
||||
# Si necesitas parámetros de conexión distintos a los de Spring Data (no suele hacer falta):
|
||||
# spring.liquibase.url=jdbc:mysql://localhost:3306/imprimelibros
|
||||
# spring.liquibase.user=tu_user
|
||||
# spring.liquibase.password=tu_pass
|
||||
|
||||
1065
src/main/resources/db/changelog/changesets/0001-baseline.yml
Normal file
1065
src/main/resources/db/changelog/changesets/0001-baseline.yml
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,146 @@
|
||||
databaseChangeLog:
|
||||
- changeSet:
|
||||
id: 0002-create-pedidos
|
||||
author: jjo
|
||||
|
||||
preConditions:
|
||||
- not:
|
||||
tableExists:
|
||||
tableName: pedidos
|
||||
|
||||
changes:
|
||||
- createTable:
|
||||
tableName: pedidos
|
||||
columns:
|
||||
- column:
|
||||
name: id
|
||||
type: BIGINT AUTO_INCREMENT
|
||||
constraints:
|
||||
primaryKey: true
|
||||
primaryKeyName: pk_pedidos
|
||||
- column:
|
||||
name: presupuesto_id
|
||||
type: BIGINT
|
||||
constraints:
|
||||
nullable: false
|
||||
- column:
|
||||
name: created_by
|
||||
type: BIGINT
|
||||
constraints:
|
||||
nullable: true
|
||||
- column:
|
||||
name: updated_by
|
||||
type: BIGINT
|
||||
constraints:
|
||||
nullable: true
|
||||
- column:
|
||||
name: deleted_by
|
||||
type: BIGINT
|
||||
constraints:
|
||||
nullable: true
|
||||
- column:
|
||||
name: deleted
|
||||
type: TINYINT(1)
|
||||
defaultValueNumeric: 0
|
||||
constraints:
|
||||
nullable: false
|
||||
- column:
|
||||
name: created_at
|
||||
type: TIMESTAMP
|
||||
defaultValueComputed: CURRENT_TIMESTAMP
|
||||
constraints:
|
||||
nullable: false
|
||||
- column:
|
||||
name: updated_at
|
||||
type: TIMESTAMP
|
||||
defaultValueComputed: CURRENT_TIMESTAMP
|
||||
constraints:
|
||||
nullable: false
|
||||
- column:
|
||||
name: deleted_at
|
||||
type: TIMESTAMP
|
||||
constraints:
|
||||
nullable: true
|
||||
|
||||
# Forzamos ON UPDATE para updated_at (MySQL/MariaDB)
|
||||
- sql:
|
||||
dbms: mysql
|
||||
splitStatements: false
|
||||
sql: |
|
||||
ALTER TABLE pedidos
|
||||
MODIFY COLUMN updated_at TIMESTAMP NOT NULL
|
||||
DEFAULT CURRENT_TIMESTAMP
|
||||
ON UPDATE CURRENT_TIMESTAMP;
|
||||
|
||||
# Índices
|
||||
- createIndex:
|
||||
tableName: pedidos
|
||||
indexName: idx_pedidos_presupuesto
|
||||
columns:
|
||||
- column:
|
||||
name: presupuesto_id
|
||||
- createIndex:
|
||||
tableName: pedidos
|
||||
indexName: idx_pedidos_deleted
|
||||
columns:
|
||||
- column:
|
||||
name: deleted
|
||||
|
||||
# Claves foráneas (ajusta nombres si difieren)
|
||||
- addForeignKeyConstraint:
|
||||
baseTableName: pedidos
|
||||
baseColumnNames: presupuesto_id
|
||||
constraintName: fk_pedidos_presupuesto
|
||||
referencedTableName: presupuesto
|
||||
referencedColumnNames: id
|
||||
onDelete: RESTRICT
|
||||
onUpdate: RESTRICT
|
||||
|
||||
- addForeignKeyConstraint:
|
||||
baseTableName: pedidos
|
||||
baseColumnNames: created_by
|
||||
constraintName: fk_pedidos_created_by
|
||||
referencedTableName: users
|
||||
referencedColumnNames: id
|
||||
onDelete: SET NULL
|
||||
onUpdate: RESTRICT
|
||||
|
||||
- addForeignKeyConstraint:
|
||||
baseTableName: pedidos
|
||||
baseColumnNames: updated_by
|
||||
constraintName: fk_pedidos_updated_by
|
||||
referencedTableName: users
|
||||
referencedColumnNames: id
|
||||
onDelete: SET NULL
|
||||
onUpdate: RESTRICT
|
||||
|
||||
- addForeignKeyConstraint:
|
||||
baseTableName: pedidos
|
||||
baseColumnNames: deleted_by
|
||||
constraintName: fk_pedidos_deleted_by
|
||||
referencedTableName: users
|
||||
referencedColumnNames: id
|
||||
onDelete: SET NULL
|
||||
onUpdate: RESTRICT
|
||||
|
||||
rollback:
|
||||
- dropForeignKeyConstraint:
|
||||
baseTableName: pedidos
|
||||
constraintName: fk_pedidos_deleted_by
|
||||
- dropForeignKeyConstraint:
|
||||
baseTableName: pedidos
|
||||
constraintName: fk_pedidos_updated_by
|
||||
- dropForeignKeyConstraint:
|
||||
baseTableName: pedidos
|
||||
constraintName: fk_pedidos_created_by
|
||||
- dropForeignKeyConstraint:
|
||||
baseTableName: pedidos
|
||||
constraintName: fk_pedidos_presupuesto
|
||||
- dropIndex:
|
||||
tableName: pedidos
|
||||
indexName: idx_pedidos_deleted
|
||||
- dropIndex:
|
||||
tableName: pedidos
|
||||
indexName: idx_pedidos_presupuesto
|
||||
- dropTable:
|
||||
tableName: pedidos
|
||||
5
src/main/resources/db/changelog/master.yml
Normal file
5
src/main/resources/db/changelog/master.yml
Normal file
@ -0,0 +1,5 @@
|
||||
databaseChangeLog:
|
||||
- include:
|
||||
file: db/changelog/changesets/0001-baseline.yml
|
||||
- include:
|
||||
file: db/changelog/changesets/0002-create-pedidos.yml
|
||||
Reference in New Issue
Block a user