Commit 892e4c0d authored by Stan Hu's avatar Stan Hu

Merge branch 'fix-migration' into 'master'

Delete rename trigger before creating to prevent error

See merge request gitlab-org/gitlab-ce!32147
parents 523c619f 599cc499
...@@ -746,6 +746,11 @@ module Gitlab ...@@ -746,6 +746,11 @@ module Gitlab
VOLATILE VOLATILE
EOF EOF
execute <<-EOF.strip_heredoc
DROP TRIGGER IF EXISTS #{trigger}
ON #{table}
EOF
execute <<-EOF.strip_heredoc execute <<-EOF.strip_heredoc
CREATE TRIGGER #{trigger} CREATE TRIGGER #{trigger}
BEFORE INSERT OR UPDATE BEFORE INSERT OR UPDATE
......
...@@ -618,11 +618,19 @@ describe Gitlab::Database::MigrationHelpers do ...@@ -618,11 +618,19 @@ describe Gitlab::Database::MigrationHelpers do
expect(model).to receive(:execute) expect(model).to receive(:execute)
.with(/CREATE OR REPLACE FUNCTION foo()/m) .with(/CREATE OR REPLACE FUNCTION foo()/m)
expect(model).to receive(:execute)
.with(/DROP TRIGGER IF EXISTS foo/m)
expect(model).to receive(:execute) expect(model).to receive(:execute)
.with(/CREATE TRIGGER foo/m) .with(/CREATE TRIGGER foo/m)
model.install_rename_triggers_for_postgresql('foo', :users, :old, :new) model.install_rename_triggers_for_postgresql('foo', :users, :old, :new)
end end
it 'does not fail if trigger already exists' do
model.install_rename_triggers_for_postgresql('foo', :users, :old, :new)
model.install_rename_triggers_for_postgresql('foo', :users, :old, :new)
end
end end
describe '#remove_rename_triggers_for_postgresql' do describe '#remove_rename_triggers_for_postgresql' do
......
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