Change external_wiki maintainance triggers
What does this MR do?
This MR changes the triggers that maintain the has_external_wiki
flag on projects so that
they are not triggered by type = ExternalWiki
integrations, but by type_new = Integrations::ExternalWiki
integrations, which is the updated STI column for the integrations table.
Migration output
Up
== 20210813151908 ReplaceExternalWikiTriggers: migrating ======================
-- execute("CREATE TRIGGER trigger_has_external_wiki_on_delete_new AFTER DELETE ON integrations FOR EACH ROW WHEN (((old.type_new)::text = 'Integrations::ExternalWiki'::text) AND (old.project_id IS NOT NULL)) EXECUTE FUNCTION set_has_external_wiki();")
-> 0.0026s
-- execute("ALTER TRIGGER trigger_has_external_wiki_on_delete ON integrations RENAME TO trigger_has_external_wiki_on_delete_old;")
-> 0.0010s
-- execute("ALTER TRIGGER trigger_has_external_wiki_on_delete_new ON integrations RENAME TO trigger_has_external_wiki_on_delete;")
-> 0.0012s
-- execute("DROP TRIGGER IF EXISTS trigger_has_external_wiki_on_delete_old ON integrations;")
-> 0.0014s
-- execute("CREATE TRIGGER trigger_has_external_wiki_on_insert_new AFTER INSERT ON integrations FOR EACH ROW WHEN (((new.type_new)::text = 'Integrations::ExternalWiki'::text) AND (new.project_id IS NOT NULL) AND (new.active = true)) EXECUTE FUNCTION set_has_external_wiki();")
-> 0.0017s
-- execute("ALTER TRIGGER trigger_has_external_wiki_on_insert ON integrations RENAME TO trigger_has_external_wiki_on_insert_old;")
-> 0.0013s
-- execute("ALTER TRIGGER trigger_has_external_wiki_on_insert_new ON integrations RENAME TO trigger_has_external_wiki_on_insert;")
-> 0.0031s
-- execute("DROP TRIGGER IF EXISTS trigger_has_external_wiki_on_insert_old ON integrations;")
-> 0.0013s
-- execute("CREATE TRIGGER trigger_has_external_wiki_on_update_new AFTER UPDATE ON integrations FOR EACH ROW WHEN (((new.type_new)::text = 'Integrations::ExternalWiki'::text) AND (new.project_id IS NOT NULL) AND (old.active <> new.active)) EXECUTE FUNCTION set_has_external_wiki();")
-> 0.0015s
-- execute("ALTER TRIGGER trigger_has_external_wiki_on_update ON integrations RENAME TO trigger_has_external_wiki_on_update_old;")
-> 0.0014s
-- execute("ALTER TRIGGER trigger_has_external_wiki_on_update_new ON integrations RENAME TO trigger_has_external_wiki_on_update;")
-> 0.0014s
-- execute("DROP TRIGGER IF EXISTS trigger_has_external_wiki_on_update_old ON integrations;")
-> 0.0012s
== 20210813151908 ReplaceExternalWikiTriggers: migrated (0.0200s) =============
Down
== 20210813151908 ReplaceExternalWikiTriggers: reverting ======================
-- execute("CREATE TRIGGER trigger_has_external_wiki_on_delete_new AFTER DELETE ON integrations FOR EACH ROW WHEN (((old.type)::text = 'ExternalWikiService'::text) AND (old.project_id IS NOT NULL)) EXECUTE FUNCTION set_has_external_wiki();")
-> 0.0053s
-- execute("ALTER TRIGGER trigger_has_external_wiki_on_delete ON integrations RENAME TO trigger_has_external_wiki_on_delete_old;")
-> 0.0013s
-- execute("ALTER TRIGGER trigger_has_external_wiki_on_delete_new ON integrations RENAME TO trigger_has_external_wiki_on_delete;")
-> 0.0012s
-- execute("DROP TRIGGER IF EXISTS trigger_has_external_wiki_on_delete_old ON integrations;")
-> 0.0021s
-- execute("CREATE TRIGGER trigger_has_external_wiki_on_insert_new AFTER INSERT ON integrations FOR EACH ROW WHEN (((new.type)::text = 'ExternalWikiService'::text) AND (new.project_id IS NOT NULL) AND (new.active = true)) EXECUTE FUNCTION set_has_external_wiki();")
-> 0.0026s
-- execute("ALTER TRIGGER trigger_has_external_wiki_on_insert ON integrations RENAME TO trigger_has_external_wiki_on_insert_old;")
-> 0.0022s
-- execute("ALTER TRIGGER trigger_has_external_wiki_on_insert_new ON integrations RENAME TO trigger_has_external_wiki_on_insert;")
-> 0.0012s
-- execute("DROP TRIGGER IF EXISTS trigger_has_external_wiki_on_insert_old ON integrations;")
-> 0.0015s
-- execute("CREATE TRIGGER trigger_has_external_wiki_on_update_new AFTER UPDATE ON integrations FOR EACH ROW WHEN (((new.type)::text = 'ExternalWikiService'::text) AND (new.project_id IS NOT NULL) AND (old.active <> new.active)) EXECUTE FUNCTION set_has_external_wiki();")
-> 0.0014s
-- execute("ALTER TRIGGER trigger_has_external_wiki_on_update ON integrations RENAME TO trigger_has_external_wiki_on_update_old;")
-> 0.0011s
-- execute("ALTER TRIGGER trigger_has_external_wiki_on_update_new ON integrations RENAME TO trigger_has_external_wiki_on_update;")
-> 0.0011s
-- execute("DROP TRIGGER IF EXISTS trigger_has_external_wiki_on_update_old ON integrations;")
-> 0.0012s
== 20210813151908 ReplaceExternalWikiTriggers: reverted (0.0234s) =============
How to setup and validate locally (strongly suggested)
- Edit a project by setting an external wiki
- inspect the project in the Rails console and confirm that
has_external_wiki
is true.
Does this MR meet the acceptance criteria?
Conformity
-
I have included changelog trailers, or none are needed. (Does this MR need a changelog?) -
I have added/updated documentation, or it's not needed. (Is documentation required?) -
I have properly separated EE content from FOSS, or this MR is FOSS only. (Where should EE code go?) -
I have added information for database reviewers in the MR description, or it's not needed. (Does this MR have database related changes?) -
I have self-reviewed this MR per code review guidelines. -
This MR does not harm performance, or I have asked a reviewer to help assess the performance impact. (Merge request performance guidelines) -
I have followed the style guides. -
This change is backwards compatible across updates, or this does not apply.
Availability and Testing
-
I have added/updated tests following the Testing Guide, or it's not needed. (Consider all test levels. See the Test Planning Process.) -
I have tested this MR in all supported browsers, or it's not needed.
Related to #334127 (closed)
Edited by Alex Kalderimis