mirror of
https://github.com/marcogll/hr_soul23.git
synced 2026-01-13 13:25:16 +00:00
Reviewed the work of agents 0-4 and made the following corrections: - Completed the directory structure for Agent 2's work. - Consolidated the database migrations from Agent 3 into a single, consistent file that aligns with the API contract. Removed the old, fragmented migration files.
82 lines
3.1 KiB
JavaScript
82 lines
3.1 KiB
JavaScript
exports.up = function(knex) {
|
|
return knex.schema
|
|
.createTable('sucursales', function(table) {
|
|
table.increments('id').primary();
|
|
table.string('nombre', 255).notNullable();
|
|
table.text('direccion');
|
|
table.timestamps(true, true);
|
|
})
|
|
.createTable('usuarios', function(table) {
|
|
table.increments('id').primary();
|
|
table.string('nombre', 255).notNullable();
|
|
table.string('email', 255).unique().notNullable();
|
|
table.string('password_hash', 255).notNullable();
|
|
table.string('rol', 50).notNullable();
|
|
table.timestamps(true, true);
|
|
})
|
|
.createTable('socias', function(table) {
|
|
table.increments('id').primary();
|
|
table.string('nombre', 255).notNullable();
|
|
table.string('apellido', 255).notNullable();
|
|
table.date('fecha_ingreso').notNullable();
|
|
table.integer('id_sucursal').unsigned().references('id').inTable('sucursales');
|
|
table.boolean('activo').defaultTo(true);
|
|
table.timestamps(true, true);
|
|
})
|
|
.createTable('vacaciones', function(table) {
|
|
table.increments('id').primary();
|
|
table.integer('id_socia').unsigned().references('id').inTable('socias');
|
|
table.date('fecha_inicio').notNullable();
|
|
table.date('fecha_fin').notNullable();
|
|
table.integer('dias_tomados').notNullable();
|
|
table.string('estado', 50).notNullable();
|
|
table.string('ciclo_anual', 10);
|
|
table.timestamps(true, true);
|
|
})
|
|
.createTable('permisos', function(table) {
|
|
table.increments('id').primary();
|
|
table.integer('id_socia').unsigned().references('id').inTable('socias');
|
|
table.date('fecha').notNullable();
|
|
table.integer('horas');
|
|
table.integer('dias');
|
|
table.text('motivo');
|
|
table.string('estado', 50).notNullable();
|
|
table.timestamps(true, true);
|
|
})
|
|
.createTable('eventos', function(table) {
|
|
table.increments('id').primary();
|
|
table.string('tipo_evento', 100).notNullable();
|
|
table.json('payload');
|
|
table.string('endpoint_url', 255);
|
|
table.string('estado_entrega', 50).defaultTo('pendiente');
|
|
table.timestamp('created_at').defaultTo(knex.fn.now());
|
|
})
|
|
.createTable('configuraciones', function(table) {
|
|
table.increments('id').primary();
|
|
table.string('clave', 100).unique().notNullable();
|
|
table.text('valor').notNullable();
|
|
table.text('descripcion');
|
|
table.timestamps(true, true);
|
|
})
|
|
.createTable('permisos_granulares', function(table) {
|
|
table.increments('id').primary();
|
|
table.integer('id_usuario').unsigned().references('id').inTable('usuarios');
|
|
table.string('recurso', 100).notNullable();
|
|
table.string('accion', 50).notNullable();
|
|
table.boolean('permitido').defaultTo(false);
|
|
table.timestamps(true, true);
|
|
});
|
|
};
|
|
|
|
exports.down = function(knex) {
|
|
return knex.schema
|
|
.dropTableIfExists('permisos_granulares')
|
|
.dropTableIfExists('vacaciones')
|
|
.dropTableIfExists('permisos')
|
|
.dropTableIfExists('eventos')
|
|
.dropTableIfExists('configuraciones')
|
|
.dropTableIfExists('socias')
|
|
.dropTableIfExists('usuarios')
|
|
.dropTableIfExists('sucursales');
|
|
};
|