feat: add spec definition api with versioning
All checks were successful
arcad/emissary/pipeline/head This commit looks good
arcad/emissary/pipeline/pr-master This commit looks good

This commit is contained in:
2024-03-12 16:22:35 +01:00
parent 0b34b485da
commit f612721b4e
69 changed files with 1468 additions and 273 deletions

View File

@ -0,0 +1 @@
DROP TABLE spec_definitions;

View File

@ -0,0 +1,9 @@
CREATE TABLE
spec_definitions (
name TEXT NOT NULL,
version TEXT NOT NULL,
schema TEXT NOT NULL,
created_at datetime NOT NULL,
updated_at datetime NOT NULL,
UNIQUE (name, version)
);

View File

@ -0,0 +1,35 @@
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;
---

View File

@ -0,0 +1,36 @@
-- Add unique constraint on name/version to specs
ALTER TABLE specs
RENAME TO _specs;
CREATE TABLE
specs (
id INTEGER PRIMARY KEY,
agent_id INTEGER,
tenant_id TEXT,
name TEXT NOT NULL,
version 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, version) ON CONFLICT REPLACE
);
INSERT INTO
specs
SELECT
id,
agent_id,
tenant_id,
name,
"0.0.0",
revision,
data,
created_at,
updated_at
FROM
_specs;
DROP TABLE _specs;