Dan
Dan

Reputation: 41

rake db:migrate RAILS_ENV=production is not working

I uploaded my local file to AWS and I did rake db:migrate RAILS_ENV=production, but it shows error... It was working on my local environment but it`s not working on production.

ActiveRecord::SchemaMigration Load (0.2ms)  SELECT `schema_migrations`.* FROM `schema_migrations`
Migrating to DeleteTagCategories (20170422082951)
== 20170422082951 DeleteTagCategories: migrating ==============================
-- drop_table(:tag_categories)
   (0.2ms)  DROP TABLE `tag_categories`
rake aborted!
StandardError: An error has occurred, all later migrations canceled:

Mysql2::Error: Unknown table 'tag_categories': DROP TABLE `tag_categories`

What is the best way to solve this error ?

Upvotes: 1

Views: 2225

Answers (1)

TWA
TWA

Reputation: 12816

You should be aware that db:schema:load will remove existing data, so you probably don't want to run that in production if you have any non-seed data you want to keep.

Since the table (tag_categories) was deleted before it was pushed to production I would have just removed the table manually and not used a migration.

So basically just remove the migration that deletes tag_categories since this table only ever existed on your local machine.

When I am doing Rails development I normally just edit existing migrations and make manual changes where possible instead of creating new migrations for each change. Once I push to production (or source control if working with a team) then I will no longer make additional changes to existing migrations. This cuts down on the number of unnecessary migrations, which can add up quickly.

Upvotes: 1

Related Questions