Commit 3d87229e authored by Tiago Botelho's avatar Tiago Botelho

ensure project mirror data with post migration

parent 0ca479d1
class EnsureProjectMirrorData < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def up
return unless Gitlab::Database.postgresql?
execute <<-SQL
INSERT INTO project_mirror_data
SELECT id AS project_id,
0 AS retry_count,
CAST(NULL AS TIMESTAMP) AS last_update_started_at,
CAST(NULL AS TIMESTAMP) AS last_update_scheduled_at,
NOW() AS next_execution_timestamp,
NOW() AS created_at,
NOW() as updated_at
FROM projects
WHERE mirror IS TRUE
AND NOT EXISTS (
SELECT true
FROM project_mirror_data
WHERE project_mirror_data.project_id = projects.id
);
SQL
end
def down
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment