Migrate order issue when upgrading from stable to develop
Environment
- Pleroma version: 2.0.50-1790-gfd5ad99a-v-develop / 9c7cb3a9 (old version: tag v2.0.7)
- Elixir version: 1.9.4 (Erlang/OTP 22)
- Operating system: NixOS 10.03
- PostgreSQL version: 12.2
Bug description
An error occurred while upgrading to the stable version:
[pleroma@swift:~/pleroma_dev]$ NIX_ENV=prod mix ecto.migrate
…
22:44:15.774 [info] == Running 20200527163635 Pleroma.Repo.Migrations.DeleteNotificationsFromInvisibleUsers.up/0 forward
22:44:15.896 [info] == Migrated 20200527163635 in 0.1s
22:44:15.901 [info] == Running 20200602094828 Pleroma.Repo.Migrations.AddTypeToNotifications.change/0 forward
22:44:15.902 [info] alter table notifications
22:44:15.903 [info] == Migrated 20200602094828 in 0.0s
22:44:15.908 [info] == Running 20200602125218 Pleroma.Repo.Migrations.BackfillNotificationTypes.up/0 forward
** (Postgrex.Error) ERROR 42703 (undefined_column) column u0.mastofe_settings does not exist
query: SELECT u0."id", u0."bio", u0."raw_bio", u0."email", u0."name", u0."nickname", u0."password_hash", u0."keys", u0."public_key", u0."ap_id", u0."avatar", u0."local", u0."follower_address", u0."following_address", u0."tags", u0."last_refreshed_at", u0."last_digest_emailed_at", u0."banner", u0."background", u0."note_count", u0."follower_count", u0."following_count", u0."locked", u0."confirmation_pending", u0."password_reset_pending", u0."confirmation_token", u0."default_scope", u0."domain_blocks", u0."deactivated", u0."no_rich_text", u0."ap_enabled", u0."is_moderator", u0."is_admin", u0."show_role", u0."mastofe_settings", u0."uri", u0."hide_followers_count", u0."hide_follows_count", u0."hide_followers", u0."hide_follows", u0."hide_favorites", u0."unread_conversation_count", u0."pinned_activities", u0."email_notifications", u0."mascot", u0."emoji", u0."pleroma_settings_store", u0."fields", u0."raw_fields", u0."discoverable", u0."invisible", u0."allow_following_move", u0."skip_thread_containment", u0."actor_type", u0."also_known_as", u0."inbox", u0."shared_inbox", u0."notification_settings", u0."blocks", u0."mutes", u0."muted_reblogs", u0."muted_notifications", u0."subscribers", u0."multi_factor_authentication_settings", u0."inserted_at", u0."updated_at" FROM "users" AS u0 WHERE (u0."ap_id" = $1)
(ecto_sql) lib/ecto/adapters/sql.ex:612: Ecto.Adapters.SQL.raise_sql_call_error/1
…
I manually renamed column settings
to mastofe_settings
, but then:
[pleroma@swift:~/pleroma_dev]$ NIX_ENV=prod mix ecto.migrate
22:45:26.063 [info] == Running 20200602125218 Pleroma.Repo.Migrations.BackfillNotificationTypes.up/0 forward
22:45:26.795 [info] == Migrated 20200602125218 in 0.7s
22:45:26.812 [info] == Running 20200602150528 Pleroma.Repo.Migrations.CreateChatMessageReference.change/0 forward
22:45:26.813 [info] create table chat_message_references
22:45:26.817 [info] create index chat_message_references_chat_id_id_desc_index
22:45:26.819 [info] == Migrated 20200602150528 in 0.0s
22:45:26.824 [info] == Running 20200603105113 Pleroma.Repo.Migrations.AddUniqueIndexToChatMessageReferences.change/0 forward
…
22:45:26.881 [info] == Running 20200607112923 Pleroma.Repo.Migrations.ChangeChatIdToFlake.up/0 forward
22:45:26.882 [info] execute "alter table chats\ndrop constraint chats_pkey cascade,\nalter column id drop default,\nalter column id set data type uuid using cast( lpad( to_hex(id), 32, '0') as uuid),\nadd primary key (id)\n"
22:45:26.887 [info] drop cascades to constraint chat_message_references_chat_id_fkey on table chat_message_references
22:45:26.887 [info] execute "alter table chat_message_references\nalter column chat_id set data type uuid using cast( lpad( to_hex(chat_id), 32, '0') as uuid),\nadd constraint chat_message_references_chat_id_fkey foreign key (chat_id) references chats(id) on delete cascade\n"
22:45:26.896 [info] == Migrated 20200607112923 in 0.0s
22:45:26.902 [info] == Running 20200630162024 Pleroma.Repo.Migrations.RenameUserSettingsCol.up/0 forward
22:45:26.902 [info] rename column settings to mastofe_settings on table users
** (Postgrex.Error) ERROR 42703 (undefined_column) column "settings" does not exist
(ecto_sql) lib/ecto/adapters/sql.ex:612: Ecto.Adapters.SQL.raise_sql_call_error/1
…
So i had to manually disable this migrate.
Edited by bird