2019-05-03 06:17:27 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-31 12:06:56 +08:00
|
|
|
class CreateActions < ActiveRecord::Migration[4.2]
|
2013-02-06 03:16:51 +08:00
|
|
|
def change
|
|
|
|
create_table :actions do |t|
|
|
|
|
|
2013-02-26 00:42:20 +08:00
|
|
|
# I elected for multiple ids as opposed to using :as cause it makes the table
|
2013-02-06 03:16:51 +08:00
|
|
|
# thinner, and the joining semantics much simpler (a simple multiple left join will do)
|
|
|
|
#
|
2021-04-24 00:25:10 +08:00
|
|
|
# There is a notification table as well that covers much of this,
|
2013-02-26 00:42:20 +08:00
|
|
|
# but this table is wider and is intended for non-notifying actions as well
|
|
|
|
|
2013-03-23 23:02:59 +08:00
|
|
|
t.integer :action_type, null: false
|
|
|
|
t.integer :user_id, null: false
|
2013-02-06 03:16:51 +08:00
|
|
|
t.integer :target_forum_thread_id
|
|
|
|
t.integer :target_post_id
|
|
|
|
t.integer :target_user_id
|
|
|
|
t.integer :acting_user_id
|
|
|
|
|
2017-08-07 23:48:36 +08:00
|
|
|
t.timestamps null: false
|
2013-02-06 03:16:51 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
add_index :actions, [:user_id, :action_type]
|
|
|
|
add_index :actions, [:acting_user_id]
|
|
|
|
end
|
|
|
|
end
|