Migration issues when updating a very old db because of database / schema mismatch
On an excessively old DB (FSE's), while trying to update to the latest stable release, the migration to insert skeletons for soft-deleted users fails, apparently due to the migration using model code and the model code expecting some non-existent columns to exist. This doesn't affect new instances (because there are no deactivated users if there are no users so the each
block never gets called) so this is probably a remote edge-case. My workaround was to just add true ||
to the unless
around the code and skip it. (Everything other than that went better than expected. Less than three.)
13:16:30.175 [info] == Running 20200428221338 Pleroma.Repo.Migrations.InsertSkeletonsForDeletedUsers.change/0 forward
** (Postgrex.Error) ERROR 42703 (undefined_column) column "is_locked" of relation "users" does not exist
query: INSERT INTO "users" ("confirmation_pending","avatar","actor_type","hide_followers_count","following_count","fields","email_notifications","unread_conversation_count","is_locked","is_moderator","hide_follows","ap_enabled","allow_following_move","muted_reblogs","note_count","emoji","domain_blocks","show_role","pinned_activities","hide_followers","is_admin","subscribers","password_reset_pending","follower_count","local","approval_pending","mutes","pleroma_settings_store","background","invisible","raw_fields","hide_favorites","hide_follows_count","also_known_as","blocks","ap_id","banner","discoverable","muted_notifications","bio","skip_thread_containment","no_rich_text","default_scope","tags","deactivated","id","inserted_at","updated_at") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22,$23,$24,$25,$26,$27,$28,$29,$30,$31,$32,$33,$34,$35,$36,$37,$38,$39,$40,$41,$42,$43,$44,$45,$46,$47,$48)
(ecto_sql 3.4.5) lib/ecto/adapters/sql.ex:593: Ecto.Adapters.SQL.raise_sql_call_error/1
(ecto 3.4.6) lib/ecto/repo/schema.ex:661: Ecto.Repo.Schema.apply/4
(ecto 3.4.6) lib/ecto/repo/schema.ex:263: anonymous fn/15 in Ecto.Repo.Schema.do_insert/4
(elixir 1.10.3) lib/enum.ex:783: Enum."-each/2-lists^foreach/1-0-"/2
(elixir 1.10.3) lib/enum.ex:783: Enum.each/2
(ecto_sql 3.4.5) lib/ecto/migration/runner.ex:278: Ecto.Migration.Runner.perform_operation/3
(stdlib 3.13.2) timer.erl:166: :timer.tc/1
(ecto_sql 3.4.5) lib/ecto/migration/runner.ex:25: Ecto.Migration.Runner.run/7
Edited by lain