CREATE TABLE documents (
    id BIGSERIAL PRIMARY KEY,
    documentable_type VARCHAR(50) NOT NULL,
    documentable_id BIGINT NOT NULL,
    type VARCHAR(50) NOT NULL,
    path VARCHAR(50) NOT NULL,
    name VARCHAR(50) NOT NULL,
    ext VARCHAR(50) NOT NULL,
    size NUMERIC(15, 3) NOT NULL,
    created_by BIGINT REFERENCES users (id) ON DELETE RESTRICT ON UPDATE CASCADE,
    created_at TIMESTAMPTZ DEFAULT now()
);

CREATE INDEX documents_documentable_polymorphic ON documents (documentable_type, documentable_id);
