代码之家  ›  专栏  ›  技术社区  ›  L11

迁移时出错

  •  1
  • L11  · 技术社区  · 8 年前

    我尝试运行db迁移,但出现以下错误

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

    :ALTER TABLE“authie\u sessions”ADD“two\u factored\u at”timestamp/home/levi/。rvm/gems/ruby-2.4.1/gems/activerecord-5.1.5/lib/active\u record/connection\u adapters/postgresql/database\u语句。rb:73:in“async\u 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
    

    我的数据库。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 回复  |  直到 8 年前
        1
  •  1
  •   Буянбат Чойжилсүрэн    8 年前

    检查 authie_sessions 两个数据库中都存在表 staytus staytus_test