From a92e82326b2e31ab02a7e1e0390db517ecabb3a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Mon, 26 Jul 2021 23:48:47 +0200 Subject: [PATCH] Ignore OldPassword in Active Storage migration This model is added by the devise-security gem, but we don't use it. We were getting an error while migrating: ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation "old_passwords" does not exist LINE 8: WHERE a.attrelid = '"old_passwords"'::regclas... ^ SELECT a.attname, format_type(a.atttypid, a.atttypmod), pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod, c.collname, col_description(a.attrelid, a.attnum) AS comment FROM pg_attribute a LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum LEFT JOIN pg_type t ON a.atttypid = t.oid LEFT JOIN pg_collation c ON a.attcollation = c.oid AND a.attcollation <> t.typcollation WHERE a.attrelid = '"old_passwords"'::regclass AND a.attnum > 0 AND NOT a.attisdropped ORDER BY a.attnum lib/tasks/active_storage.rake:27:in `block (4 levels) in ' lib/tasks/active_storage.rake:26:in `each' lib/tasks/active_storage.rake:26:in `block (3 levels) in ' lib/tasks/active_storage.rake:25:in `block (2 levels) in ' Caused by: PG::UndefinedTable: ERROR: relation "old_passwords" does not exist --- lib/tasks/active_storage.rake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/tasks/active_storage.rake b/lib/tasks/active_storage.rake index 762e2d33e..7eb4ab919 100644 --- a/lib/tasks/active_storage.rake +++ b/lib/tasks/active_storage.rake @@ -24,6 +24,8 @@ namespace :active_storage do ActiveRecord::Base.transaction do models.each do |model| + next if model.name == "OldPassword" && !model.table_exists? + attachments = model.column_names.map do |c| if c =~ /(.+)_file_name$/ $1