Seed Data API

Seed definitions and their plans. Base path /api/db-devops, needs an active license, signed-in callers. Any role can list seeds, plan them and create a script from a plan; creating, changing and deleting seeds needs a Release Manager or admin (403 otherwise). Plans take the engine and database from the connection; a request may still send dialect, but one that does not match the connection is 400 (DIALECT_MISMATCH). Seed plans support PostgreSQL (and CockroachDB, TimescaleDB), MySQL/MariaDB and SQLite; any other engine is 400 (UNSUPPORTED_DIALECT).

Seeds

MethodEndpointDescription
GET/seedAll seed definitions by name: [{ id, name, description, schemaName, tableName, mode, keyColumns, rows, appliesToDialects, isActive, createdBy, createdAt, updatedAt }]
POST/seedCreate a seed (Release Manager or admin): { "name", "tableName", "mode", "keyColumns", "rows", "schemaName"?, "description"?, "appliesToDialects"?, "isActive"? }. mode is insert, upsert or sync; rows is an array of objects, each with a value for every key column and no two with the same key; a sync seed needs at least one row; appliesToDialects names seed engines only. Answers 201 with the seed
PUT/seed/:idReplace a seed (Release Manager or admin), with the same body and rules
DELETE/seed/:idDelete a seed (Release Manager or admin). Rows already applied to tables are not touched. Answers { success }

A seed that breaks a rule is 400 (INVALID_SEED) with every problem in the message; a name another seed already uses, ignoring case, is 409 (SEED_NAME_TAKEN).

Plans and scripts

MethodEndpointDescription
POST/seed/planCompare { "seedId", "connectionId" } with the table on the connection. Answers { inserts, updates, changes, deletes, sql, dialect }: the rows to insert, the seed rows that change, each change as { key, columns: { column: { from, to } } }, the table rows to delete (sync only), and the script in the connection engine's language (SQL, CQL, MongoDB shell commands, Redis commands, Cypher, or Elasticsearch operations as JSON; Elasticsearch seeds must use _id as their only key column, otherwise 400 INVALID_SEED)
POST/seed/:id/scriptPlan the seed against { "connectionId" } and save the SQL as a migration script for that connection, waiting for approval (any role that can create scripts). Answers 201 with { scriptId, name, approvalStatus, counts }; a table that already matches is 409 (SEED_NOTHING_TO_DO)

Values are compared by meaning: JSON by content, dates by day, numbers by value, booleans also against 1 and 0. Missing rows are plain INSERTs and changed rows an UPDATE of only the changed columns, so the table needs no unique key on the key columns.

Errors

Errors answer { "error": "...", "code": "..." }.