Commit abea2e32 authored by Thong Kuah's avatar Thong Kuah

Removes FK for ci_pipeline_schedules to users

Changelog: changed
parent b5fb1331
# frozen_string_literal: true
class RemoveUsersCiPipelineSchedulesOwnerIdFk < Gitlab::Database::Migration[1.0]
disable_ddl_transaction!
def up
with_lock_retries do
remove_foreign_key_if_exists(:ci_pipeline_schedules, :users, name: "fk_9ea99f58d2")
end
end
def down
add_concurrent_foreign_key(:ci_pipeline_schedules, :users, name: "fk_9ea99f58d2", column: :owner_id, target_column: :id, on_delete: :nullify)
end
end
983e5522b2798ca0d17ca3fd848f527b12afdbdd1482a2d420c4c6ce4fa2c9c4
\ No newline at end of file
...@@ -29522,9 +29522,6 @@ ALTER TABLE ONLY protected_environments ...@@ -29522,9 +29522,6 @@ ALTER TABLE ONLY protected_environments
ALTER TABLE ONLY alert_management_alerts ALTER TABLE ONLY alert_management_alerts
ADD CONSTRAINT fk_9e49e5c2b7 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; ADD CONSTRAINT fk_9e49e5c2b7 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
ALTER TABLE ONLY ci_pipeline_schedules
ADD CONSTRAINT fk_9ea99f58d2 FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE SET NULL;
ALTER TABLE ONLY protected_branch_push_access_levels ALTER TABLE ONLY protected_branch_push_access_levels
ADD CONSTRAINT fk_9ffc86a3d9 FOREIGN KEY (protected_branch_id) REFERENCES protected_branches(id) ON DELETE CASCADE; ADD CONSTRAINT fk_9ffc86a3d9 FOREIGN KEY (protected_branch_id) REFERENCES protected_branches(id) ON DELETE CASCADE;
---
dast_site_profiles_pipelines: dast_site_profiles_pipelines:
- table: ci_pipelines - table: ci_pipelines
column: ci_pipeline_id column: ci_pipeline_id
......
...@@ -23,6 +23,11 @@ RSpec.describe Ci::PipelineSchedule do ...@@ -23,6 +23,11 @@ RSpec.describe Ci::PipelineSchedule do
subject { build(:ci_pipeline_schedule, project: project) } subject { build(:ci_pipeline_schedule, project: project) }
end end
it_behaves_like 'cleanup by a loose foreign key' do
let!(:parent) { create(:user) }
let!(:model) { create(:ci_pipeline_schedule, owner: parent) }
end
describe 'validations' do describe 'validations' do
it 'does not allow invalid cron patterns' do it 'does not allow invalid cron patterns' do
pipeline_schedule = build(:ci_pipeline_schedule, cron: '0 0 0 * *') pipeline_schedule = build(:ci_pipeline_schedule, cron: '0 0 0 * *')
......
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