Top "Rails-migrations" questions

Rails migrations are used to track and apply database alterations in a reversible manner.

index: true vs foreign_key: true (Rails)

Following a guide, I ran the following command: rails g migration CreateSnippetsUsers snippet:belongs_to user:belongs_to This created …

ruby-on-rails rails-activerecord ruby-on-rails-5 rails-migrations
Rails migration change sequence or order

I wrote a few migrations for my Rails 3 app, but I would like to change the order of the migrations. …

ruby-on-rails ruby-on-rails-3 rails-migrations
Change foreign key column name in rails

I have a Project migration class like this: class CreateProjects < ActiveRecord::Migration def change create_table :projects do |t| …

ruby-on-rails database-migration rails-migrations
Reversible migration for change_column_default from not having any default in Rails

The Rails guides to active record migrations says that you can do change_column_default :products, :approved, from: true, to: …

ruby-on-rails ruby-on-rails-4 rails-activerecord rails-migrations
Best SQL indexes for join table

With performance improvements in mind, I was wondering if and which indexes are helpful on a join table (specifically used …

ruby-on-rails database-design indexing rails-migrations
Ruby on Rails: how to migrate changes made on models?

In a Rails application, how can I migrate the changes I make in models? For instance, I know that if …

ruby-on-rails ruby ruby-on-rails-3 rails-migrations rails-models
Meaning of "Expected string default value for ..." on Ruby on Rails

Recently I've created an app for Ruby (2.3.3) on Rails (5.0.0.1): $ rails _5.0.0.1_ new myapp --database=postgresql -T After setting up the Gemfile …

ruby-on-rails rails-migrations
Rails 3 migration for adding unsigned int column

I would like to generate a migration to add a column to a table which has a data type of …

ruby-on-rails ruby-on-rails-3 rails-migrations
Specify custom index name when using add_reference

I have the following migration class LinkDoctorsAndSpecializations < ActiveRecord::Migration def up add_reference :doctors, :doctor_specialization, polymorphic: true, index: …

ruby-on-rails ruby ruby-on-rails-4 activerecord rails-migrations
Rails 4 Migration: Mysql2::Error: Data too long for column 'xxxx'

Here is my schema.rb create_table "users", force: true do |t| t.string "name", limit: 6 t.string "email" t.…

ruby-on-rails ruby-on-rails-4 rails-migrations