Миграция прерывается в процессе развертывания с ошибкой: PG :: UndefinedTable: ОШИБКА: отношение «списки воспроизведения» не существует - PullRequest
0 голосов
/ 28 февраля 2020

Это миграция, которую я имею:

class AddTranslationsForPlaylistsYoutubesDjSetsAndPodcasts < ActiveRecord::Migration[6.0]
  def change
    reversible do |dir|
      dir.up do
        Djset.create_translation_table!({ title: :string }, { migrate_data: true, remove_source_columns: true })
        Playlist.create_translation_table!({ title: :string }, { migrate_data: true, remove_source_columns: true })
        YouTube.create_translation_table!({ title: :string }, { migrate_data: true, remove_source_columns: true })
        Podcast.create_translation_table!({ title: :string }, { migrate_data: true, remove_source_columns: true })
      end

      dir.down do
        Djset.drop_translation_table! migrate_data: true
        Playlist.drop_translation_table! migrate_data: true
        YouTube.drop_translation_table! migrate_data: true
        Podcast.drop_translation_table! migrate_data: true
      end
    end
  end
end

Когда я запускаю ее локально - все в порядке, но когда я запускаю процесс развертывания с помощью capistrano, миграция прерывается с ошибкой: PG::UndefinedTable: ERROR: relation "playlists" does not exist и в моих логах написано, что что-то не так с этой строкой: Playlist.create_translation_table!({ title: :string }, { migrate_data: true, remove_source_columns: true }). Не могу понять, что не так с этой строкой, потому что предыдущая строка очень похожа на текущую. Кто-нибудь может сказать мне, что идет не так? Спасибо вперед.

=== РЕДАКТИРОВАТЬ ===

Вот журналы:

DEBUG [9cd2ebc3]    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc1/lib/active_record/connection_adapters/postgresql/database_statements.rb:65:in `async_exec'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc1/lib/active_record/connection_adapters/postgresql/database_statements.rb:65:in `block (2 levels) in query'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/gems/activesupport-6.0.0.rc1/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/gems/activesupport-6.0.0.rc1/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/gems/activesupport-6.0.0.rc1/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc1/lib/active_record/connection_adapters/postgresql/database_statements.rb:64:in `block in query'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc1/lib/active_record/connection_adapters/abstract_adapter.rb:685:in `block (2 levels) in log'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc1/lib/active_record/connection_adapters/abstract_adapter.rb:684:in `block in log'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/gems/activesupport-6.0.0.rc1/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc1/lib/active_record/connection_adapters/abstract_adapter.rb:675:in `log'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc1/lib/active_record/connection_adapters/postgresql/database_statements.rb:63:in `query'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc1/lib/active_record/connection_adapters/postgresql_adapter.rb:806:in `column_definitions'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc1/lib/active_record/connection_adapters/abstract/schema_statements.rb:114:in `columns'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc1/lib/active_record/connection_adapters/schema_cache.rb:76:in `columns'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc1/lib/active_record/connection_adapters/schema_cache.rb:82:in `columns_hash'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc1/lib/active_record/model_schema.rb:487:in `load_schema!'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc1/lib/active_record/attributes.rb:247:in `load_schema!'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc1/lib/active_record/attribute_decorators.rb:51:in `load_schema!'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc1/lib/active_record/model_schema.rb:480:in `block in load_schema'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc1/lib/active_record/model_schema.rb:477:in `load_schema'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc1/lib/active_record/model_schema.rb:357:in `columns'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/bundler/gems/globalize-8af95a12a0dc/lib/globalize/active_record/migration.rb:18:in `columns'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/bundler/gems/globalize-8af95a12a0dc/lib/globalize/active_record/migration.rb:172:in `column_type'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/bundler/gems/globalize-8af95a12a0dc/lib/globalize/active_record/migration.rb:85:in `block in create_translation_table'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc1/lib/active_record/connection_adapters/abstract/schema_statements.rb:309:in `create_table'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/bundler/gems/globalize-8af95a12a0dc/lib/globalize/active_record/migration.rb:81:in `create_translation_table'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/bundler/gems/globalize-8af95a12a0dc/lib/globalize/active_record/migration.rb:39:in `create_translation_table!'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/bundler/gems/globalize-8af95a12a0dc/lib/globalize/active_record/migration.rb:10:in `create_translation_table!'
    /home/deployer/apps/my-app/releases/20200228105525/db/migrate/20200220101151_add_translations_for_playlists_youtubes_dj_sets_and_podcasts.rb:5:in `block (2 levels) in change'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc1/lib/active_record/migration.rb:705:in `up'
    /home/deployer/apps/my-app/releases/20200228105525/db/migrate/20200220101151_add_translations_for_playlists_youtubes_dj_sets_and_podcasts.rb:4:in `block in change'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc1/lib/active_record/migration.rb:741:in `block in reversible'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc1/lib/active_record/migration.rb:967:in `execute_block'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc1/lib/active_record/migration.rb:741:in `reversible'
    /home/deployer/apps/my-app/releases/20200228105525/db/migrate/20200220101151_add_translations_for_playlists_youtubes_dj_sets_and_podcasts.rb:3:in `change'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc1/lib/active_record/migration.rb:820:in `exec_migration'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc1/lib/active_record/migration.rb:804:in `block (2 levels) in migrate'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc1/lib/active_record/migration.rb:803:in `block in migrate'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc1/lib/active_record/connection_adapters/abstract/connection_pool.rb:416:in `with_connection'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc1/lib/active_record/migration.rb:802:in `migrate'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc1/lib/active_record/migration.rb:992:in `migrate'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc1/lib/active_record/migration.rb:1300:in `block in execute_migration_in_transaction'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc1/lib/active_record/migration.rb:1351:in `block in ddl_transaction'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc1/lib/active_record/connection_adapters/abstract/database_statements.rb:277:in `block in transaction'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc1/lib/active_record/connection_adapters/abstract/transaction.rb:272:in `block in within_new_transaction'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc1/lib/active_record/connection_adapters/abstract/transaction.rb:270:in `within_new_transaction'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc1/lib/active_record/connection_adapters/abstract/database_statements.rb:277:in `transaction'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc1/lib/active_record/transactions.rb:212:in `transaction'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc1/lib/active_record/migration.rb:1351:in `ddl_transaction'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc1/lib/active_record/migration.rb:1299:in `execute_migration_in_transaction'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc1/lib/active_record/migration.rb:1271:in `block in migrate_without_lock'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc1/lib/active_record/migration.rb:1270:in `each'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc1/lib/active_record/migration.rb:1270:in `migrate_without_lock'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc1/lib/active_record/migration.rb:1218:in `block in migrate'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc1/lib/active_record/migration.rb:1371:in `with_advisory_lock'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc1/lib/active_record/migration.rb:1218:in `migrate'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc1/lib/active_record/migration.rb:1051:in `up'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc1/lib/active_record/migration.rb:1026:in `migrate'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc1/lib/active_record/tasks/database_tasks.rb:226:in `migrate'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc1/lib/active_record/railties/databases.rake:83:in `block (3 levels) in <main>'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc1/lib/active_record/railties/databases.rake:81:in `each'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/gems/activerecord-6.0.0.rc1/lib/active_record/railties/databases.rake:81:in `block (2 levels) in <main>'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/gems/rake-12.3.2/exe/rake:27:in `<top (required)>'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/bin/ruby_executable_hooks:24:in `eval'
    /home/deployer/apps/my-app/shared/bundle/ruby/2.6.0/bin/ruby_executable_hooks:24:in `<main>'
     DEBUG [9cd2ebc3]   
    Caused by:
     DEBUG [9cd2ebc3]   PG::UndefinedTable: ERROR:  relation "playlists" does not exist
    LINE 8:  WHERE a.attrelid = '"playlists"'::regclass   
...