迁移错误

时间:2018-04-04 16:00:44

标签: ruby-on-rails ruby postgresql ruby-on-rails-5 rails-migrations

我尝试运行数据库迁移,但出现以下错误

PG::UndefinedTable: ERROR:  relation "authie_sessions" does not exist
     

:ALTER TABLE" authie_sessions" ADD" two_factored_at" timestamp / home / levi / .rvm / gems / ruby​​-2.4.1 / gems / activerecord-5.1.5 / lib / active_record / connection_adapters / postgresql / database_statements.rb:73:in`async_exec'

我的迁移文件是

class AddTwoFactorAuthFieldsToAuthie < ActiveRecord::Migration[4.2]
  def change
    add_column :authie_sessions, :two_factored_at, :datetime
    add_column :authie_sessions, :two_factored_ip, :string
    add_column :authie_sessions, :requests, :integer, :default => 0
    add_column :authie_sessions, :password_seen_at, :datetime
  end
end

我的database.yml是

default: &default
  adapter: postgresql
  encoding: utf8
  pool: 5
  username: postgres
  password: postgres
  database: staytus
  host: 127.0.0.1

production:
  <<: *default

development:
  <<: *default

test:
  <<: *default
  database: staytus_test

我正在使用postgresql

1 个答案:

答案 0 :(得分:1)

检查authie_sessionsstaytus两个数据库中是否存在staytus_test表。