ALTER TABLE specs
RENAME TO _specs;

CREATE TABLE
    specs (
        id INTEGER PRIMARY KEY,
        agent_id INTEGER,
        tenant_id TEXT,
        name TEXT NOT NULL,
        revision INTEGER DEFAULT 0,
        data TEXT,
        created_at datetime NOT NULL,
        updated_at datetime NOT NULL,
        FOREIGN KEY (tenant_id) REFERENCES tenants (id),
        FOREIGN KEY (agent_id) REFERENCES agents (id) ON DELETE CASCADE,
        UNIQUE (agent_id, name) ON CONFLICT REPLACE
    );

INSERT INTO
    specs
SELECT
    id,
    agent_id,
    tenant_id,
    name,
    revision,
    data,
    created_at,
    updated_at
FROM
    _specs;

DROP TABLE _specs;

---