Hi I am new to rails and I am adding a like option to my posts, however when I run rails db:migrate:redo I get the error ArgumentError: No indexes found on likes with the options provided. I am confused because I see the indexes in my schema
here is a picture of the error
20221215185521_create_likes.rb
class CreateLikes < ActiveRecord::Migration[7.0]
def change
create_table :likes do |t|
t.references :user, null: false, foreign_key: true
t.references :post, null: false, foreign_key: true
t.timestamps
end
add_index :likes, [:user_id, :post_id], unique: true
end
end
schema.rb
ActiveRecord::Schema[7.0].define(version: 2022_12_15_185521) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
create_table "followability_relationships", force: :cascade do |t|
t.string "followerable_type", null: false
t.bigint "followerable_id", null: false
t.string "followable_type", null: false
t.bigint "followable_id", null: false
t.integer "status"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["followable_type", "followable_id"], name:
"index_followability_relationships_on_followable"
t.index ["followerable_type", "followerable_id"], name:
"index_followability_relationships_on_followerable"
end
create_table "likes", force: :cascade do |t|
t.bigint "user_id", null: false
t.bigint "post_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["post_id"], name: "index_likes_on_post_id"
t.index ["user_id"], name: "index_likes_on_user_id"
end
create_table "notifications", force: :cascade do |t|
t.string "recipient_type", null: false
t.bigint "recipient_id", null: false
t.string "type", null: false
t.jsonb "params"
t.datetime "read_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["read_at"], name: "index_notifications_on_read_at"
t.index ["recipient_type", "recipient_id"], name: "index_notifications_on_recipient"
end
create_table "posts", force: :cascade do |t|
t.text "body"
t.bigint "user_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["user_id"], name: "index_posts_on_user_id"
end
create_table "users", force: :cascade do |t|
t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "username"
t.index ["email"], name: "index_users_on_email", unique: true
t.index ["reset_password_token"], name: "index_users_on_reset_password_token",
unique: true
end
add_foreign_key "likes", "posts"
add_foreign_key "likes", "users"
add_foreign_key "posts", "users"
end