mirror of
https://github.com/marcogll/hr_soul23.git
synced 2026-01-13 13:25:16 +00:00
Merge pull request #8 from marcogll/jules/review-agent-work-and-fix-migrations-16782006470421669202
Review Agent Work and Fix Migrations
This commit is contained in:
@@ -1,5 +1,28 @@
|
||||
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');
|
||||
@@ -35,14 +58,6 @@ exports.up = function(knex) {
|
||||
table.text('descripcion');
|
||||
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('permisos_granulares', function(table) {
|
||||
table.increments('id').primary();
|
||||
table.integer('id_usuario').unsigned().references('id').inTable('usuarios');
|
||||
@@ -55,10 +70,12 @@ exports.up = function(knex) {
|
||||
|
||||
exports.down = function(knex) {
|
||||
return knex.schema
|
||||
.dropTable('permisos_granulares')
|
||||
.dropTable('usuarios')
|
||||
.dropTable('configuraciones')
|
||||
.dropTable('eventos')
|
||||
.dropTable('permisos')
|
||||
.dropTable('vacaciones');
|
||||
.dropTableIfExists('permisos_granulares')
|
||||
.dropTableIfExists('vacaciones')
|
||||
.dropTableIfExists('permisos')
|
||||
.dropTableIfExists('eventos')
|
||||
.dropTableIfExists('configuraciones')
|
||||
.dropTableIfExists('socias')
|
||||
.dropTableIfExists('usuarios')
|
||||
.dropTableIfExists('sucursales');
|
||||
};
|
||||
@@ -1,63 +0,0 @@
|
||||
/**
|
||||
* @param { import("knex").Knex } knex
|
||||
* @returns { Promise<void> }
|
||||
*/
|
||||
exports.up = function(knex) {
|
||||
return knex.schema
|
||||
.createTable('branches', function (table) {
|
||||
table.string('id').primary();
|
||||
table.string('name', 255).notNullable();
|
||||
table.string('address', 255);
|
||||
})
|
||||
.createTable('users', function (table) {
|
||||
table.string('id').primary();
|
||||
table.string('username', 255).notNullable().unique();
|
||||
table.string('role', 50).notNullable();
|
||||
table.jsonb('permissions');
|
||||
table.timestamps(true, true);
|
||||
})
|
||||
.createTable('employees', function (table) {
|
||||
table.string('id').primary();
|
||||
table.string('firstName', 255).notNullable();
|
||||
table.string('lastName', 255).notNullable();
|
||||
table.string('email', 255).notNullable().unique();
|
||||
table.timestamp('hireDate').notNullable();
|
||||
table.string('branchId').references('id').inTable('branches');
|
||||
table.boolean('isActive').defaultTo(true);
|
||||
table.timestamps(true, true);
|
||||
})
|
||||
.createTable('vacations', function (table) {
|
||||
table.string('id').primary();
|
||||
table.string('employeeId').notNullable().references('id').inTable('employees');
|
||||
table.date('startDate').notNullable();
|
||||
table.date('endDate').notNullable();
|
||||
table.integer('daysUsed').notNullable();
|
||||
table.string('status', 50).notNullable().defaultTo('PENDING');
|
||||
table.integer('cycleYear').notNullable();
|
||||
table.timestamp('requestedAt').defaultTo(knex.fn.now());
|
||||
table.string('approvedBy').references('id').inTable('users');
|
||||
table.timestamp('approvedAt');
|
||||
})
|
||||
.createTable('permissions', function (table) {
|
||||
table.string('id').primary();
|
||||
table.string('employeeId').notNullable().references('id').inTable('employees');
|
||||
table.date('permissionDate').notNullable();
|
||||
table.integer('hours');
|
||||
table.string('reason', 255);
|
||||
table.string('status', 50).notNullable().defaultTo('PENDING');
|
||||
table.timestamp('requestedAt').defaultTo(knex.fn.now());
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* @param { import("knex").Knex } knex
|
||||
* @returns { Promise<void> }
|
||||
*/
|
||||
exports.down = function(knex) {
|
||||
return knex.schema
|
||||
.dropTable('permissions')
|
||||
.dropTable('vacations')
|
||||
.dropTable('employees')
|
||||
.dropTable('users')
|
||||
.dropTable('branches');
|
||||
};
|
||||
@@ -1,12 +0,0 @@
|
||||
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);
|
||||
});
|
||||
};
|
||||
|
||||
exports.down = function(knex) {
|
||||
return knex.schema.dropTable('sucursales');
|
||||
};
|
||||
@@ -1,15 +0,0 @@
|
||||
exports.up = function(knex) {
|
||||
return knex.schema.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);
|
||||
});
|
||||
};
|
||||
|
||||
exports.down = function(knex) {
|
||||
return knex.schema.dropTable('socias');
|
||||
};
|
||||
Reference in New Issue
Block a user