Linked Questions
21 questions linked to/from How can I rename a database column in a Ruby on Rails migration?
-1
votes
1
answer
542
views
Change in migration [duplicate]
add_index :tests, [:title, :level], unique: true
how can i change title to body and save in schema.rb
I tired to manually change it but it doesn't save in schema.rb
441
votes
7
answers
160k
views
How do you write a migration to rename an ActiveRecord model and its table in Rails?
I'm terrible at naming and realize that there are a better set of names for my models in my Rails app. Is there any way to use a migration to rename a model and its corresponding table?
17
votes
3
answers
4k
views
rails g migration "command" to generate column rename migration?
I want to auto generate a migration file that looks like this:
class RenameDatabaseColumn < ActiveRecord::Migration
def change
rename_column :events, :subcategory, :subcategory_id
end
end
...
0
votes
2
answers
4k
views
Convert camelcase table and column names to snake case in mysql
I tried googling and stackoverflowing this but couldn't find an answer, so I thought I would post one.
Currently I inherited a legacy system (PHP/MySQL) where the table and column names are defined ...
0
votes
2
answers
635
views
rails form - checkboxes, FK and datetime -> how to store those attributes in the db?
(rails 2.2.2)
I have 2 models, user and subscription. Each user can have one ore more subscriptions (= premium services). Below the attributes:
user: id, username, ...
subscription: id, user_id (FK), ...
0
votes
2
answers
1k
views
Rails 5: Why does rails add column to schema.rb even though I've deleted the migration file
I created a migration:
class AddFormCounterToUsers < ActiveRecord::Migration[5.2]
def change
add_column :users, :form_count, :integer, default: 0
end
end
I ran rails db:migrate but soon ...
3
votes
2
answers
1k
views
How to resolve a rails model attribute and gem name conflict?
On Rails 3.2.1. I have a model called Car with an attribute called rate (indicates a price quantity). I'm using the ajaxful_rating gem which associates a method called rate (to submit a rating of how ...
0
votes
1
answer
1k
views
Rails Migration Missing Column
I'm trying to rename a column that is definitely there in the schema and all the info is there, but when I go to update it it's giving me a "missing column" error and I can't figure out why? Any ideas?...
1
vote
1
answer
898
views
Change localhost:3000/users/1 to localhost:3000/members/1
I am trying to change "localhost:3000/users/1" to "localhost:3000/members/1".
I changed resources :users in the routes to resources :members and changed users_controller.rb to members_controller.rb ...
1
vote
1
answer
462
views
Rails: Editing Model Column
I'm not sure why it happened, but one of the columns starts with a capital letter. I'm a little worried to change it by doing migrations because the affected column is 'comment_id' column, and Comment ...
1
vote
2
answers
752
views
Update manual database changes in rails app
I created 'Country' table with following columns in rails:
Country
id
country_code
name
prefix
url
Then, updated column names in phppgadmin and now table ...
1
vote
1
answer
339
views
Rails migration returning index too long
Below is the migration file I have defined to rename the column in schooling_document_types_managing_areas table but the issue is when I run the migration I am getting an error Index name is too long; ...
1
vote
1
answer
460
views
rails migration and renaming blob column (sqlite)
created a new rails db migration for renaming a set of columns including one with blob format. when running the migration the following error occurs and the migration is canceled:
SQLite3::...
0
votes
2
answers
360
views
Rails migration to remove field
Hello I am about to attempt to run a rails migration on a database of skills that has a :title and :description. I need to remove the description field and I assume it will look something like this:
...
5
votes
1
answer
192
views
How to rename fields and make them not nulls
My current schema looks like:
create_table "users", :force => true do |t|
t.string "username"
t.string "firstname"
t.string "lastname"
...