修正
This commit is contained in:
39
backend/create_fiscal_year_locks.py
Normal file
39
backend/create_fiscal_year_locks.py
Normal file
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env python3
|
||||
"""fiscal_year_locks テーブル作成スクリプト"""
|
||||
import psycopg
|
||||
|
||||
try:
|
||||
conn = psycopg.connect('host=localhost user=postgres password=postgres dbname=accounting')
|
||||
cur = conn.cursor()
|
||||
|
||||
# テーブル作成
|
||||
cur.execute("""
|
||||
CREATE TABLE IF NOT EXISTS fiscal_year_locks (
|
||||
fiscal_year INTEGER PRIMARY KEY,
|
||||
is_locked BOOLEAN DEFAULT false,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
)
|
||||
""")
|
||||
print("✓ fiscal_year_locks テーブル作成完了")
|
||||
|
||||
# デフォルト行を挿入
|
||||
cur.execute("DELETE FROM fiscal_year_locks")
|
||||
cur.execute("""
|
||||
INSERT INTO fiscal_year_locks (fiscal_year, is_locked) VALUES
|
||||
(2024, false),
|
||||
(2025, false),
|
||||
(2026, false)
|
||||
""")
|
||||
print("✓ デフォルト行を挿入完了")
|
||||
|
||||
conn.commit()
|
||||
print("✓ コミット完了")
|
||||
|
||||
cur.close()
|
||||
conn.close()
|
||||
print("\n✅ fiscal_year_locks テーブルの準備が完了しました")
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ エラー: {e}")
|
||||
exit(1)
|
||||
Reference in New Issue
Block a user