迁移错误
Error in migration
我尝试 运行 数据库迁移,但出现以下错误
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
检查 authie_sessions
table 在两个数据库 staytus
和 staytus_test
中都存在。
我尝试 运行 数据库迁移,但出现以下错误
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
检查 authie_sessions
table 在两个数据库 staytus
和 staytus_test
中都存在。