From a31a92e28cc8b53113fd528b5f0b421c7fc9c8f2 Mon Sep 17 00:00:00 2001 From: Kemal <223029+disq@users.noreply.github.com> Date: Mon, 2 May 2022 10:01:53 +0100 Subject: [PATCH] fix: Migrator: Use correct underlying type for ARRAY columns in down migrations (#236) Co-authored-by: Kemal Hadimli --- migration/table.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migration/table.go b/migration/table.go index ef5cd449..dd963c3f 100644 --- a/migration/table.go +++ b/migration/table.go @@ -17,7 +17,7 @@ import ( ) const ( - queryTableColumns = `SELECT ARRAY_AGG(column_name::text) AS columns, ARRAY_AGG(data_type::text) AS types FROM information_schema.columns WHERE table_schema=$1 AND table_name=$2` + queryTableColumns = `SELECT ARRAY_AGG(column_name::text) AS columns, ARRAY_AGG(udt_name::regtype::text) AS types FROM information_schema.columns WHERE table_schema=$1 AND table_name=$2` addColumnToTable = `ALTER TABLE IF EXISTS %s ADD COLUMN IF NOT EXISTS %v %v;` dropColumnFromTable = `ALTER TABLE IF EXISTS %s DROP COLUMN IF EXISTS %v;` renameColumnInTable = `-- ALTER TABLE %s RENAME COLUMN %v TO %v; -- uncomment to activate, remove ADD/DROP COLUMN above and below` // Can't have IF EXISTS here