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
-1
votes
1 answer

Issue with rake db:migrate whilst setting up pins scaffold

I have been having some issues with rake db:migrate while setting up a pins scaffold for the One Mont Rails tutorial. When I try to migrate in the terminal I get the following error: Taylors-MacBook-Pro:pinteresting taylorburton$ bin/rake db:migrate…
-1
votes
3 answers

Rails 4: How to delete join table entries via a migration?

I have a join table in rails that has a few entries that need to be deleted. lets say the join table is named 'products_variants' I found out i have a few entries in this join table that were created erroneously a while ago. I have their IDs, so i…
Zyren
  • 603
  • 2
  • 7
  • 21
-1
votes
2 answers

Why 'git checkout .' doesn't undo the changes made by rake 'db:rollback'?

I created a rails application using scaffolding and migrated the database. and I committed a local repository by git commit -m "First commit" then I unrolled the database using rake db:rollback and the application stopped working. I tried to undo…
The Pianist
  • 546
  • 2
  • 13
  • 23
-1
votes
1 answer

Create file on a rails migration

I'm trying to generate default images on my database directly on a migration from images included in my rails app (assets/images). Before this kind of migration, I tap my command directly on the terminal. I would like something like that :…
brcebn
  • 1,571
  • 1
  • 23
  • 46
-2
votes
1 answer

Backfill default values to a column through migration

I have a table(Users). In one of its columns(configs) i added a default value ("A"=>0) through a migration. Now all the new users i create have default value of A but the old users don't. I want to backfill the default value of A for the old users…
-2
votes
1 answer

Removing A Table Index In Rails 4 Using PL-SQL

Please dont blindly report it as a duplicate question, I have clearly explained I have seen all these solutions, but doesnt make any sense to me as beginner, in the given answers code is there to write, but its not clearly given where to write these…
Praveen George
  • 9,237
  • 4
  • 26
  • 53
-2
votes
2 answers

adding a new table using rails migration..?

I want to add new table using rails migration: **table_name** users_location_track **columns** id (primary key, auto increment serial), user_id (reference to users), location_info (string), creation_time(time-stamp) please…
piyushmandovra
  • 4,219
  • 3
  • 19
  • 30
-2
votes
2 answers

Rails and Devise- How do I make the username migration unique and show an error if it is not?

I am using devise for my rails app. I wanted to add the username field so I added a migration to the database. Now I want devise to validate the user_name field for uniqueness but I am not able to figure out how to do that. I also want it to show…
Nishant Arora
  • 388
  • 1
  • 5
  • 10
-2
votes
3 answers

Method rename_column does not rename the column in DB

Solved! Thanks to all so much. It seems was a conflict of the migration versions. I just deleted last records from the scheme_migrations table related with the column renaming. Also i deleted all migrations files in db/migrations related with…
ElCoyote
  • 311
  • 2
  • 11
-3
votes
1 answer

How do I maintain a consistent db for a rails project?

Edit for clarity: I have edited a record in a table in the db. I would like for this record to be consistent across all users who are using the project. All of us are using the same copy of a scrubbed db. I know I could create a migration file for…
-3
votes
1 answer

undefined method `deciaml' when migrating

Hello I have a migration which creates a table (and adds a column to an existing table). class CreateAdminModule < ActiveRecord::Migration def change create_table :admin_module do |t| t.decimal :no_of_devices_multiplier t.decimal…
-4
votes
2 answers

Create first_name and last_name from full_name in a Rails migration

I have a table (People) with a full name column, but want to split it into a first name (and initial if it exists) column and last name column. It's a PostgreSQL database FWIW. I'm at the point of creating the columns, so it can all be done in the…
Greg
  • 2,359
  • 5
  • 22
  • 35
-4
votes
1 answer

Rails (rake) default ID field

When creating a table on my pgslq db with rake, rails allways create an "id" field as primary key. My issue is that i need to have the id field with a custom name. How can i specify the database fields with ONLY the fields i want, specifying the…
Techmago
  • 380
  • 4
  • 18
1 2 3
68
69