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:
authorKamil Trzcinski <ayufan@ayufan.eu>2016-06-14 13:41:18 +0300
committerKamil Trzcinski <ayufan@ayufan.eu>2016-06-14 13:41:18 +0300
commit7d9e8b04c025278e26904e061e8b0a005cd81ab0 (patch)
tree82cf4b183228718d99fd8542104047450f5378b3 /db
parent672aec4a2da36d9ee755156be4a907f4b8d96347 (diff)
parent066020fcd015ca92397b794342a49a46dd02582c (diff)
Merge remote-tracking branch 'origin/master' into environments-and-deployments
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20160610140403_remove_notification_setting_not_null_constraints.rb11
-rw-r--r--db/migrate/20160610194713_remove_deprecated_issues_tracker_columns_from_projects.rb6
-rw-r--r--db/migrate/20160610201627_migrate_users_notification_level.rb21
-rw-r--r--db/migrate/20160610301627_remove_notification_level_from_users.rb7
-rw-r--r--db/schema.rb9
5 files changed, 48 insertions, 6 deletions
diff --git a/db/migrate/20160610140403_remove_notification_setting_not_null_constraints.rb b/db/migrate/20160610140403_remove_notification_setting_not_null_constraints.rb
new file mode 100644
index 00000000000..259abb08e47
--- /dev/null
+++ b/db/migrate/20160610140403_remove_notification_setting_not_null_constraints.rb
@@ -0,0 +1,11 @@
+class RemoveNotificationSettingNotNullConstraints < ActiveRecord::Migration
+ def up
+ change_column :notification_settings, :source_type, :string, null: true
+ change_column :notification_settings, :source_id, :integer, null: true
+ end
+
+ def down
+ change_column :notification_settings, :source_type, :string, null: false
+ change_column :notification_settings, :source_id, :integer, null: false
+ end
+end
diff --git a/db/migrate/20160610194713_remove_deprecated_issues_tracker_columns_from_projects.rb b/db/migrate/20160610194713_remove_deprecated_issues_tracker_columns_from_projects.rb
new file mode 100644
index 00000000000..477b2106dea
--- /dev/null
+++ b/db/migrate/20160610194713_remove_deprecated_issues_tracker_columns_from_projects.rb
@@ -0,0 +1,6 @@
+class RemoveDeprecatedIssuesTrackerColumnsFromProjects < ActiveRecord::Migration
+ def change
+ remove_column :projects, :issues_tracker, :string, default: 'gitlab', null: false
+ remove_column :projects, :issues_tracker_id, :string
+ end
+end
diff --git a/db/migrate/20160610201627_migrate_users_notification_level.rb b/db/migrate/20160610201627_migrate_users_notification_level.rb
new file mode 100644
index 00000000000..760b766828e
--- /dev/null
+++ b/db/migrate/20160610201627_migrate_users_notification_level.rb
@@ -0,0 +1,21 @@
+class MigrateUsersNotificationLevel < ActiveRecord::Migration
+ # Migrates only users who changed their default notification level :participating
+ # creating a new record on notification settings table
+
+ def up
+ execute(%Q{
+ INSERT INTO notification_settings
+ (user_id, level, created_at, updated_at)
+ (SELECT id, notification_level, created_at, updated_at FROM users WHERE notification_level != 1)
+ })
+ end
+
+ # Migrates from notification settings back to user notification_level
+ # If no value is found the default level of 1 will be used
+ def down
+ execute(%Q{
+ UPDATE users u SET
+ notification_level = COALESCE((SELECT level FROM notification_settings WHERE user_id = u.id AND source_type IS NULL), 1)
+ })
+ end
+end
diff --git a/db/migrate/20160610301627_remove_notification_level_from_users.rb b/db/migrate/20160610301627_remove_notification_level_from_users.rb
new file mode 100644
index 00000000000..8afb14df2cf
--- /dev/null
+++ b/db/migrate/20160610301627_remove_notification_level_from_users.rb
@@ -0,0 +1,7 @@
+class RemoveNotificationLevelFromUsers < ActiveRecord::Migration
+ include Gitlab::Database::MigrationHelpers
+
+ def change
+ remove_column :users, :notification_level, :integer
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 63df5efb879..cd6c087c847 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20160610211845) do
+ActiveRecord::Schema.define(version: 20160610301627) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -699,8 +699,8 @@ ActiveRecord::Schema.define(version: 20160610211845) do
create_table "notification_settings", force: :cascade do |t|
t.integer "user_id", null: false
- t.integer "source_id", null: false
- t.string "source_type", null: false
+ t.integer "source_id"
+ t.string "source_type"
t.integer "level", default: 0, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
@@ -780,8 +780,6 @@ ActiveRecord::Schema.define(version: 20160610211845) do
t.boolean "merge_requests_enabled", default: true, null: false
t.boolean "wiki_enabled", default: true, null: false
t.integer "namespace_id"
- t.string "issues_tracker", default: "gitlab", null: false
- t.string "issues_tracker_id"
t.boolean "snippets_enabled", default: true, null: false
t.datetime "last_activity_at"
t.string "import_url"
@@ -1017,7 +1015,6 @@ ActiveRecord::Schema.define(version: 20160610211845) do
t.boolean "can_create_team", default: true, null: false
t.string "state"
t.integer "color_scheme_id", default: 1, null: false
- t.integer "notification_level", default: 1, null: false
t.datetime "password_expires_at"
t.integer "created_by_id"
t.datetime "last_credential_check_at"