summaryrefslogtreecommitdiff
path: root/db/migrate
diff options
context:
space:
mode:
Diffstat (limited to 'db/migrate')
-rw-r--r--db/migrate/20130218141258_convert_closed_to_state_in_issue.rb18
-rw-r--r--db/migrate/20130218141327_convert_closed_to_state_in_merge_request.rb22
-rw-r--r--db/migrate/20130218141344_convert_closed_to_state_in_milestone.rb18
-rw-r--r--db/migrate/20130220125544_convert_merge_status_in_merge_request.rb22
-rw-r--r--db/migrate/20130315124931_user_color_scheme.rb4
-rw-r--r--db/migrate/20130403003950_add_last_activity_column_into_project.rb16
-rw-r--r--db/migrate/20130419190306_allow_merges_for_forks.rb8
-rw-r--r--db/migrate/20131112220935_add_visibility_level_to_projects.rb6
-rw-r--r--db/migrate/20140313092127_migrate_already_imported_projects.rb8
-rw-r--r--db/migrate/20141007100818_add_visibility_level_to_snippet.rb14
-rw-r--r--db/migrate/20160302151724_add_import_credentials_to_project_import_data.rb7
-rw-r--r--db/migrate/20160302152808_remove_wrong_import_url_from_projects.rb131
-rw-r--r--db/migrate/20160315135439_project_add_repository_check.rb8
-rw-r--r--db/migrate/20160324020319_remove_todos_for_deleted_issues.rb17
-rw-r--r--db/migrate/20160328112808_create_notification_settings.rb11
-rw-r--r--db/migrate/20160328115649_migrate_new_notification_setting.rb17
-rw-r--r--db/migrate/20160328121138_add_notification_setting_index.rb6
-rw-r--r--db/migrate/20160329144452_add_index_on_pending_delete_projects.rb6
-rw-r--r--db/migrate/20160331133914_remove_todos_for_deleted_merge_requests.rb17
-rw-r--r--db/migrate/20160331223143_remove_twitter_sharing_enabled_from_application_settings.rb5
-rw-r--r--db/migrate/20160412140240_add_repository_checks_enabled_setting.rb5
21 files changed, 313 insertions, 53 deletions
diff --git a/db/migrate/20130218141258_convert_closed_to_state_in_issue.rb b/db/migrate/20130218141258_convert_closed_to_state_in_issue.rb
index 9fa96203ffd..99289166e81 100644
--- a/db/migrate/20130218141258_convert_closed_to_state_in_issue.rb
+++ b/db/migrate/20130218141258_convert_closed_to_state_in_issue.rb
@@ -1,14 +1,18 @@
class ConvertClosedToStateInIssue < ActiveRecord::Migration
+ include Gitlab::Database
+
def up
- Issue.transaction do
- Issue.where(closed: true).update_all(state: :closed)
- Issue.where(closed: false).update_all(state: :opened)
- end
+ execute "UPDATE #{table_name} SET state = 'closed' WHERE closed = #{true_value}"
+ execute "UPDATE #{table_name} SET state = 'opened' WHERE closed = #{false_value}"
end
def down
- Issue.transaction do
- Issue.where(state: :closed).update_all(closed: true)
- end
+ execute "UPDATE #{table_name} SET closed = #{true_value} WHERE state = 'closed'"
+ end
+
+ private
+
+ def table_name
+ Issue.table_name
end
end
diff --git a/db/migrate/20130218141327_convert_closed_to_state_in_merge_request.rb b/db/migrate/20130218141327_convert_closed_to_state_in_merge_request.rb
index ebb7ae585e6..bd1e016d679 100644
--- a/db/migrate/20130218141327_convert_closed_to_state_in_merge_request.rb
+++ b/db/migrate/20130218141327_convert_closed_to_state_in_merge_request.rb
@@ -1,16 +1,20 @@
class ConvertClosedToStateInMergeRequest < ActiveRecord::Migration
+ include Gitlab::Database
+
def up
- MergeRequest.transaction do
- MergeRequest.where(closed: true, merged: true).update_all(state: :merged)
- MergeRequest.where(closed: true, merged: false).update_all(state: :closed)
- MergeRequest.where(closed: false).update_all(state: :opened)
- end
+ execute "UPDATE #{table_name} SET state = 'merged' WHERE closed = #{true_value} AND merged = #{true_value}"
+ execute "UPDATE #{table_name} SET state = 'closed' WHERE closed = #{true_value} AND merged = #{false_value}"
+ execute "UPDATE #{table_name} SET state = 'opened' WHERE closed = #{false_value}"
end
def down
- MergeRequest.transaction do
- MergeRequest.where(state: :closed).update_all(closed: true)
- MergeRequest.where(state: :merged).update_all(closed: true, merged: true)
- end
+ execute "UPDATE #{table_name} SET closed = #{true_value} WHERE state = 'closed'"
+ execute "UPDATE #{table_name} SET closed = #{true_value}, merged = #{true_value} WHERE state = 'merged'"
+ end
+
+ private
+
+ def table_name
+ MergeRequest.table_name
end
end
diff --git a/db/migrate/20130218141344_convert_closed_to_state_in_milestone.rb b/db/migrate/20130218141344_convert_closed_to_state_in_milestone.rb
index 1978ea89153..d1174bc3d98 100644
--- a/db/migrate/20130218141344_convert_closed_to_state_in_milestone.rb
+++ b/db/migrate/20130218141344_convert_closed_to_state_in_milestone.rb
@@ -1,14 +1,18 @@
class ConvertClosedToStateInMilestone < ActiveRecord::Migration
+ include Gitlab::Database
+
def up
- Milestone.transaction do
- Milestone.where(closed: true).update_all(state: :closed)
- Milestone.where(closed: false).update_all(state: :active)
- end
+ execute "UPDATE #{table_name} SET state = 'closed' WHERE closed = #{true_value}"
+ execute "UPDATE #{table_name} SET state = 'active' WHERE closed = #{false_value}"
end
def down
- Milestone.transaction do
- Milestone.where(state: :closed).update_all(closed: true)
- end
+ execute "UPDATE #{table_name} SET closed = #{true_value} WHERE state = 'cloesd'"
+ end
+
+ private
+
+ def table_name
+ Milestone.table_name
end
end
diff --git a/db/migrate/20130220125544_convert_merge_status_in_merge_request.rb b/db/migrate/20130220125544_convert_merge_status_in_merge_request.rb
index b310b35e373..1c758c56ffe 100644
--- a/db/migrate/20130220125544_convert_merge_status_in_merge_request.rb
+++ b/db/migrate/20130220125544_convert_merge_status_in_merge_request.rb
@@ -1,17 +1,19 @@
class ConvertMergeStatusInMergeRequest < ActiveRecord::Migration
def up
- MergeRequest.transaction do
- MergeRequest.where(merge_status: 1).update_all("new_merge_status = 'unchecked'")
- MergeRequest.where(merge_status: 2).update_all("new_merge_status = 'can_be_merged'")
- MergeRequest.where(merge_status: 3).update_all("new_merge_status = 'cannot_be_merged'")
- end
+ execute "UPDATE #{table_name} SET new_merge_status = 'unchecked' WHERE merge_status = 1"
+ execute "UPDATE #{table_name} SET new_merge_status = 'can_be_merged' WHERE merge_status = 2"
+ execute "UPDATE #{table_name} SET new_merge_status = 'cannot_be_merged' WHERE merge_status = 3"
end
def down
- MergeRequest.transaction do
- MergeRequest.where(new_merge_status: :unchecked).update_all("merge_status = 1")
- MergeRequest.where(new_merge_status: :can_be_merged).update_all("merge_status = 2")
- MergeRequest.where(new_merge_status: :cannot_be_merged).update_all("merge_status = 3")
- end
+ execute "UPDATE #{table_name} SET merge_status = 1 WHERE new_merge_status = 'unchecked'"
+ execute "UPDATE #{table_name} SET merge_status = 2 WHERE new_merge_status = 'can_be_merged'"
+ execute "UPDATE #{table_name} SET merge_status = 3 WHERE new_merge_status = 'cannot_be_merged'"
+ end
+
+ private
+
+ def table_name
+ MergeRequest.table_name
end
end
diff --git a/db/migrate/20130315124931_user_color_scheme.rb b/db/migrate/20130315124931_user_color_scheme.rb
index fe139e32ea7..56c9a31ee3c 100644
--- a/db/migrate/20130315124931_user_color_scheme.rb
+++ b/db/migrate/20130315124931_user_color_scheme.rb
@@ -1,7 +1,9 @@
class UserColorScheme < ActiveRecord::Migration
+ include Gitlab::Database
+
def up
add_column :users, :color_scheme_id, :integer, null: false, default: 1
- User.where(dark_scheme: true).update_all(color_scheme_id: 2)
+ execute("UPDATE users SET color_scheme_id = 2 WHERE dark_scheme = #{true_value}")
remove_column :users, :dark_scheme
end
diff --git a/db/migrate/20130403003950_add_last_activity_column_into_project.rb b/db/migrate/20130403003950_add_last_activity_column_into_project.rb
index 2a036bd9993..85e31608d79 100644
--- a/db/migrate/20130403003950_add_last_activity_column_into_project.rb
+++ b/db/migrate/20130403003950_add_last_activity_column_into_project.rb
@@ -3,14 +3,16 @@ class AddLastActivityColumnIntoProject < ActiveRecord::Migration
add_column :projects, :last_activity_at, :datetime
add_index :projects, :last_activity_at
- Project.find_each do |project|
- last_activity_date = if project.last_activity
- project.last_activity.created_at
- else
- project.updated_at
- end
+ select_all('SELECT id, updated_at FROM projects').each do |project|
+ project_id = project['id']
+ update_date = project['updated_at']
+ event = select_one("SELECT created_at FROM events WHERE project_id = #{project_id} ORDER BY created_at DESC LIMIT 1")
- project.update_attribute(:last_activity_at, last_activity_date)
+ if event && event['created_at']
+ update_date = event['created_at']
+ end
+
+ execute("UPDATE projects SET last_activity_at = '#{update_date}' WHERE id = #{project_id}")
end
end
diff --git a/db/migrate/20130419190306_allow_merges_for_forks.rb b/db/migrate/20130419190306_allow_merges_for_forks.rb
index 56ce58a846d..56ea97e8561 100644
--- a/db/migrate/20130419190306_allow_merges_for_forks.rb
+++ b/db/migrate/20130419190306_allow_merges_for_forks.rb
@@ -1,7 +1,7 @@
class AllowMergesForForks < ActiveRecord::Migration
def self.up
add_column :merge_requests, :target_project_id, :integer, :null => true
- MergeRequest.update_all("target_project_id = project_id")
+ execute "UPDATE #{table_name} SET target_project_id = project_id"
change_column :merge_requests, :target_project_id, :integer, :null => false
rename_column :merge_requests, :project_id, :source_project_id
end
@@ -10,4 +10,10 @@ class AllowMergesForForks < ActiveRecord::Migration
remove_column :merge_requests, :target_project_id
rename_column :merge_requests, :source_project_id,:project_id
end
+
+ private
+
+ def table_name
+ MergeRequest.table_name
+ end
end
diff --git a/db/migrate/20131112220935_add_visibility_level_to_projects.rb b/db/migrate/20131112220935_add_visibility_level_to_projects.rb
index cf1e9f912a0..89421cbedad 100644
--- a/db/migrate/20131112220935_add_visibility_level_to_projects.rb
+++ b/db/migrate/20131112220935_add_visibility_level_to_projects.rb
@@ -1,13 +1,15 @@
class AddVisibilityLevelToProjects < ActiveRecord::Migration
+ include Gitlab::Database
+
def self.up
add_column :projects, :visibility_level, :integer, :default => 0, :null => false
- Project.where(public: true).update_all(visibility_level: Gitlab::VisibilityLevel::PUBLIC)
+ execute("UPDATE projects SET visibility_level = #{Gitlab::VisibilityLevel::PUBLIC} WHERE public = #{true_value}")
remove_column :projects, :public
end
def self.down
add_column :projects, :public, :boolean, :default => false, :null => false
- Project.where(visibility_level: Gitlab::VisibilityLevel::PUBLIC).update_all(public: true)
+ execute("UPDATE projects SET public = #{true_value} WHERE visibility_level = #{Gitlab::VisibilityLevel::PUBLIC}")
remove_column :projects, :visibility_level
end
end
diff --git a/db/migrate/20140313092127_migrate_already_imported_projects.rb b/db/migrate/20140313092127_migrate_already_imported_projects.rb
index f4392c0f05e..0a9f73a5758 100644
--- a/db/migrate/20140313092127_migrate_already_imported_projects.rb
+++ b/db/migrate/20140313092127_migrate_already_imported_projects.rb
@@ -1,12 +1,14 @@
class MigrateAlreadyImportedProjects < ActiveRecord::Migration
+ include Gitlab::Database
+
def up
- Project.where(imported: true).update_all(import_status: "finished")
- Project.where(imported: false).update_all(import_status: "none")
+ execute("UPDATE projects SET import_status = 'finished' WHERE imported = #{true_value}")
+ execute("UPDATE projects SET import_status = 'none' WHERE imported = #{false_value}")
remove_column :projects, :imported
end
def down
add_column :projects, :imported, :boolean, default: false
- Project.where(import_status: 'finished').update_all(imported: true)
+ execute("UPDATE projects SET imported = #{true_value} WHERE import_status = 'finished'")
end
end
diff --git a/db/migrate/20141007100818_add_visibility_level_to_snippet.rb b/db/migrate/20141007100818_add_visibility_level_to_snippet.rb
index 7f125acb5d1..93826185e8b 100644
--- a/db/migrate/20141007100818_add_visibility_level_to_snippet.rb
+++ b/db/migrate/20141007100818_add_visibility_level_to_snippet.rb
@@ -1,9 +1,11 @@
class AddVisibilityLevelToSnippet < ActiveRecord::Migration
+ include Gitlab::Database
+
def up
add_column :snippets, :visibility_level, :integer, :default => 0, :null => false
- Snippet.where(private: true).update_all(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
- Snippet.where(private: false).update_all(visibility_level: Gitlab::VisibilityLevel::INTERNAL)
+ execute("UPDATE snippets SET visibility_level = #{Gitlab::VisibilityLevel::PRIVATE} WHERE private = #{true_value}")
+ execute("UPDATE snippets SET visibility_level = #{Gitlab::VisibilityLevel::INTERNAL} WHERE private = #{false_value}")
add_index :snippets, :visibility_level
@@ -12,10 +14,10 @@ class AddVisibilityLevelToSnippet < ActiveRecord::Migration
def down
add_column :snippets, :private, :boolean, :default => false, :null => false
-
- Snippet.where(visibility_level: Gitlab::VisibilityLevel::INTERNAL).update_all(private: false)
- Snippet.where(visibility_level: Gitlab::VisibilityLevel::PRIVATE).update_all(private: true)
-
+
+ execute("UPDATE snippets SET private = #{false_value} WHERE visibility_level = #{Gitlab::VisibilityLevel::INTERNAL}")
+ execute("UPDATE snippets SET private = #{true_value} WHERE visibility_level = #{Gitlab::VisibilityLevel::PRIVATE}")
+
remove_column :snippets, :visibility_level
end
end
diff --git a/db/migrate/20160302151724_add_import_credentials_to_project_import_data.rb b/db/migrate/20160302151724_add_import_credentials_to_project_import_data.rb
new file mode 100644
index 00000000000..ffcd64266e3
--- /dev/null
+++ b/db/migrate/20160302151724_add_import_credentials_to_project_import_data.rb
@@ -0,0 +1,7 @@
+class AddImportCredentialsToProjectImportData < ActiveRecord::Migration
+ def change
+ add_column :project_import_data, :encrypted_credentials, :text
+ add_column :project_import_data, :encrypted_credentials_iv, :string
+ add_column :project_import_data, :encrypted_credentials_salt, :string
+ end
+end
diff --git a/db/migrate/20160302152808_remove_wrong_import_url_from_projects.rb b/db/migrate/20160302152808_remove_wrong_import_url_from_projects.rb
new file mode 100644
index 00000000000..8a351cf27a3
--- /dev/null
+++ b/db/migrate/20160302152808_remove_wrong_import_url_from_projects.rb
@@ -0,0 +1,131 @@
+# Loops through old importer projects that kept a token/password in the import URL
+# and encrypts the credentials into a separate field in project#import_data
+# #down method not supported
+class RemoveWrongImportUrlFromProjects < ActiveRecord::Migration
+
+ class ProjectImportDataFake
+ extend AttrEncrypted
+ attr_accessor :credentials
+ attr_encrypted :credentials, key: Gitlab::Application.secrets.db_key_base, marshal: true, encode: true, :mode => :per_attribute_iv_and_salt
+ end
+
+ def up
+ say("Encrypting and migrating project import credentials...")
+
+ # This should cover GitHub, GitLab, Bitbucket user:password, token@domain, and other similar URLs.
+ in_transaction(message: "Projects including GitHub and GitLab projects with an unsecured URL.") { process_projects_with_wrong_url }
+
+ in_transaction(message: "Migrating Bitbucket credentials...") { process_project(import_type: 'bitbucket', credentials_keys: ['bb_session']) }
+
+ in_transaction(message: "Migrating FogBugz credentials...") { process_project(import_type: 'fogbugz', credentials_keys: ['fb_session']) }
+
+ end
+
+ def process_projects_with_wrong_url
+ projects_with_wrong_import_url.each do |project|
+ begin
+ import_url = Gitlab::ImportUrl.new(project["import_url"])
+
+ update_import_url(import_url, project)
+ update_import_data(import_url, project)
+ rescue URI::InvalidURIError
+ nullify_import_url(project)
+ end
+ end
+ end
+
+ def process_project(import_type:, credentials_keys: [])
+ unencrypted_import_data(import_type: import_type).each do |data|
+ replace_data_credentials(data, credentials_keys)
+ end
+ end
+
+ def replace_data_credentials(data, credentials_keys)
+ data_hash = JSON.load(data['data']) if data['data']
+ unless data_hash.blank?
+ encrypted_data_hash = encrypt_data(data_hash, credentials_keys)
+ unencrypted_data = data_hash.empty? ? ' NULL ' : quote(data_hash.to_json)
+ update_with_encrypted_data(encrypted_data_hash, data['id'], unencrypted_data)
+ end
+ end
+
+ def encrypt_data(data_hash, credentials_keys)
+ new_data_hash = {}
+ credentials_keys.each do |key|
+ new_data_hash[key.to_sym] = data_hash.delete(key) if data_hash[key]
+ end
+ new_data_hash.deep_symbolize_keys
+ end
+
+ def in_transaction(message:)
+ say_with_time(message) do
+ ActiveRecord::Base.transaction do
+ yield
+ end
+ end
+ end
+
+ def update_import_data(import_url, project)
+ fake_import_data = ProjectImportDataFake.new
+ fake_import_data.credentials = import_url.credentials
+ import_data_id = project['import_data_id']
+ if import_data_id
+ execute(update_import_data_sql(import_data_id, fake_import_data))
+ else
+ execute(insert_import_data_sql(project['id'], fake_import_data))
+ end
+ end
+
+ def update_with_encrypted_data(data_hash, import_data_id, unencrypted_data = ' NULL ')
+ fake_import_data = ProjectImportDataFake.new
+ fake_import_data.credentials = data_hash
+ execute(update_import_data_sql(import_data_id, fake_import_data, unencrypted_data))
+ end
+
+ def update_import_url(import_url, project)
+ execute("UPDATE projects SET import_url = #{quote(import_url.sanitized_url)} WHERE id = #{project['id']}")
+ end
+
+ def nullify_import_url(project)
+ execute("UPDATE projects SET import_url = NULL WHERE id = #{project['id']}")
+ end
+
+ def insert_import_data_sql(project_id, fake_import_data)
+ %(
+ INSERT INTO project_import_data
+ (encrypted_credentials,
+ project_id,
+ encrypted_credentials_iv,
+ encrypted_credentials_salt)
+ VALUES ( #{quote(fake_import_data.encrypted_credentials)},
+ '#{project_id}',
+ #{quote(fake_import_data.encrypted_credentials_iv)},
+ #{quote(fake_import_data.encrypted_credentials_salt)})
+ ).squish
+ end
+
+ def update_import_data_sql(id, fake_import_data, data = 'NULL')
+ %(
+ UPDATE project_import_data
+ SET encrypted_credentials = #{quote(fake_import_data.encrypted_credentials)},
+ encrypted_credentials_iv = #{quote(fake_import_data.encrypted_credentials_iv)},
+ encrypted_credentials_salt = #{quote(fake_import_data.encrypted_credentials_salt)},
+ data = #{data}
+ WHERE id = '#{id}'
+ ).squish
+ end
+
+ #GitHub projects with token, and any user:password@ based URL
+ def projects_with_wrong_import_url
+ select_all("SELECT p.id, p.import_url, i.id as import_data_id FROM projects p LEFT JOIN project_import_data i on p.id = i.project_id WHERE p.import_url <> '' AND p.import_url LIKE '%//%@%'")
+ end
+
+ # All imports with data for import_type
+ def unencrypted_import_data(import_type: )
+ select_all("SELECT i.id, p.import_url, i.data FROM projects p INNER JOIN project_import_data i ON p.id = i.project_id WHERE p.import_url <> '' AND p.import_type = '#{import_type}' ")
+ end
+
+ def quote(value)
+ ActiveRecord::Base.connection.quote(value)
+ end
+end
diff --git a/db/migrate/20160315135439_project_add_repository_check.rb b/db/migrate/20160315135439_project_add_repository_check.rb
new file mode 100644
index 00000000000..8687d5d6296
--- /dev/null
+++ b/db/migrate/20160315135439_project_add_repository_check.rb
@@ -0,0 +1,8 @@
+class ProjectAddRepositoryCheck < ActiveRecord::Migration
+ def change
+ add_column :projects, :last_repository_check_failed, :boolean
+ add_index :projects, :last_repository_check_failed
+
+ add_column :projects, :last_repository_check_at, :datetime
+ end
+end
diff --git a/db/migrate/20160324020319_remove_todos_for_deleted_issues.rb b/db/migrate/20160324020319_remove_todos_for_deleted_issues.rb
new file mode 100644
index 00000000000..1fff9759d1e
--- /dev/null
+++ b/db/migrate/20160324020319_remove_todos_for_deleted_issues.rb
@@ -0,0 +1,17 @@
+class RemoveTodosForDeletedIssues < ActiveRecord::Migration
+ def up
+ execute <<-SQL
+ DELETE FROM todos
+ WHERE todos.target_type = 'Issue'
+ AND NOT EXISTS (
+ SELECT *
+ FROM issues
+ WHERE issues.id = todos.target_id
+ AND issues.deleted_at IS NULL
+ )
+ SQL
+ end
+
+ def down
+ end
+end
diff --git a/db/migrate/20160328112808_create_notification_settings.rb b/db/migrate/20160328112808_create_notification_settings.rb
new file mode 100644
index 00000000000..4755da8b806
--- /dev/null
+++ b/db/migrate/20160328112808_create_notification_settings.rb
@@ -0,0 +1,11 @@
+class CreateNotificationSettings < ActiveRecord::Migration
+ def change
+ create_table :notification_settings do |t|
+ t.references :user, null: false
+ t.references :source, polymorphic: true, null: false
+ t.integer :level, default: 0, null: false
+
+ t.timestamps null: false
+ end
+ end
+end
diff --git a/db/migrate/20160328115649_migrate_new_notification_setting.rb b/db/migrate/20160328115649_migrate_new_notification_setting.rb
new file mode 100644
index 00000000000..3c81b2c37bf
--- /dev/null
+++ b/db/migrate/20160328115649_migrate_new_notification_setting.rb
@@ -0,0 +1,17 @@
+# This migration will create one row of NotificationSetting for each Member row
+# It can take long time on big instances.
+#
+# This migration can be done online but with following effects:
+# - during migration some users will receive notifications based on their global settings (project/group settings will be ignored)
+# - its possible to get duplicate records for notification settings since we don't create uniq index yet
+#
+class MigrateNewNotificationSetting < ActiveRecord::Migration
+ def up
+ timestamp = Time.now.strftime('%F %T')
+ 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
+ execute "DELETE FROM notification_settings"
+ end
+end
diff --git a/db/migrate/20160328121138_add_notification_setting_index.rb b/db/migrate/20160328121138_add_notification_setting_index.rb
new file mode 100644
index 00000000000..8aebce0244d
--- /dev/null
+++ b/db/migrate/20160328121138_add_notification_setting_index.rb
@@ -0,0 +1,6 @@
+class AddNotificationSettingIndex < ActiveRecord::Migration
+ def change
+ add_index :notification_settings, :user_id
+ add_index :notification_settings, [:source_id, :source_type]
+ end
+end
diff --git a/db/migrate/20160329144452_add_index_on_pending_delete_projects.rb b/db/migrate/20160329144452_add_index_on_pending_delete_projects.rb
new file mode 100644
index 00000000000..275554e736e
--- /dev/null
+++ b/db/migrate/20160329144452_add_index_on_pending_delete_projects.rb
@@ -0,0 +1,6 @@
+class AddIndexOnPendingDeleteProjects < ActiveRecord::Migration
+ def change
+ add_index :projects, :pending_delete
+ end
+end
+
diff --git a/db/migrate/20160331133914_remove_todos_for_deleted_merge_requests.rb b/db/migrate/20160331133914_remove_todos_for_deleted_merge_requests.rb
new file mode 100644
index 00000000000..54cea964ff2
--- /dev/null
+++ b/db/migrate/20160331133914_remove_todos_for_deleted_merge_requests.rb
@@ -0,0 +1,17 @@
+class RemoveTodosForDeletedMergeRequests < ActiveRecord::Migration
+ def up
+ execute <<-SQL
+ DELETE FROM todos
+ WHERE todos.target_type = 'MergeRequest'
+ AND NOT EXISTS (
+ SELECT *
+ FROM merge_requests
+ WHERE merge_requests.id = todos.target_id
+ AND merge_requests.deleted_at IS NULL
+ )
+ SQL
+ end
+
+ def down
+ end
+end
diff --git a/db/migrate/20160331223143_remove_twitter_sharing_enabled_from_application_settings.rb b/db/migrate/20160331223143_remove_twitter_sharing_enabled_from_application_settings.rb
new file mode 100644
index 00000000000..0d736e323b6
--- /dev/null
+++ b/db/migrate/20160331223143_remove_twitter_sharing_enabled_from_application_settings.rb
@@ -0,0 +1,5 @@
+class RemoveTwitterSharingEnabledFromApplicationSettings < ActiveRecord::Migration
+ def change
+ remove_column :application_settings, :twitter_sharing_enabled, :boolean
+ end
+end
diff --git a/db/migrate/20160412140240_add_repository_checks_enabled_setting.rb b/db/migrate/20160412140240_add_repository_checks_enabled_setting.rb
new file mode 100644
index 00000000000..ebfa4bcbc7b
--- /dev/null
+++ b/db/migrate/20160412140240_add_repository_checks_enabled_setting.rb
@@ -0,0 +1,5 @@
+class AddRepositoryChecksEnabledSetting < ActiveRecord::Migration
+ def change
+ add_column :application_settings, :repository_checks_enabled, :boolean, default: true
+ end
+end