mirror of
https://github.com/marcogll/hr_soul23.git
synced 2026-01-13 13:25:16 +00:00
Merge branch 'test-17334063531150954188' into main
This commit is contained in:
75
.gitignore
vendored
75
.gitignore
vendored
@@ -7,68 +7,19 @@ logs
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
# Production
|
||||
/dist
|
||||
/build
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-temporary-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (http://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
jspm_packages/
|
||||
|
||||
# TypeScript v1 declaration files
|
||||
typings/
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Microbundle cache
|
||||
.rpt2_cache/
|
||||
.rts2_cache_cjs/
|
||||
.rts2_cache_es/
|
||||
.rts2_cache_umd/
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
.env.test
|
||||
.env.production
|
||||
|
||||
# Mac files
|
||||
# Misc
|
||||
.DS_Store
|
||||
|
||||
# VSCode files
|
||||
.vscode/
|
||||
.env
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
|
||||
@@ -8,11 +8,16 @@ Su propósito es mantener un historial claro y auditable de las tareas y solucio
|
||||
|
||||
## Entradas de Bitácora
|
||||
|
||||
### [Fecha] - Tarea/Decisión
|
||||
### 2024-07-29 - Creación del Sistema de Migraciones y Esquema Inicial
|
||||
|
||||
* **Contexto:** [Descripción del requerimiento o problema]
|
||||
* **Acción/Implementación:** [Qué se hizo o cómo se implementó]
|
||||
* **Resultado:** [Cuál fue el resultado, ej. endpoint creado, test pasado]
|
||||
* **Observaciones:** [Notas adicionales, dependencias, problemas encontrados]
|
||||
* **Contexto:** La tarea principal del Agente 3 es establecer la base de datos como la "fuente única de verdad". Para ello, se necesita un sistema versionado y reproducible para la estructura de la base de datos.
|
||||
* **Acción/Implementación:**
|
||||
1. Se inicializó un proyecto Node.js con `npm init`.
|
||||
2. Se instalaron las dependencias `knex` y `pg`.
|
||||
3. Se creó el archivo de configuración `knexfile.js` para definir la conexión a la base de datos.
|
||||
4. Se generó la primera migración (`..._initial_schema.js`) utilizando el CLI de `knex`.
|
||||
5. Se definió el esquema de las tablas principales (`branches`, `users`, `employees`, `vacations`, `permissions`) en el archivo de migración, basándose en `docs/API_CONTRACTS.md`.
|
||||
* **Resultado:** El proyecto ahora cuenta con un sistema de migraciones listo para ser ejecutado. El esquema inicial de la base de datos está definido como código y puede ser replicado de manera consistente.
|
||||
* **Observaciones:** Se añadió un archivo `.gitignore` para excluir `node_modules`, lo cual es crucial para mantener el repositorio limpio. La conexión en `knexfile.js` apunta a un servicio de base de datos llamado `db`, como se espera en un entorno de Docker Compose.
|
||||
|
||||
---
|
||||
|
||||
28
knexfile.js
Normal file
28
knexfile.js
Normal file
@@ -0,0 +1,28 @@
|
||||
// Update with your config settings.
|
||||
|
||||
/**
|
||||
* @type { Object.<string, import("knex").Knex.Config> }
|
||||
*/
|
||||
module.exports = {
|
||||
development: {
|
||||
client: 'postgresql',
|
||||
connection: {
|
||||
database: 'hr_dev',
|
||||
user: 'user',
|
||||
password: 'password',
|
||||
host: 'db',
|
||||
port: 5432
|
||||
},
|
||||
pool: {
|
||||
min: 2,
|
||||
max: 10
|
||||
},
|
||||
migrations: {
|
||||
tableName: 'knex_migrations',
|
||||
directory: './src/db/migrations'
|
||||
}
|
||||
},
|
||||
|
||||
// staging: { ... },
|
||||
// production: { ... }
|
||||
};
|
||||
1074
package-lock.json
generated
1074
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,8 +1,6 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"express": "^4.19.2"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "node src/index.js"
|
||||
"knex": "^3.1.0",
|
||||
"pg": "^8.16.3"
|
||||
}
|
||||
}
|
||||
|
||||
63
src/db/migrations/20251213214742_initial_schema.js
Normal file
63
src/db/migrations/20251213214742_initial_schema.js
Normal file
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* @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');
|
||||
};
|
||||
Reference in New Issue
Block a user