CREATE TYPE house_type_enum AS ENUM ('open_house', 'close_house');

CREATE TABLE house_depreciation_standards (
    id BIGSERIAL PRIMARY KEY,
    name VARCHAR(100),
    effective_date DATE,
    house_type house_type_enum NOT NULL,
    day INT NOT NULL
        CHECK (day >= 0),
    depreciation_percent NUMERIC(15, 6) NOT NULL
        CHECK (depreciation_percent >= 0 AND depreciation_percent <= 100),
    created_at TIMESTAMPTZ DEFAULT NOW(),
    updated_at TIMESTAMPTZ DEFAULT NOW(),
    CONSTRAINT house_depreciation_standards_house_type_day_unique UNIQUE (house_type, day)
);

ALTER TABLE kandangs
    ADD COLUMN house_type house_type_enum;
