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

@@ -0,0 +1,57 @@
require('dotenv').config();
module.exports = {
development: {
client: 'mysql2',
connection: {
host: process.env.DB_HOST,
port: process.env.DB_PORT,
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME,
socketPath: process.env.DB_SOCKET
},
migrations: {
directory: './db/migrations'
},
seeds: {
directory: './db/seeds'
}
},
staging: {
client: 'mysql2',
connection: {
host: process.env.DB_HOST,
port: process.env.DB_PORT,
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME,
socketPath: process.env.DB_SOCKET
},
migrations: {
directory: './db/migrations'
},
seeds: {
directory: './db/seeds'
}
},
production: {
client: 'mysql2',
connection: {
host: process.env.DB_HOST,
port: process.env.DB_PORT,
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME,
socketPath: process.env.DB_SOCKET
},
migrations: {
directory: './db/migrations'
},
seeds: {
directory: './db/seeds'
}
}
};