diff options
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20150313012111_create_subscribes_table.rb | 16 | ||||
-rw-r--r-- | db/migrate/20150313012111_create_subscriptions_table.rb | 13 | ||||
-rw-r--r-- | db/schema.rb | 10 |
3 files changed, 17 insertions, 22 deletions
diff --git a/db/migrate/20150313012111_create_subscribes_table.rb b/db/migrate/20150313012111_create_subscribes_table.rb deleted file mode 100644 index ab0e9a2a5b5..00000000000 --- a/db/migrate/20150313012111_create_subscribes_table.rb +++ /dev/null @@ -1,16 +0,0 @@ -class CreateSubscribesTable < ActiveRecord::Migration - def change - create_table :subscribes do |t| - t.integer :user_id - t.integer :merge_request_id - t.integer :issue_id - t.boolean :subscribed - - t.timestamps - end - - add_index :subscribes, :user_id - add_index :subscribes, :issue_id - add_index :subscribes, :merge_request_id - end -end diff --git a/db/migrate/20150313012111_create_subscriptions_table.rb b/db/migrate/20150313012111_create_subscriptions_table.rb new file mode 100644 index 00000000000..78f7aeeaf7c --- /dev/null +++ b/db/migrate/20150313012111_create_subscriptions_table.rb @@ -0,0 +1,13 @@ +class CreateSubscriptionsTable < ActiveRecord::Migration + def change + create_table :subscriptions do |t| + t.integer :user_id + t.references :subscribable, polymorphic: true + t.boolean :subscribed + + t.timestamps + end + + add_index :subscriptions, [:subscribable_id, :subscribable_type, :user_id], unique: true, name: 'subscriptions_user_id_and_ref_fields' + end +end diff --git a/db/schema.rb b/db/schema.rb index 46663ad495b..3f808d5ac3f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -397,18 +397,16 @@ ActiveRecord::Schema.define(version: 20150313012111) do add_index "snippets", ["project_id"], name: "index_snippets_on_project_id", using: :btree add_index "snippets", ["visibility_level"], name: "index_snippets_on_visibility_level", using: :btree - create_table "subscribes", force: true do |t| + create_table "subscriptions", force: true do |t| t.integer "user_id" - t.integer "merge_request_id" - t.integer "issue_id" + t.integer "subscribable_id" + t.string "subscribable_type" t.boolean "subscribed" t.datetime "created_at" t.datetime "updated_at" end - add_index "subscribes", ["issue_id"], name: "index_subscribes_on_issue_id", using: :btree - add_index "subscribes", ["merge_request_id"], name: "index_subscribes_on_merge_request_id", using: :btree - add_index "subscribes", ["user_id"], name: "index_subscribes_on_user_id", using: :btree + add_index "subscriptions", ["subscribable_id", "subscribable_type", "user_id"], name: "subscriptions_user_id_and_ref_fields", unique: true, using: :btree create_table "taggings", force: true do |t| t.integer "tag_id" |