mirror of
https://git.imnavajas.es/jjimenez/erp-imprimelibros.git
synced 2026-01-24 09:40:21 +00:00
añadido sistema de migraciones
This commit is contained in:
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