问题
I just updated to rails4 and realized that my db roles and database was somehow not setup.
So I dropped the db and re-created the app_development db and the roles.
Now I am trying to run rake db:migrate and its failing with following error:
== DeviseCreateUsers: migrating ==============================================
-- create_table(:users)
-> 0.0081s
-- add_index(:users, :email, {:unique=>true})
-> 0.0031s
-- add_index(:users, :reset_password_token, {:unique=>true})
-> 0.0030s
== DeviseCreateUsers: migrated (0.0144s) =====================================
rake aborted!
An error has occurred, this and all later migrations canceled:
PG::ProtocolViolation: ERROR: bind message supplies 1 parameters, but prepared statement "a1" requires 0
: INSERT INTO "schema_migrations" ("version") VALUES ('20130815235601')
Tasks: TOP => db:migrate
I tried to run migrations for different tables manually and it gives the same for each table.
Here is a sample migration file that it is complaining about:
class DeviseCreateUsers < ActiveRecord::Migration
def change
create_table(:users) do |t|
## Database authenticatable
t.string :email, :null => false, :default => ""
t.string :encrypted_password, :null => false, :default => ""
## Recoverable
t.string :reset_password_token
t.datetime :reset_password_sent_at
## Rememberable
t.datetime :remember_created_at
## Trackable
t.integer :sign_in_count, :default => 0
t.datetime :current_sign_in_at
t.datetime :last_sign_in_at
t.string :current_sign_in_ip
t.string :last_sign_in_ip
## Confirmable
# t.string :confirmation_token
# t.datetime :confirmed_at
# t.datetime :confirmation_sent_at
# t.string :unconfirmed_email # Only if using reconfirmable
## Lockable
# t.integer :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts
# t.string :unlock_token # Only if unlock strategy is :email or :both
# t.datetime :locked_at
## Token authenticatable
# t.string :authentication_token
t.timestamps
end
add_index :users, :email, :unique => true
add_index :users, :reset_password_token, :unique => true
# add_index :users, :confirmation_token, :unique => true
# add_index :users, :unlock_token, :unique => true
# add_index :users, :authentication_token, :unique => true
end
end
I think one way is to delete the migration and re-create it.
But I am not sure of exact steps to do that.
Can anyone help me with exact steps with getting the migrations running. I dont mind dropping the db etc since the project is dev stage and there is not much prod data/schema I need to worry about
Thanks. Rails 4.0 PG 9.3.0
Update1: Dont see any rows in schema_mgrations:
select * from schema_migrations;
version
---------
(0 rows)
Update2: Inserting by hand the same values works fine !
INSERT INTO "schema_migrations" ("version") VALUES ('20130815235601');
INSERT 0 1
select * from schema_migrations
version
----------------
20130815235601
(1 row)
Update 3
I ran migrations for different table manually and its failing for each table, so its not an issue with any specific migration.
I also tried to revert back to Rails 3.2.14 and am still facing the same issue.
Feeling lost here and stuck in it for 4-5 days now !!
来源:https://stackoverflow.com/questions/19698806/failing-migrations-pgprotocolviolation-rails