Rails 4: Migrations are pending

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 rake db:migrate


Solidus: Enable checkout in Indian currency and setting up Shipping Methods

add Lines

# 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?
# 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 4: hack for creating mysql table without auto_increment

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
    add_index :zipcodes, :code, :unique => true