0

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?

2 Answers 2

1

you need something like this in your migration

add_column :users, :favourites, :integer, array: true, default: []

probably better rename column to favourites_ids

Sign up to request clarification or add additional context in comments.

Comments

0

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: []

Comments

Your Answer

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.

Ask question

Explore related questions

See similar questions with these tags.