-- 標準報酬月額表テーブル
CREATE TABLE IF NOT EXISTS standard_remuneration (
    id SERIAL PRIMARY KEY,
    rate_year INTEGER NOT NULL,
    prefecture VARCHAR(50) NOT NULL,
    grade VARCHAR(20) NOT NULL,
    monthly_amount DECIMAL(12, 2) NOT NULL,
    salary_from DECIMAL(12, 2) NOT NULL,
    salary_to DECIMAL(12, 2),
    health_insurance_no_care DECIMAL(12, 2) NOT NULL,
    health_insurance_with_care DECIMAL(12, 2) NOT NULL,
    pension_insurance DECIMAL(12, 2) NOT NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    UNIQUE(rate_year, prefecture, grade)
);

-- インデックス作成
CREATE INDEX IF NOT EXISTS idx_standard_remuneration_year_pref 
    ON standard_remuneration(rate_year, prefecture);
CREATE INDEX IF NOT EXISTS idx_standard_remuneration_salary 
    ON standard_remuneration(rate_year, prefecture, salary_from, salary_to);

COMMENT ON TABLE standard_remuneration IS '健康保険・厚生年金保険の標準報酬月額表';
COMMENT ON COLUMN standard_remuneration.rate_year IS '適用年度';
COMMENT ON COLUMN standard_remuneration.prefecture IS '都道府県名';
COMMENT ON COLUMN standard_remuneration.grade IS '等級';
COMMENT ON COLUMN standard_remuneration.monthly_amount IS '標準報酬月額';
COMMENT ON COLUMN standard_remuneration.salary_from IS '報酬月額（下限）';
COMMENT ON COLUMN standard_remuneration.salary_to IS '報酬月額（上限、最高等級の場合はNULL）';
COMMENT ON COLUMN standard_remuneration.health_insurance_no_care IS '健康保険料（介護保険なし）';
COMMENT ON COLUMN standard_remuneration.health_insurance_with_care IS '健康保険料（介護保険あり）';
COMMENT ON COLUMN standard_remuneration.pension_insurance IS '厚生年金保険料';
