生产中的Rails 6无法运行,无法使用任何Rails db或rake db命令,因为未定义表

时间:2020-04-24 21:00:43

标签: ruby-on-rails ruby

当前我们的项目正在开发中,但是当使用RAILS_ENV=production运行时,我无法运行该项目:

coolGuy@coolGuy-home:~/repos/raamble_on-project6-beta$ RAILS_ENV=production rails server
=> Booting Puma
=> Rails 6.0.2.2 application starting in production 
=> Run `rails server --help` for more startup options
Exiting
Traceback (most recent call last):
    91: from bin/rails:4:in `<main>'
    90: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activesupport-6.0.2.2/lib/active_support/dependencies.rb:325:in `require'
    89: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activesupport-6.0.2.2/lib/active_support/dependencies.rb:291:in `load_dependency'
    88: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activesupport-6.0.2.2/lib/active_support/dependencies.rb:325:in `block in require'
    87: from /home/ray/.rvm/gems/ruby-2.6.5/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
    86: from /home/ray/.rvm/gems/ruby-2.6.5/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
    85: from /home/ray/.rvm/gems/ruby-2.6.5/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
    84: from /home/ray/.rvm/gems/ruby-2.6.5/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
    83: from /home/ray/.rvm/gems/ruby-2.6.5/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
    82: from /home/ray/.rvm/gems/ruby-2.6.5/gems/railties-6.0.2.2/lib/rails/commands.rb:18:in `<main>'
    81: from /home/ray/.rvm/gems/ruby-2.6.5/gems/railties-6.0.2.2/lib/rails/command.rb:46:in `invoke'
    80: from /home/ray/.rvm/gems/ruby-2.6.5/gems/railties-6.0.2.2/lib/rails/command/base.rb:69:in `perform'
    79: from /home/ray/.rvm/gems/ruby-2.6.5/gems/thor-1.0.1/lib/thor.rb:392:in `dispatch'
    78: from /home/ray/.rvm/gems/ruby-2.6.5/gems/thor-1.0.1/lib/thor/invocation.rb:127:in `invoke_command'
    77: from /home/ray/.rvm/gems/ruby-2.6.5/gems/thor-1.0.1/lib/thor/command.rb:27:in `run'
    76: from /home/ray/.rvm/gems/ruby-2.6.5/gems/railties-6.0.2.2/lib/rails/commands/server/server_command.rb:138:in `perform'
    75: from /home/ray/.rvm/gems/ruby-2.6.5/gems/railties-6.0.2.2/lib/rails/commands/server/server_command.rb:138:in `tap'
    74: from /home/ray/.rvm/gems/ruby-2.6.5/gems/railties-6.0.2.2/lib/rails/commands/server/server_command.rb:147:in `block in perform'
    73: from /home/ray/.rvm/gems/ruby-2.6.5/gems/railties-6.0.2.2/lib/rails/commands/server/server_command.rb:39:in `start'
    72: from /home/ray/.rvm/gems/ruby-2.6.5/gems/rack-2.2.2/lib/rack/server.rb:311:in `start'
    71: from /home/ray/.rvm/gems/ruby-2.6.5/gems/rack-2.2.2/lib/rack/server.rb:379:in `handle_profiling'
    70: from /home/ray/.rvm/gems/ruby-2.6.5/gems/rack-2.2.2/lib/rack/server.rb:312:in `block in start'
    69: from /home/ray/.rvm/gems/ruby-2.6.5/gems/rack-2.2.2/lib/rack/server.rb:422:in `wrapped_app'
    68: from /home/ray/.rvm/gems/ruby-2.6.5/gems/rack-2.2.2/lib/rack/server.rb:249:in `app'
    67: from /home/ray/.rvm/gems/ruby-2.6.5/gems/rack-2.2.2/lib/rack/server.rb:349:in `build_app_and_options_from_config'
    66: from /home/ray/.rvm/gems/ruby-2.6.5/gems/rack-2.2.2/lib/rack/builder.rb:66:in `parse_file'
    65: from /home/ray/.rvm/gems/ruby-2.6.5/gems/rack-2.2.2/lib/rack/builder.rb:105:in `load_file'
    64: from /home/ray/.rvm/gems/ruby-2.6.5/gems/rack-2.2.2/lib/rack/builder.rb:116:in `new_from_string'
    63: from /home/ray/.rvm/gems/ruby-2.6.5/gems/rack-2.2.2/lib/rack/builder.rb:116:in `eval'
    62: from config.ru:3:in `block in <main>'
    61: from /home/ray/.rvm/gems/ruby-2.6.5/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:49:in `require_relative'
    60: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activesupport-6.0.2.2/lib/active_support/dependencies.rb:325:in `require'
    59: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activesupport-6.0.2.2/lib/active_support/dependencies.rb:291:in `load_dependency'
    58: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activesupport-6.0.2.2/lib/active_support/dependencies.rb:325:in `block in require'
    57: from /home/ray/.rvm/gems/ruby-2.6.5/gems/zeitwerk-2.3.0/lib/zeitwerk/kernel.rb:23:in `require'
    56: from /home/ray/.rvm/gems/ruby-2.6.5/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
    55: from /home/ray/.rvm/gems/ruby-2.6.5/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
    54: from /home/ray/.rvm/gems/ruby-2.6.5/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
    53: from /home/ray/.rvm/gems/ruby-2.6.5/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
    52: from /home/ray/.rvm/gems/ruby-2.6.5/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
    51: from /home/ray/repos/raamble_on-project6-beta/config/environment.rb:5:in `<main>'
    50: from /home/ray/.rvm/gems/ruby-2.6.5/gems/railties-6.0.2.2/lib/rails/application.rb:363:in `initialize!'
    49: from /home/ray/.rvm/gems/ruby-2.6.5/gems/railties-6.0.2.2/lib/rails/initializable.rb:60:in `run_initializers'
    48: from /home/ray/.rbenv/versions/2.6.3/lib/ruby/2.6.0/tsort.rb:205:in `tsort_each'
    47: from /home/ray/.rbenv/versions/2.6.3/lib/ruby/2.6.0/tsort.rb:226:in `tsort_each'
    46: from /home/ray/.rbenv/versions/2.6.3/lib/ruby/2.6.0/tsort.rb:347:in `each_strongly_connected_component'
    45: from /home/ray/.rbenv/versions/2.6.3/lib/ruby/2.6.0/tsort.rb:347:in `call'
    44: from /home/ray/.rbenv/versions/2.6.3/lib/ruby/2.6.0/tsort.rb:347:in `each'
    43: from /home/ray/.rbenv/versions/2.6.3/lib/ruby/2.6.0/tsort.rb:349:in `block in each_strongly_connected_component'
    42: from /home/ray/.rbenv/versions/2.6.3/lib/ruby/2.6.0/tsort.rb:431:in `each_strongly_connected_component_from'
    41: from /home/ray/.rbenv/versions/2.6.3/lib/ruby/2.6.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
    40: from /home/ray/.rbenv/versions/2.6.3/lib/ruby/2.6.0/tsort.rb:228:in `block in tsort_each'
    39: from /home/ray/.rvm/gems/ruby-2.6.5/gems/railties-6.0.2.2/lib/rails/initializable.rb:61:in `block in run_initializers'
    38: from /home/ray/.rvm/gems/ruby-2.6.5/gems/railties-6.0.2.2/lib/rails/initializable.rb:32:in `run'
    37: from /home/ray/.rvm/gems/ruby-2.6.5/gems/railties-6.0.2.2/lib/rails/initializable.rb:32:in `instance_exec'
    36: from /home/ray/.rvm/gems/ruby-2.6.5/gems/railties-6.0.2.2/lib/rails/application/finisher.rb:129:in `block in <module:Finisher>'
    35: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activesupport-6.0.2.2/lib/active_support/lazy_load_hooks.rb:51:in `run_load_hooks'
    34: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activesupport-6.0.2.2/lib/active_support/lazy_load_hooks.rb:51:in `each'
    33: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activesupport-6.0.2.2/lib/active_support/lazy_load_hooks.rb:52:in `block in run_load_hooks'
    32: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activesupport-6.0.2.2/lib/active_support/lazy_load_hooks.rb:67:in `execute_hook'
    31: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activesupport-6.0.2.2/lib/active_support/lazy_load_hooks.rb:62:in `with_execution_control'
    30: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activesupport-6.0.2.2/lib/active_support/lazy_load_hooks.rb:69:in `block in execute_hook'
    29: from /home/ray/repos/raamble_on-project6-beta/config/application.rb:52:in `block in <class:Application>'
    28: from /home/ray/repos/raamble_on-project6-beta/config/application.rb:52:in `each'
    27: from /home/ray/repos/raamble_on-project6-beta/config/application.rb:113:in `block (2 levels) in <class:Application>'
    26: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activerecord-6.0.2.2/lib/active_record/dynamic_matchers.rb:18:in `method_missing'
    25: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activerecord-6.0.2.2/lib/active_record/dynamic_matchers.rb:60:in `valid?'
    24: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activerecord-6.0.2.2/lib/active_record/dynamic_matchers.rb:60:in `all?'
    23: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activerecord-6.0.2.2/lib/active_record/dynamic_matchers.rb:60:in `block in valid?'
    22: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activerecord-6.0.2.2/lib/active_record/model_schema.rb:352:in `columns_hash'
    21: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activerecord-6.0.2.2/lib/active_record/model_schema.rb:477:in `load_schema'
    20: from /home/ray/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:230:in `mon_synchronize'
    19: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activerecord-6.0.2.2/lib/active_record/model_schema.rb:480:in `block in load_schema'
    18: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activerecord-6.0.2.2/lib/active_record/attribute_decorators.rb:51:in `load_schema!'
    17: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activerecord-6.0.2.2/lib/active_record/attributes.rb:247:in `load_schema!'
    16: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activerecord-6.0.2.2/lib/active_record/model_schema.rb:490:in `load_schema!'
    15: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activerecord-6.0.2.2/lib/active_record/connection_adapters/schema_cache.rb:82:in `columns_hash'
    14: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activerecord-6.0.2.2/lib/active_record/connection_adapters/schema_cache.rb:76:in `columns'
    13: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activerecord-6.0.2.2/lib/active_record/connection_adapters/abstract/schema_statements.rb:114:in `columns'
    12: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activerecord-6.0.2.2/lib/active_record/connection_adapters/postgresql_adapter.rb:817:in `column_definitions'
    11: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activerecord-6.0.2.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:63:in `query'
    10: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activerecord-6.0.2.2/lib/active_record/connection_adapters/abstract_adapter.rb:708:in `log'
     9: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activesupport-6.0.2.2/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
     8: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activerecord-6.0.2.2/lib/active_record/connection_adapters/abstract_adapter.rb:717:in `block in log'
     7: from /home/ray/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:230:in `mon_synchronize'
     6: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activerecord-6.0.2.2/lib/active_record/connection_adapters/abstract_adapter.rb:718:in `block (2 levels) in log'
     5: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activerecord-6.0.2.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:64:in `block in query'
     4: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activesupport-6.0.2.2/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
     3: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activesupport-6.0.2.2/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
     2: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activesupport-6.0.2.2/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
     1: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activerecord-6.0.2.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:65:in `block (2 levels) in query'
/home/ray/.rvm/gems/ruby-2.6.5/gems/activerecord-6.0.2.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:65:in `exec': ERROR:  relation "courses" does not exist (PG::UndefinedTable)
LINE 8:  WHERE a.attrelid = '"courses"'::regclass
                            ^
    91: from bin/rails:4:in `<main>'
    90: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activesupport-6.0.2.2/lib/active_support/dependencies.rb:325:in `require'
    89: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activesupport-6.0.2.2/lib/active_support/dependencies.rb:291:in `load_dependency'
    88: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activesupport-6.0.2.2/lib/active_support/dependencies.rb:325:in `block in require'
    87: from /home/ray/.rvm/gems/ruby-2.6.5/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
    86: from /home/ray/.rvm/gems/ruby-2.6.5/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
    85: from /home/ray/.rvm/gems/ruby-2.6.5/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
    84: from /home/ray/.rvm/gems/ruby-2.6.5/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
    83: from /home/ray/.rvm/gems/ruby-2.6.5/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
    82: from /home/ray/.rvm/gems/ruby-2.6.5/gems/railties-6.0.2.2/lib/rails/commands.rb:18:in `<main>'
    81: from /home/ray/.rvm/gems/ruby-2.6.5/gems/railties-6.0.2.2/lib/rails/command.rb:46:in `invoke'
    80: from /home/ray/.rvm/gems/ruby-2.6.5/gems/railties-6.0.2.2/lib/rails/command/base.rb:69:in `perform'
    79: from /home/ray/.rvm/gems/ruby-2.6.5/gems/thor-1.0.1/lib/thor.rb:392:in `dispatch'
    78: from /home/ray/.rvm/gems/ruby-2.6.5/gems/thor-1.0.1/lib/thor/invocation.rb:127:in `invoke_command'
    77: from /home/ray/.rvm/gems/ruby-2.6.5/gems/thor-1.0.1/lib/thor/command.rb:27:in `run'
    76: from /home/ray/.rvm/gems/ruby-2.6.5/gems/railties-6.0.2.2/lib/rails/commands/server/server_command.rb:138:in `perform'
    75: from /home/ray/.rvm/gems/ruby-2.6.5/gems/railties-6.0.2.2/lib/rails/commands/server/server_command.rb:138:in `tap'
    74: from /home/ray/.rvm/gems/ruby-2.6.5/gems/railties-6.0.2.2/lib/rails/commands/server/server_command.rb:147:in `block in perform'
    73: from /home/ray/.rvm/gems/ruby-2.6.5/gems/railties-6.0.2.2/lib/rails/commands/server/server_command.rb:39:in `start'
    72: from /home/ray/.rvm/gems/ruby-2.6.5/gems/rack-2.2.2/lib/rack/server.rb:311:in `start'
    71: from /home/ray/.rvm/gems/ruby-2.6.5/gems/rack-2.2.2/lib/rack/server.rb:379:in `handle_profiling'
    70: from /home/ray/.rvm/gems/ruby-2.6.5/gems/rack-2.2.2/lib/rack/server.rb:312:in `block in start'
    69: from /home/ray/.rvm/gems/ruby-2.6.5/gems/rack-2.2.2/lib/rack/server.rb:422:in `wrapped_app'
    68: from /home/ray/.rvm/gems/ruby-2.6.5/gems/rack-2.2.2/lib/rack/server.rb:249:in `app'
    67: from /home/ray/.rvm/gems/ruby-2.6.5/gems/rack-2.2.2/lib/rack/server.rb:349:in `build_app_and_options_from_config'
    66: from /home/ray/.rvm/gems/ruby-2.6.5/gems/rack-2.2.2/lib/rack/builder.rb:66:in `parse_file'
    65: from /home/ray/.rvm/gems/ruby-2.6.5/gems/rack-2.2.2/lib/rack/builder.rb:105:in `load_file'
    64: from /home/ray/.rvm/gems/ruby-2.6.5/gems/rack-2.2.2/lib/rack/builder.rb:116:in `new_from_string'
    63: from /home/ray/.rvm/gems/ruby-2.6.5/gems/rack-2.2.2/lib/rack/builder.rb:116:in `eval'
    62: from config.ru:3:in `block in <main>'
    61: from /home/ray/.rvm/gems/ruby-2.6.5/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:49:in `require_relative'
    60: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activesupport-6.0.2.2/lib/active_support/dependencies.rb:325:in `require'
    59: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activesupport-6.0.2.2/lib/active_support/dependencies.rb:291:in `load_dependency'
    58: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activesupport-6.0.2.2/lib/active_support/dependencies.rb:325:in `block in require'
    57: from /home/ray/.rvm/gems/ruby-2.6.5/gems/zeitwerk-2.3.0/lib/zeitwerk/kernel.rb:23:in `require'
    56: from /home/ray/.rvm/gems/ruby-2.6.5/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
    55: from /home/ray/.rvm/gems/ruby-2.6.5/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
    54: from /home/ray/.rvm/gems/ruby-2.6.5/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
    53: from /home/ray/.rvm/gems/ruby-2.6.5/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
    52: from /home/ray/.rvm/gems/ruby-2.6.5/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
    51: from /home/ray/repos/raamble_on-project6-beta/config/environment.rb:5:in `<main>'
    50: from /home/ray/.rvm/gems/ruby-2.6.5/gems/railties-6.0.2.2/lib/rails/application.rb:363:in `initialize!'
    49: from /home/ray/.rvm/gems/ruby-2.6.5/gems/railties-6.0.2.2/lib/rails/initializable.rb:60:in `run_initializers'
    48: from /home/ray/.rbenv/versions/2.6.3/lib/ruby/2.6.0/tsort.rb:205:in `tsort_each'
    47: from /home/ray/.rbenv/versions/2.6.3/lib/ruby/2.6.0/tsort.rb:226:in `tsort_each'
    46: from /home/ray/.rbenv/versions/2.6.3/lib/ruby/2.6.0/tsort.rb:347:in `each_strongly_connected_component'
    45: from /home/ray/.rbenv/versions/2.6.3/lib/ruby/2.6.0/tsort.rb:347:in `call'
    44: from /home/ray/.rbenv/versions/2.6.3/lib/ruby/2.6.0/tsort.rb:347:in `each'
    43: from /home/ray/.rbenv/versions/2.6.3/lib/ruby/2.6.0/tsort.rb:349:in `block in each_strongly_connected_component'
    42: from /home/ray/.rbenv/versions/2.6.3/lib/ruby/2.6.0/tsort.rb:431:in `each_strongly_connected_component_from'
    41: from /home/ray/.rbenv/versions/2.6.3/lib/ruby/2.6.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
    40: from /home/ray/.rbenv/versions/2.6.3/lib/ruby/2.6.0/tsort.rb:228:in `block in tsort_each'
    39: from /home/ray/.rvm/gems/ruby-2.6.5/gems/railties-6.0.2.2/lib/rails/initializable.rb:61:in `block in run_initializers'
    38: from /home/ray/.rvm/gems/ruby-2.6.5/gems/railties-6.0.2.2/lib/rails/initializable.rb:32:in `run'
    37: from /home/ray/.rvm/gems/ruby-2.6.5/gems/railties-6.0.2.2/lib/rails/initializable.rb:32:in `instance_exec'
    36: from /home/ray/.rvm/gems/ruby-2.6.5/gems/railties-6.0.2.2/lib/rails/application/finisher.rb:129:in `block in <module:Finisher>'
    35: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activesupport-6.0.2.2/lib/active_support/lazy_load_hooks.rb:51:in `run_load_hooks'
    34: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activesupport-6.0.2.2/lib/active_support/lazy_load_hooks.rb:51:in `each'
    33: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activesupport-6.0.2.2/lib/active_support/lazy_load_hooks.rb:52:in `block in run_load_hooks'
    32: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activesupport-6.0.2.2/lib/active_support/lazy_load_hooks.rb:67:in `execute_hook'
    31: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activesupport-6.0.2.2/lib/active_support/lazy_load_hooks.rb:62:in `with_execution_control'
    30: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activesupport-6.0.2.2/lib/active_support/lazy_load_hooks.rb:69:in `block in execute_hook'
    29: from /home/ray/repos/raamble_on-project6-beta/config/application.rb:52:in `block in <class:Application>'
    28: from /home/ray/repos/raamble_on-project6-beta/config/application.rb:52:in `each'
    27: from /home/ray/repos/raamble_on-project6-beta/config/application.rb:113:in `block (2 levels) in <class:Application>'
    26: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activerecord-6.0.2.2/lib/active_record/dynamic_matchers.rb:18:in `method_missing'
    25: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activerecord-6.0.2.2/lib/active_record/dynamic_matchers.rb:60:in `valid?'
    24: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activerecord-6.0.2.2/lib/active_record/dynamic_matchers.rb:60:in `all?'
    23: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activerecord-6.0.2.2/lib/active_record/dynamic_matchers.rb:60:in `block in valid?'
    22: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activerecord-6.0.2.2/lib/active_record/model_schema.rb:352:in `columns_hash'
    21: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activerecord-6.0.2.2/lib/active_record/model_schema.rb:477:in `load_schema'
    20: from /home/ray/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:230:in `mon_synchronize'
    19: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activerecord-6.0.2.2/lib/active_record/model_schema.rb:480:in `block in load_schema'
    18: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activerecord-6.0.2.2/lib/active_record/attribute_decorators.rb:51:in `load_schema!'
    17: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activerecord-6.0.2.2/lib/active_record/attributes.rb:247:in `load_schema!'
    16: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activerecord-6.0.2.2/lib/active_record/model_schema.rb:490:in `load_schema!'
    15: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activerecord-6.0.2.2/lib/active_record/connection_adapters/schema_cache.rb:82:in `columns_hash'
    14: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activerecord-6.0.2.2/lib/active_record/connection_adapters/schema_cache.rb:76:in `columns'
    13: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activerecord-6.0.2.2/lib/active_record/connection_adapters/abstract/schema_statements.rb:114:in `columns'
    12: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activerecord-6.0.2.2/lib/active_record/connection_adapters/postgresql_adapter.rb:817:in `column_definitions'
    11: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activerecord-6.0.2.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:63:in `query'
    10: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activerecord-6.0.2.2/lib/active_record/connection_adapters/abstract_adapter.rb:708:in `log'
     9: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activesupport-6.0.2.2/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
     8: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activerecord-6.0.2.2/lib/active_record/connection_adapters/abstract_adapter.rb:717:in `block in log'
     7: from /home/ray/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:230:in `mon_synchronize'
     6: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activerecord-6.0.2.2/lib/active_record/connection_adapters/abstract_adapter.rb:718:in `block (2 levels) in log'
     5: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activerecord-6.0.2.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:64:in `block in query'
     4: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activesupport-6.0.2.2/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
     3: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activesupport-6.0.2.2/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
     2: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activesupport-6.0.2.2/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
     1: from /home/ray/.rvm/gems/ruby-2.6.5/gems/activerecord-6.0.2.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:65:in `block (2 levels) in query'
/home/ray/.rvm/gems/ruby-2.6.5/gems/activerecord-6.0.2.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:65:in `exec': PG::UndefinedTable: ERROR:  relation "courses" does not exist (ActiveRecord::StatementInvalid)
LINE 8:  WHERE a.attrelid = '"courses"'::regclass

此错误未出现在开发中。该表较早存在一个问题,我的团队成员删除了一些迁移,为此表创建了一个迁移,并为此表创建了一个列,但是,在进行一些修补后,我得以使其再次在开发环境中工作。

我也尝试使用SQLite作为数据库而不是PostgreSQL,但是我仍然没有运气。

如何修复生产?

1 个答案:

答案 0 :(得分:2)

如果schema.rb是数据库架构的有效版本,则可以使用它代替生产中的迁移。

RAILS_ENV=production rake db:schema:load

将db / schema.rb中已经生成的模式加载到数据库中。

您可能需要首先创建或删除/创建生产数据库。如果我理解正确,那么那里还没有真实数据。

RAILS_ENV=production rake db:drop
RAILS_ENV=production rake db:create

相关问题