summaryrefslogtreecommitdiff
path: root/db/migrate
diff options
context:
space:
mode:
Diffstat (limited to 'db/migrate')
-rw-r--r--db/migrate/20180515121227_create_notes_diff_files.rb21
-rw-r--r--db/migrate/20180524132016_merge_requests_target_id_iid_state_partial_index.rb27
-rw-r--r--db/migrate/20180529093006_ensure_remote_mirror_columns.rb24
3 files changed, 72 insertions, 0 deletions
diff --git a/db/migrate/20180515121227_create_notes_diff_files.rb b/db/migrate/20180515121227_create_notes_diff_files.rb
new file mode 100644
index 00000000000..7108bc1a64b
--- /dev/null
+++ b/db/migrate/20180515121227_create_notes_diff_files.rb
@@ -0,0 +1,21 @@
+class CreateNotesDiffFiles < ActiveRecord::Migration
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def change
+ create_table :note_diff_files do |t|
+ t.references :diff_note, references: :notes, null: false, index: { unique: true }
+ t.text :diff, null: false
+ t.boolean :new_file, null: false
+ t.boolean :renamed_file, null: false
+ t.boolean :deleted_file, null: false
+ t.string :a_mode, null: false
+ t.string :b_mode, null: false
+ t.text :new_path, null: false
+ t.text :old_path, null: false
+ end
+
+ add_foreign_key :note_diff_files, :notes, column: :diff_note_id, on_delete: :cascade
+ end
+end
diff --git a/db/migrate/20180524132016_merge_requests_target_id_iid_state_partial_index.rb b/db/migrate/20180524132016_merge_requests_target_id_iid_state_partial_index.rb
new file mode 100644
index 00000000000..cee576b91c8
--- /dev/null
+++ b/db/migrate/20180524132016_merge_requests_target_id_iid_state_partial_index.rb
@@ -0,0 +1,27 @@
+# See http://doc.gitlab.com/ce/development/migration_style_guide.html
+# for more information on how to write migrations for GitLab.
+
+class MergeRequestsTargetIdIidStatePartialIndex < ActiveRecord::Migration
+ include Gitlab::Database::MigrationHelpers
+
+ # Set this constant to true if this migration requires downtime.
+ DOWNTIME = false
+
+ INDEX_NAME = 'index_merge_requests_on_target_project_id_and_iid_opened'
+
+ disable_ddl_transaction!
+
+ def up
+ # On GitLab.com this index will take up roughly 5 MB of space.
+ add_concurrent_index(
+ :merge_requests,
+ [:target_project_id, :iid],
+ where: "state = 'opened'",
+ name: INDEX_NAME
+ )
+ end
+
+ def down
+ remove_concurrent_index_by_name(:merge_requests, INDEX_NAME)
+ end
+end
diff --git a/db/migrate/20180529093006_ensure_remote_mirror_columns.rb b/db/migrate/20180529093006_ensure_remote_mirror_columns.rb
new file mode 100644
index 00000000000..290416cb61c
--- /dev/null
+++ b/db/migrate/20180529093006_ensure_remote_mirror_columns.rb
@@ -0,0 +1,24 @@
+class EnsureRemoteMirrorColumns < ActiveRecord::Migration
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_column :remote_mirrors, :last_update_started_at, :datetime unless column_exists?(:remote_mirrors, :last_update_started_at)
+ add_column :remote_mirrors, :remote_name, :string unless column_exists?(:remote_mirrors, :remote_name)
+
+ unless column_exists?(:remote_mirrors, :only_protected_branches)
+ add_column_with_default(:remote_mirrors,
+ :only_protected_branches,
+ :boolean,
+ default: false,
+ allow_null: false)
+ end
+ end
+
+ def down
+ # db/migrate/20180503131624_create_remote_mirrors.rb will remove the table
+ end
+end