Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
I want to add an extra field "favourites' to my database, obviously favourites should be an array of Int (ID of the event to add as favourite). How can I generate a migration for that?
you need something like this in your migration
add_column :users, :favourites, :integer, array: true, default: []
probably better rename column to favourites_ids
Add a comment
You can do
rails g migration AddFavouritesToUser favourites:text
Then modify the migration before you run it...
add_column :users, :favourites, :text, array: true, default: []
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.