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,45 @@
|
||||
-- hyungi 계정을 시스템 권한으로 업데이트
|
||||
-- 실행 날짜: 2025-01-XX
|
||||
|
||||
-- hyungi 계정의 role을 system으로 변경
|
||||
UPDATE Users
|
||||
SET
|
||||
role = 'system',
|
||||
access_level = 'system',
|
||||
name = '시스템 관리자',
|
||||
updated_at = NOW()
|
||||
WHERE username = 'hyungi';
|
||||
|
||||
-- 변경 결과 확인
|
||||
SELECT
|
||||
user_id,
|
||||
username,
|
||||
name,
|
||||
role,
|
||||
access_level,
|
||||
is_active,
|
||||
updated_at
|
||||
FROM Users
|
||||
WHERE username = 'hyungi';
|
||||
|
||||
-- 시스템 권한 확인을 위한 쿼리
|
||||
SELECT
|
||||
username,
|
||||
name,
|
||||
role,
|
||||
access_level,
|
||||
CASE
|
||||
WHEN role = 'system' THEN '✅ 시스템 관리자'
|
||||
WHEN role = 'admin' THEN '🔧 관리자'
|
||||
WHEN role = 'leader' THEN '👨🏫 그룹장'
|
||||
ELSE '👤 일반 사용자'
|
||||
END as permission_level
|
||||
FROM Users
|
||||
ORDER BY
|
||||
CASE role
|
||||
WHEN 'system' THEN 1
|
||||
WHEN 'admin' THEN 2
|
||||
WHEN 'leader' THEN 3
|
||||
ELSE 4
|
||||
END,
|
||||
username;
|
||||
Reference in New Issue
Block a user