Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2016-03-29 00:39:49 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2016-03-30 11:44:20 +0300
commit855b2820c16c6e569d5c38b7def8ead18c86cecd (patch)
tree350e7746b0e64c4994a85dd058b9e4af9c3acf3c /db
parent4ca73f56cb59b86f25b55ff02800571fb82c742f (diff)
Improve db migrations for notification settings
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20160328112808_create_notification_settings.rb7
-rw-r--r--db/migrate/20160328115649_migrate_new_notification_setting.rb2
-rw-r--r--db/schema.rb18
3 files changed, 13 insertions, 14 deletions
diff --git a/db/migrate/20160328112808_create_notification_settings.rb b/db/migrate/20160328112808_create_notification_settings.rb
index 88652821ac3..4755da8b806 100644
--- a/db/migrate/20160328112808_create_notification_settings.rb
+++ b/db/migrate/20160328112808_create_notification_settings.rb
@@ -1,10 +1,9 @@
class CreateNotificationSettings < ActiveRecord::Migration
def change
create_table :notification_settings do |t|
- t.integer :user_id
- t.integer :level
- t.integer :source_id
- t.string :source_type
+ t.references :user, null: false
+ t.references :source, polymorphic: true, null: false
+ t.integer :level, default: 0, null: false
t.timestamps null: false
end
diff --git a/db/migrate/20160328115649_migrate_new_notification_setting.rb b/db/migrate/20160328115649_migrate_new_notification_setting.rb
index 331c35535f2..aff866b5f46 100644
--- a/db/migrate/20160328115649_migrate_new_notification_setting.rb
+++ b/db/migrate/20160328115649_migrate_new_notification_setting.rb
@@ -4,7 +4,7 @@
class MigrateNewNotificationSetting < ActiveRecord::Migration
def up
timestamp = Time.now
- execute "INSERT INTO notification_settings ( user_id, source_id, source_type, level, created_at, updated_at ) SELECT user_id, source_id, source_type, notification_level, '#{timestamp}', '#{timestamp}' FROM members"
+ execute "INSERT INTO notification_settings ( user_id, source_id, source_type, level, created_at, updated_at ) SELECT user_id, source_id, source_type, notification_level, '#{timestamp}', '#{timestamp}' FROM members WHERE user_id IS NOT NULL"
end
def down
diff --git a/db/schema.rb b/db/schema.rb
index 29639abb6fc..e946ecd3f2b 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -639,12 +639,12 @@ ActiveRecord::Schema.define(version: 20160328121138) do
add_index "notes", ["updated_at"], name: "index_notes_on_updated_at", using: :btree
create_table "notification_settings", force: :cascade do |t|
- t.integer "user_id"
- t.integer "level"
- t.integer "source_id"
- t.string "source_type"
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ t.integer "user_id", null: false
+ t.integer "source_id", null: false
+ t.string "source_type", null: false
+ t.integer "level", default: 0, null: false
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
end
add_index "notification_settings", ["source_id", "source_type"], name: "index_notification_settings_on_source_id_and_source_type", using: :btree
@@ -798,9 +798,9 @@ ActiveRecord::Schema.define(version: 20160328121138) do
t.string "type"
t.string "title"
t.integer "project_id"
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
- t.boolean "active", null: false
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.boolean "active", default: false, null: false
t.text "properties"
t.boolean "template", default: false
t.boolean "push_events", default: true