From 22b57b7a7417a0f0a74d3cc2a67b4f818f946bc2 Mon Sep 17 00:00:00 2001 From: Scott Wilson Date: Mon, 3 Feb 2025 19:40:00 -0800 Subject: [PATCH] chore: add migration file --- ...ions-and-secret-syncs-unique-constraint.ts | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 backend/src/db/migrations/20250204025010_app-connections-and-secret-syncs-unique-constraint.ts diff --git a/backend/src/db/migrations/20250204025010_app-connections-and-secret-syncs-unique-constraint.ts b/backend/src/db/migrations/20250204025010_app-connections-and-secret-syncs-unique-constraint.ts new file mode 100644 index 000000000..348694ae7 --- /dev/null +++ b/backend/src/db/migrations/20250204025010_app-connections-and-secret-syncs-unique-constraint.ts @@ -0,0 +1,23 @@ +import { Knex } from "knex"; + +import { TableName } from "@app/db/schemas"; + +export async function up(knex: Knex): Promise { + await knex.schema.alterTable(TableName.AppConnection, (t) => { + t.unique(["orgId", "name"]); + }); + + await knex.schema.alterTable(TableName.SecretSync, (t) => { + t.unique(["projectId", "name"]); + }); +} + +export async function down(knex: Knex): Promise { + await knex.schema.alterTable(TableName.AppConnection, (t) => { + t.dropUnique(["orgId", "name"]); + }); + + await knex.schema.alterTable(TableName.SecretSync, (t) => { + t.dropUnique(["projectId", "name"]); + }); +}