Questions tagged [rails-migrations]

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

Migrations are a way to alter your database in a reversible manner using (usually) Ruby classes and objects rather than raw SQL. Rails also keeps track of which migrations have run so a simple

$ rake db:migrate

is all that is needed to bring your database up to date even if different people have made different changes. The migrations also maintain your db/schema.rb file.

Links:

1033 questions
0
votes
1 answer

No such file or directory - git://github.com/rails/rails_upgrade.git (Errno::ENOENT)

I was trying to migrate rails app from 2.3.8 to 3.2. I found rails_upgrade plugin appropriate for migration task. But something is stopping me and I have no idea about it. Also tried cloning the same plugin using ssh but rake task of plugin not…
0
votes
2 answers

Added Bio field to 'edit profile' - created migration but then what to add to model?

I've followed Hartl's rails tutorials to the of Chap 9 and now i'm building my own idea so i can get deep into rails. Current issue - I've added a Bio filed to user profiles in edit and the text box appear on the Users profile but i can't figure…
HandDisco
  • 627
  • 1
  • 6
  • 13
0
votes
0 answers

Rails migration not recognizing new column

I am trying to fun a migration to shift some data around. In the previous migration I run the following: add_column :portfolios, :owner_id, :integer Then in the following migration is as follows: class MoveUserIdToPortfolio <…
Ryan
  • 641
  • 5
  • 17
0
votes
3 answers

Mixing Rake tasks AND migrations (legacy to new Rails app)

I am currently re-designing a legacy (Rails) app data schema into a new Rails app. What I have to do is : 1 Migration : create new fields in several tables, add new ones 1 Rake task : dispatch legacy fields values into newly created tables fields 1…
gbarillot
  • 309
  • 1
  • 2
  • 13
0
votes
2 answers

Rails model update doen't work after cap migrate

I have a Rails 3.2 application and I have some issues on the production side: I have a model 'Poject' and did a migration to add a string for 'description'. running rake db:migrate works fine on my developer machine like all the times. But when I…
0
votes
2 answers

Database issues when using RSpec for testing

I'm working on a Ruby on Rails project and trying to get RSpec working so i can write some tests. I run the following command: bundle exec rspec spec/ to run my test. I then get the error Migrations are pending; run 'rake db:migrate…
Sriram Venkatesh
  • 593
  • 2
  • 8
  • 22
0
votes
1 answer

deploying rails app with no migrations

I started building my app in PHP but was convinced by some developer friends to change to RoR instead. Since I already had my database structure designed and created in mysql, I never used any rails migrations to create tables; I just created the…
circle1
  • 237
  • 5
  • 15
0
votes
1 answer

How do I get form_for(@example) to work inside my Collections#show when example belongs_to Collection

this seems like a re-occuring problem for my (probably conceptually), hopefully I can tackle it this time! #stillLearning Two models. A Collection has_many :examples A Example belongs_to :collection Collection has a title: string Example has…
dngoo
  • 499
  • 1
  • 5
  • 16
0
votes
1 answer

Rails Foreign Key not working for one habtm relation?

My model looks like: class Location < ActiveRecord::Base attr_accessible :title has_and_belongs_to_many :adjacent_locations, :class_name => "Location", :foreign_key => "adjacent_location_id", :join_table => "adjacent_locations_locations" …
J.R.
  • 5,789
  • 11
  • 55
  • 78
0
votes
1 answer

Is creating (My)SQL views for a Rails migration bad practice?

I have some nasty looking sql in a migration. I can make it more readable by first creating some views, populating my new table from cleaner SQL that the views make possible, then drop the views. I don't think I've seen this done before in a single…
Mark Bolusmjak
  • 23,606
  • 10
  • 74
  • 129
0
votes
2 answers

mysql missing field after running rails db migration

i have a rails migration: >> cat db/migrate/20091126031039_create_cards.rb class CreateCards < ActiveRecord::Migration def self.up create_table :cards do |t| t.string :number_hash t.int :number t.string :name t.string…
aaronstacy
  • 6,189
  • 13
  • 59
  • 72
0
votes
1 answer

Error : undefined local variable or method `post' for #"

i have come across problem in adding links to posts. My code for index is :-

Listing posts

<%= link_to 'new post',new_post_path %> <% @posts.each do |post| %>
title text
<%= post.title %>…
neha sharma
  • 117
  • 1
  • 3
  • 11
0
votes
2 answers

How to notified about pending Rails migrations after git pull?

I think everybody had that problem. When you colleague creates a migration and you forget to run it after git pull. As I understand, this can be done by post-checkout git hook. Is there a ready solution? If not, suggest how to make this check.…
icem
  • 707
  • 7
  • 12
0
votes
1 answer

How to add_index after migrated in Rail 3

Sorry, I not familiar to Rails. I just wanna know how to apply add_index , after I've already done the migration file by db:migrate add_index :categories_products, [:category_id, :product_id], unique: true I tried to edit the migrate and…
newBike
  • 14,385
  • 29
  • 109
  • 192
0
votes
2 answers

Rails migration error - Name can't be blank

I am using rails 2.x version. Am using mysql 5.0 database for back end process. I faced a migration error when i did the following steps. Get the application code from github. Run schema:create, load and seed process After that add some data in the…