mirror of
https://github.com/discourse/discourse.git
synced 2024-12-03 13:33:45 +08:00
e21c640a3c
We are planning on attaching bookmarks to more and more other models, so it makes sense to make a polymorphic relationship to handle this. This commit adds the new columns and backfills them in the bookmark table, and makes sure that any new bookmark changes fill in the columns via DB triggers. This way we can gradually change the frontend and backend to use these new columns, and eventually delete the old post_id and for_topic columns in `bookmarks`.
11 lines
367 B
Ruby
11 lines
367 B
Ruby
# frozen_string_literal: true
|
|
|
|
class AddBookmarkPolymorphicColumns < ActiveRecord::Migration[6.1]
|
|
def change
|
|
add_column :bookmarks, :bookmarkable_id, :integer
|
|
add_column :bookmarks, :bookmarkable_type, :string
|
|
|
|
add_index :bookmarks, [:user_id, :bookmarkable_type, :bookmarkable_id], name: "idx_bookmarks_user_polymorphic_unique", unique: true
|
|
end
|
|
end
|