mirror of
https://github.com/discourse/discourse.git
synced 2026-08-10 04:58:31 -05:00
DEV: Use Single Table Inheritance in TopicTimer (#34530)
To prepare for the introduction of `CategoryDefaultTimer`, which allows posts created in certain categories to have a default `TopicTimer`, we first need to convert `TopicTimer` to use [Single Table Inheritance][STI]. [STI]: https://guides.rubyonrails.org/association_basics.html#single-table-inheritance-sti
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
# frozen_string_literal: true
|
||||
class AddTypeToTopicTimer < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
add_column :topic_timers, :type, :string, null: false, default: "TopicTimer"
|
||||
remove_index :topic_timers, name: :idx_topic_id_public_type_deleted_at
|
||||
add_index :topic_timers,
|
||||
:topic_id,
|
||||
unique: true,
|
||||
name: :idx_topic_id_public_type_deleted_at,
|
||||
where: "public_type = true AND deleted_at IS NULL AND type = 'TopicTimer'"
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user