diff options
author | Zeger-Jan van de Weg <zegerjan@gitlab.com> | 2017-05-08 01:35:56 +0300 |
---|---|---|
committer | Kamil TrzciĆski <ayufan@ayufan.eu> | 2017-05-08 01:35:56 +0300 |
commit | 8df3997a92bffa2d29f3c559933a336b837cdb93 (patch) | |
tree | 5ee50876b35b6c5fd40607665f72468cfcee51fe /db/post_migrate | |
parent | 8a0cde81feb3c8f3af26eefa5cef7b72eda2d266 (diff) |
Add Pipeline Schedules that supersedes experimental Trigger Schedule
Diffstat (limited to 'db/post_migrate')
-rw-r--r-- | db/post_migrate/20170425121605_migrate_trigger_schedules_to_pipeline_schedules.rb | 41 | ||||
-rw-r--r-- | db/post_migrate/20170425130047_drop_ci_trigger_schedules_table.rb | 32 |
2 files changed, 73 insertions, 0 deletions
diff --git a/db/post_migrate/20170425121605_migrate_trigger_schedules_to_pipeline_schedules.rb b/db/post_migrate/20170425121605_migrate_trigger_schedules_to_pipeline_schedules.rb new file mode 100644 index 00000000000..a44b399c4de --- /dev/null +++ b/db/post_migrate/20170425121605_migrate_trigger_schedules_to_pipeline_schedules.rb @@ -0,0 +1,41 @@ +class MigrateTriggerSchedulesToPipelineSchedules < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def up + connection.execute <<-SQL + INSERT INTO ci_pipeline_schedules ( + project_id, + created_at, + updated_at, + deleted_at, + cron, + cron_timezone, + next_run_at, + ref, + active, + owner_id, + description + ) + SELECT + ci_trigger_schedules.project_id, + ci_trigger_schedules.created_at, + ci_trigger_schedules.updated_at, + ci_trigger_schedules.deleted_at, + ci_trigger_schedules.cron, + ci_trigger_schedules.cron_timezone, + ci_trigger_schedules.next_run_at, + ci_trigger_schedules.ref, + ci_trigger_schedules.active, + ci_triggers.owner_id, + ci_triggers.description + FROM ci_trigger_schedules + INNER JOIN ci_triggers ON ci_trigger_schedules.trigger_id=ci_triggers.id; + SQL + end + + def down + # no op as the data has been removed + end +end diff --git a/db/post_migrate/20170425130047_drop_ci_trigger_schedules_table.rb b/db/post_migrate/20170425130047_drop_ci_trigger_schedules_table.rb new file mode 100644 index 00000000000..24750c58ef0 --- /dev/null +++ b/db/post_migrate/20170425130047_drop_ci_trigger_schedules_table.rb @@ -0,0 +1,32 @@ +class DropCiTriggerSchedulesTable < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + drop_table :ci_trigger_schedules + end + + def down + create_table "ci_trigger_schedules", force: :cascade do |t| + t.integer "project_id" + t.integer "trigger_id", null: false + t.datetime "deleted_at" + t.datetime "created_at" + t.datetime "updated_at" + t.string "cron" + t.string "cron_timezone" + t.datetime "next_run_at" + t.string "ref" + t.boolean "active" + end + + add_index "ci_trigger_schedules", %w(active next_run_at), name: "index_ci_trigger_schedules_on_active_and_next_run_at", using: :btree + add_index "ci_trigger_schedules", ["project_id"], name: "index_ci_trigger_schedules_on_project_id", using: :btree + add_index "ci_trigger_schedules", ["next_run_at"], name: "index_ci_trigger_schedules_on_next_run_at" + + add_concurrent_foreign_key "ci_trigger_schedules", "ci_triggers", column: :trigger_id, on_delete: :cascade + end +end |