Skip to content

Change external_wiki maintainance triggers

Alex Kalderimis requested to merge 334127-integrations-change-wiki-trigger into master

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

Availability and Testing

Related to #334127 (closed)

Edited by Alex Kalderimis

Merge request reports

Loading