-- Add migration script here

CREATE TABLE table_validation_rules (
    id BIGSERIAL PRIMARY KEY,
    table_def_id BIGINT NOT NULL
        REFERENCES table_definitions(id)
        ON DELETE CASCADE,
    data_key TEXT NOT NULL,
    config JSONB NOT NULL,
    updated_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP,
    UNIQUE (table_def_id, data_key)
);

CREATE INDEX idx_table_validation_rules_table
    ON table_validation_rules (table_def_id);
