Skip to content

Commit

Permalink
Fix creating index in migration
Browse files Browse the repository at this point in the history
  • Loading branch information
Splines committed Sep 12, 2023
1 parent 87b366f commit fd5a930
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions db/migrate/20230912172632_create_has_seen_news_popups.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ def change
create_table :has_seen_news_popups do |t|
t.references :user, null: false, foreign_key: true
t.references :news_popup, null: false, foreign_key: true

t.timestamps
end

add_index :has_seen_news_popups, [:user, :news_popup], unique: true
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddIndexToHasSeenNewsPopups < ActiveRecord::Migration[7.0]
def change
add_index :has_seen_news_popups, [:user_id, :news_popup_id], unique: true
end
end
5 changes: 4 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.0].define(version: 2023_09_12_172632) do
ActiveRecord::Schema[7.0].define(version: 2023_09_12_193144) do
# These are extensions that must be enabled in order to support this database
enable_extension "pgcrypto"
enable_extension "plpgsql"
Expand Down Expand Up @@ -204,7 +204,10 @@
create_table "has_seen_news_popups", force: :cascade do |t|
t.bigint "user_id", null: false
t.bigint "news_popup_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["news_popup_id"], name: "index_has_seen_news_popups_on_news_popup_id"
t.index ["user_id", "news_popup_id"], name: "index_has_seen_news_popups_on_user_id_and_news_popup_id", unique: true
t.index ["user_id"], name: "index_has_seen_news_popups_on_user_id"
end

Expand Down

0 comments on commit fd5a930

Please sign in to comment.