40 lines
1.2 KiB
Python
40 lines
1.2 KiB
Python
#!/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)
|