From 7d72041fff9dc427f730d0afb87de32a2baa15e6 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Mon, 13 Dec 2021 16:19:09 +0000 Subject: [PATCH] FIX: Correct email_tokens_token_to_nullable migration (#15277) We were checking for the existence of the column in any schema, including the `backup` schema. This can cause 'column does not exist' errors. In fact, we should only be checking in the `public` schema. --- db/migrate/20211213060445_email_tokens_token_to_nullable.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/db/migrate/20211213060445_email_tokens_token_to_nullable.rb b/db/migrate/20211213060445_email_tokens_token_to_nullable.rb index d668a9a90d..1207ae1825 100644 --- a/db/migrate/20211213060445_email_tokens_token_to_nullable.rb +++ b/db/migrate/20211213060445_email_tokens_token_to_nullable.rb @@ -11,7 +11,9 @@ class EmailTokensTokenToNullable < ActiveRecord::Migration[6.1] Migration::SafeMigrate.disable! if DB.query_single(<<~SQL).length > 0 SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS - WHERE table_name = 'email_tokens' AND column_name = 'token' + WHERE table_schema='public' + AND table_name = 'email_tokens' + AND column_name = 'token' SQL execute <<~SQL ALTER TABLE email_tokens ALTER COLUMN token DROP NOT NULL