ruby on rails - Rake db:migrate table already exist -
i don't understand why happening. have following migration:
def self.up create_table :leakages |t| t.integer :feature_id t.integer :project_id t.float :total t.date :apt_date end add_index :leakages, [:feature_id, :apt_date] end when run first time runs properly, when run migration again error thrown saying leakages table exist. why error occurring? using mysql2 gem.
do have corresponding self.down in leakages migration? if not change method def change, should able run rake db:migrate:redo runs db:migrate:down db:migrate:up last migration.
the reason seeing message because table exists. rake db:migrate doesn't drop table. runs migrations have not run yet, current environment.
you might interested in reading: http://guides.rubyonrails.org/migrations.html#running-specific-migrations.
so rerun migration(i.e. db:migrate:down db:migrate:up) run:
rake db:migrate:reset version={your migration version}
Comments
Post a Comment