From d6b1c4e3c9fab601697a583219650c43b8140aac Mon Sep 17 00:00:00 2001 From: Juanma Hidalgo Date: Thu, 11 Apr 2024 15:57:38 +0200 Subject: [PATCH] feat: add IF NOT EXISTS to remote server migration --- src/migrations/1712569914536_fdw-setup.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/migrations/1712569914536_fdw-setup.ts b/src/migrations/1712569914536_fdw-setup.ts index adf0a0c..0a0c45a 100644 --- a/src/migrations/1712569914536_fdw-setup.ts +++ b/src/migrations/1712569914536_fdw-setup.ts @@ -13,15 +13,15 @@ export async function up(pgm: MigrationBuilder): Promise { pgm.sql('CREATE EXTENSION IF NOT EXISTS postgres_fdw;') pgm.sql(` - CREATE SERVER builder_server + CREATE SERVER IF NOT EXISTS builder_server FOREIGN DATA WRAPPER postgres_fdw OPTIONS (host '${builderServerDBHost}', port '${builderServerDBPort}', dbname 'builder'); `) - pgm.sql(`CREATE USER MAPPING FOR ${marketplaceServerDBUser} + pgm.sql(`CREATE USER MAPPING IF NOT EXISTS FOR ${marketplaceServerDBUser} SERVER builder_server OPTIONS (user '${builderServerDBUser}', password '${builderServerDBPassword}');`) - pgm.sql(`CREATE FOREIGN TABLE builder_server_items ( + pgm.sql(`CREATE FOREIGN TABLE IF NOT EXISTS builder_server_items ( collection_id uuid, blockchain_item_id text, data text @@ -29,7 +29,7 @@ export async function up(pgm: MigrationBuilder): Promise { SERVER builder_server OPTIONS (schema_name 'public', table_name 'items'); - CREATE FOREIGN TABLE builder_server_collections ( + CREATE FOREIGN TABLE IF NOT EXISTS builder_server_collections ( id uuid, contract_address text )