feat: Introduce knex for database migrations

- Adds knex.js to manage database schema changes systematically.
- Creates an initial migration file based on `hyungi_schema_v2.sql` to represent the current database state.
- Adds npm scripts (`db:migrate`, `db:rollback`, etc.) for easy execution of migration tasks.
- Archives legacy SQL files and old migration scripts into the `db_archive/` directory to prevent confusion and clean up the project structure.
This commit is contained in:
Hyungi Ahn
2025-12-19 09:43:09 +09:00
parent 9206672b63
commit b67362a733
28 changed files with 5665 additions and 9 deletions

View File

@@ -4,7 +4,18 @@
"main": "index.js",
"scripts": {
"start": "pm2-runtime start ecosystem.config.js --env production",
"dev": "pm2-runtime start ecosystem.config.js --env development"
"dev": "pm2-runtime start ecosystem.config.js --env development",
"test": "jest",
"test:watch": "jest --watch",
"test:coverage": "jest --coverage",
"test:unit": "jest tests/unit",
"test:integration": "jest tests/integration",
"test:verbose": "jest --verbose",
"db:migrate": "knex migrate:latest --knexfile knexfile.js",
"db:migrate:make": "knex migrate:make --knexfile knexfile.js",
"db:rollback": "knex migrate:rollback --knexfile knexfile.js",
"db:seed": "knex seed:run --knexfile knexfile.js",
"db:seed:make": "knex seed:make --knexfile knexfile.js"
},
"dependencies": {
"@simplewebauthn/server": "^13.1.1",
@@ -19,6 +30,7 @@
"express-validator": "^7.2.1",
"helmet": "^7.2.0",
"jsonwebtoken": "^9.0.0",
"knex": "^3.1.0",
"multer": "^1.4.5-lts.1",
"mysql2": "^3.14.1",
"node-cache": "^5.1.2",
@@ -28,5 +40,10 @@
"sqlite3": "^5.1.6",
"swagger-jsdoc": "^6.2.8",
"swagger-ui-express": "^5.0.1"
},
"devDependencies": {
"@types/jest": "^29.5.12",
"jest": "^29.7.0",
"supertest": "^7.0.0"
}
}