feat: 初始化高校人事请假考勤技能 (process-leave-attendance-default)
All checks were successful
技能自动化发布 / release (push) Successful in 15s
All checks were successful
技能自动化发布 / release (push) Successful in 15s
基于 skill-template 脚手架开发,包含: - 5 张业务表(教职工、请假政策、考勤日历、请假记录、假期余额) - 请假核算引擎(扣薪计算、审批层级判定、年假抵扣) - CLI 入口(import-employees / calculate-leave / render-html) - HTML 审批与扣薪报告生成 - 示例数据与完整测试套件(295 tests passed)
This commit is contained in:
54
scripts/db/connection.py
Normal file
54
scripts/db/connection.py
Normal file
@@ -0,0 +1,54 @@
|
||||
"""SQLite 连接与请假考勤业务表幂等初始化。"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import sqlite3
|
||||
|
||||
from db.display_metadata import init_display_metadata
|
||||
from db.leave_display_metadata import seed_leave_display_metadata
|
||||
from db.schema import BUSINESS_TABLES, TABLE_DDL
|
||||
from db.timestamp_columns import init_updated_at_trigger
|
||||
from util.runtime_paths import get_db_path
|
||||
|
||||
|
||||
def get_conn() -> sqlite3.Connection:
|
||||
return sqlite3.connect(get_db_path())
|
||||
|
||||
|
||||
def init_db() -> None:
|
||||
conn = get_conn()
|
||||
try:
|
||||
cur = conn.cursor()
|
||||
for table_name, ddl in TABLE_DDL:
|
||||
cur.execute(ddl)
|
||||
init_updated_at_trigger(cur, table_name)
|
||||
cur.execute(
|
||||
"""
|
||||
CREATE INDEX IF NOT EXISTS idx_leave_requests_employee
|
||||
ON leave_requests(employee_id, status)
|
||||
"""
|
||||
)
|
||||
cur.execute(
|
||||
"""
|
||||
CREATE INDEX IF NOT EXISTS idx_leave_balances_employee
|
||||
ON leave_balances(employee_id, balance_type)
|
||||
"""
|
||||
)
|
||||
cur.execute(
|
||||
"""
|
||||
CREATE INDEX IF NOT EXISTS idx_leave_policies_type
|
||||
ON leave_policies(leave_type)
|
||||
"""
|
||||
)
|
||||
cur.execute(
|
||||
"""
|
||||
CREATE INDEX IF NOT EXISTS idx_attendance_holidays_date
|
||||
ON attendance_holidays(holiday_date)
|
||||
"""
|
||||
)
|
||||
init_display_metadata(cur)
|
||||
seed_leave_display_metadata(cur)
|
||||
_ = BUSINESS_TABLES
|
||||
conn.commit()
|
||||
finally:
|
||||
conn.close()
|
||||
Reference in New Issue
Block a user