diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2017-05-09 15:44:58 +0000 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2017-05-09 15:44:58 +0000 |
commit | acd031f61b6ca0f9733a064bc2ab4cf99acdaa40 (patch) | |
tree | d2bd4ae68d6bc72ffc0ebb7bfc74bbff33d73f29 /db/migrate | |
parent | b1ad5c186066f11c21ef165957f6e6c8350b4275 (diff) | |
parent | 388641ae8431686d4f101bd7b68453f9b64d6ee6 (diff) | |
download | gitlab-ce-acd031f61b6ca0f9733a064bc2ab4cf99acdaa40.tar.gz |
Merge branch 'master' into 'add-index-for-auto_canceled_by_id-mysql'
# Conflicts:
# db/schema.rb
Diffstat (limited to 'db/migrate')
7 files changed, 114 insertions, 0 deletions
diff --git a/db/migrate/20170425112128_create_pipeline_schedules_table.rb b/db/migrate/20170425112128_create_pipeline_schedules_table.rb new file mode 100644 index 00000000000..3612a796ae8 --- /dev/null +++ b/db/migrate/20170425112128_create_pipeline_schedules_table.rb @@ -0,0 +1,28 @@ +class CreatePipelineSchedulesTable < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def up + create_table :ci_pipeline_schedules do |t| + t.string :description + t.string :ref + t.string :cron + t.string :cron_timezone + t.datetime :next_run_at + t.integer :project_id + t.integer :owner_id + t.boolean :active, default: true + t.datetime :deleted_at + + t.timestamps + end + + add_index(:ci_pipeline_schedules, :project_id) + add_index(:ci_pipeline_schedules, [:next_run_at, :active]) + end + + def down + drop_table :ci_pipeline_schedules + end +end diff --git a/db/migrate/20170425112628_remove_foreigh_key_ci_trigger_schedules.rb b/db/migrate/20170425112628_remove_foreigh_key_ci_trigger_schedules.rb new file mode 100644 index 00000000000..6116ca59ee4 --- /dev/null +++ b/db/migrate/20170425112628_remove_foreigh_key_ci_trigger_schedules.rb @@ -0,0 +1,13 @@ +class RemoveForeighKeyCiTriggerSchedules < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def up + remove_foreign_key :ci_trigger_schedules, column: :trigger_id + end + + def down + # no op, the foreign key should not have been here + end +end diff --git a/db/migrate/20170425114731_add_pipeline_schedule_id_to_pipelines.rb b/db/migrate/20170425114731_add_pipeline_schedule_id_to_pipelines.rb new file mode 100644 index 00000000000..ddb27d4dc81 --- /dev/null +++ b/db/migrate/20170425114731_add_pipeline_schedule_id_to_pipelines.rb @@ -0,0 +1,9 @@ +class AddPipelineScheduleIdToPipelines < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def change + add_column :ci_pipelines, :pipeline_schedule_id, :integer + end +end diff --git a/db/migrate/20170506085040_add_index_to_pipeline_pipeline_schedule_id.rb b/db/migrate/20170506085040_add_index_to_pipeline_pipeline_schedule_id.rb new file mode 100644 index 00000000000..08a7f3fc9ab --- /dev/null +++ b/db/migrate/20170506085040_add_index_to_pipeline_pipeline_schedule_id.rb @@ -0,0 +1,19 @@ +class AddIndexToPipelinePipelineScheduleId < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + unless index_exists?(:ci_pipelines, :pipeline_schedule_id) + add_concurrent_index(:ci_pipelines, :pipeline_schedule_id) + end + end + + def down + if index_exists?(:ci_pipelines, :pipeline_schedule_id) + remove_concurrent_index(:ci_pipelines, :pipeline_schedule_id) + end + end +end diff --git a/db/migrate/20170506091344_add_foreign_key_to_pipeline_schedules.rb b/db/migrate/20170506091344_add_foreign_key_to_pipeline_schedules.rb new file mode 100644 index 00000000000..7f2dba702af --- /dev/null +++ b/db/migrate/20170506091344_add_foreign_key_to_pipeline_schedules.rb @@ -0,0 +1,15 @@ +class AddForeignKeyToPipelineSchedules < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_foreign_key :ci_pipeline_schedules, :projects, column: :project_id + end + + def down + remove_foreign_key :ci_pipeline_schedules, :projects + end +end diff --git a/db/migrate/20170506185517_add_foreign_key_pipeline_schedules_and_pipelines.rb b/db/migrate/20170506185517_add_foreign_key_pipeline_schedules_and_pipelines.rb new file mode 100644 index 00000000000..55bf40ba24d --- /dev/null +++ b/db/migrate/20170506185517_add_foreign_key_pipeline_schedules_and_pipelines.rb @@ -0,0 +1,23 @@ +class AddForeignKeyPipelineSchedulesAndPipelines < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + on_delete = + if Gitlab::Database.mysql? + :nullify + else + 'SET NULL' + end + + add_concurrent_foreign_key :ci_pipelines, :ci_pipeline_schedules, + column: :pipeline_schedule_id, on_delete: on_delete + end + + def down + remove_foreign_key :ci_pipelines, column: :pipeline_schedule_id + end +end diff --git a/db/migrate/20170507205316_add_head_pipeline_id_to_merge_requests.rb b/db/migrate/20170507205316_add_head_pipeline_id_to_merge_requests.rb new file mode 100644 index 00000000000..8fc6e380a77 --- /dev/null +++ b/db/migrate/20170507205316_add_head_pipeline_id_to_merge_requests.rb @@ -0,0 +1,7 @@ +class AddHeadPipelineIdToMergeRequests < ActiveRecord::Migration + DOWNTIME = false + + def change + add_column :merge_requests, :head_pipeline_id, :integer + end +end |