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:
@@ -0,0 +1,16 @@
|
||||
-- 006_add_description_column.sql
|
||||
-- daily_work_reports 테이블에 description 컬럼 추가
|
||||
|
||||
-- description 컬럼 추가 (이미 존재하는 경우 무시)
|
||||
SET @sql = (SELECT IF(
|
||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'daily_work_reports'
|
||||
AND table_schema = 'hyungi'
|
||||
AND column_name = 'description') = 0,
|
||||
'ALTER TABLE daily_work_reports ADD COLUMN description TEXT COMMENT ''작업 설명'' AFTER work_hours',
|
||||
'SELECT ''description column already exists'' as message'
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @sql;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
Reference in New Issue
Block a user