From 5ee52f886ffa6b13f831954cc28c01bad7117759 Mon Sep 17 00:00:00 2001 From: Artemiy Vereshchinskiy Date: Mon, 25 May 2026 00:13:40 +0700 Subject: [PATCH] SQL migrations sync fix --- .changeset/big-timers-crash.md | 10 ++++++++++ .../sql/migrations/pg/0001_oauth_refresh_tokens.sql | 10 ++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 .changeset/big-timers-crash.md diff --git a/.changeset/big-timers-crash.md b/.changeset/big-timers-crash.md new file mode 100644 index 00000000..e916cfc7 --- /dev/null +++ b/.changeset/big-timers-crash.md @@ -0,0 +1,10 @@ +--- +'rushdb-core': patch +'rushdb-docs': patch +'@rushdb/javascript-sdk': patch +'@rushdb/mcp-server': patch +'@rushdb/skills': patch +'rushdb-dashboard': patch +--- + +SQL migrations sync fix diff --git a/platform/core/src/database/sql/migrations/pg/0001_oauth_refresh_tokens.sql b/platform/core/src/database/sql/migrations/pg/0001_oauth_refresh_tokens.sql index 5e4bf1eb..ecfd211e 100644 --- a/platform/core/src/database/sql/migrations/pg/0001_oauth_refresh_tokens.sql +++ b/platform/core/src/database/sql/migrations/pg/0001_oauth_refresh_tokens.sql @@ -1,4 +1,4 @@ -CREATE TABLE "oauth_refresh_tokens" ( +CREATE TABLE IF NOT EXISTS "oauth_refresh_tokens" ( "id" text PRIMARY KEY NOT NULL, "consent_id" text NOT NULL, "client_id" text NOT NULL, @@ -9,4 +9,10 @@ CREATE TABLE "oauth_refresh_tokens" ( "expires_at" text NOT NULL ); --> statement-breakpoint -ALTER TABLE "oauth_refresh_tokens" ADD CONSTRAINT "oauth_refresh_tokens_consent_id_oauth_consents_id_fk" FOREIGN KEY ("consent_id") REFERENCES "public"."oauth_consents"("id") ON DELETE cascade ON UPDATE no action; +DO $$ BEGIN + IF NOT EXISTS ( + SELECT 1 FROM pg_constraint WHERE conname = 'oauth_refresh_tokens_consent_id_oauth_consents_id_fk' + ) THEN + ALTER TABLE "oauth_refresh_tokens" ADD CONSTRAINT "oauth_refresh_tokens_consent_id_oauth_consents_id_fk" FOREIGN KEY ("consent_id") REFERENCES "public"."oauth_consents"("id") ON DELETE cascade ON UPDATE no action; + END IF; +END $$;