First of all debug your migration code.
List your executed migrations with
rake db:migrate:status and look if every migration was executed. You can try to cancel your migration with
rake db:abort_if_pending_migrations and then run
sudo /etc/init.d/httpd restart
sudo /etc/init.d/httpd stop
sudo /etc/init.d/httpd start
Rename the migration dependent on the data and then run
rake db:seed (it will no longer complain on the pending migrations) and then rename back the migration and run
# Change default country and currency # Check if table already exists if ActiveRecord::Base.connection.tables.include?('spree_countries') Spree.config do |config| config.currency = 'INR' country = Spree::Country.find_by_name('India') config.default_country_id = country.id if country.present? end end # Change default country and currency
Checking for existence of
spree_countries table is required. When you run migration for the first time, there will be no table, therefore migration will not work.
rails g model Article title:string body:text user:references
I came across this issue when I was trying to create a zipcodes table with `code` as a primary key and I didn’t want AUTO_INCREMENT.
Below migration helped me-
class CreateZipcodesTable < ActiveRecord::Migration def change create_table :zipcodes, :id => false do |t| t.integer :code, :null => false t.integer :state_id, null: false t.string :city, limit: 255 t.string :state_code, limit: 2, null: false end add_index :zipcodes, :code, :unique => true end end