Drop the web_hook_logs_archived table
What does this MR do?
Related issue: #323678 (closed)
This is the final step required after partitioning the web_hook_logs
table (&5558 (closed)) is complete; we finish the process by dropping the non-partitioned web_hook_logs_archived
table and the related sync trigger and function.
Migrations
db:migrate
$ bundle exec rake db:migrate
== 20210609125005 DropNonPartitionedWebHookLogs: migrating ====================
-- execute("DROP TRIGGER IF EXISTS table_sync_trigger_b99eb6998c ON web_hook_logs")
-> 0.0023s
-- execute("DROP FUNCTION IF EXISTS table_sync_function_29bc99d6db()")
-> 0.0007s
-- drop_table("web_hook_logs_archived")
-> 0.0021s
== 20210609125005 DropNonPartitionedWebHookLogs: migrated (0.0133s) ===========
db:rollback
$ bundle exec rake db:rollback
== 20210609125005 DropNonPartitionedWebHookLogs: reverting ====================
-- execute("CREATE TABLE web_hook_logs_archived (\n id integer NOT NULL,\n web_hook_id integer NOT NULL,\n trigger character varying,\n url character varying,\n request_headers text,\n request_data text,\n response_headers text,\n response_body text,\n response_status character varying,\n execution_duration double precision,\n internal_error_message character varying,\n created_at timestamp without time zone NOT NULL,\n updated_at timestamp without time zone NOT NULL\n);\n\nALTER TABLE ONLY web_hook_logs_archived ADD CONSTRAINT web_hook_logs_archived_pkey PRIMARY KEY (id);\n\nCREATE INDEX index_web_hook_logs_on_created_at_and_web_hook_id ON web_hook_logs_archived USING btree (created_at, web_hook_id);\nCREATE INDEX index_web_hook_logs_on_web_hook_id ON web_hook_logs_archived USING btree (web_hook_id);\n\nALTER TABLE ONLY web_hook_logs_archived ADD CONSTRAINT fk_rails_666826e111 FOREIGN KEY (web_hook_id) REFERENCES web_hooks(id) ON DELETE CASCADE;\n")
-> 0.0080s
-- execute("CREATE FUNCTION table_sync_function_29bc99d6db()\nRETURNS TRIGGER AS\n$$\nBEGIN\nIF (TG_OP = 'DELETE') THEN\n DELETE FROM web_hook_logs_archived where id = OLD.id;\nELSIF (TG_OP = 'UPDATE') THEN\n UPDATE web_hook_logs_archived\n SET web_hook_id = NEW.web_hook_id,\n trigger = NEW.trigger,\n url = NEW.url,\n request_headers = NEW.request_headers,\n request_data = NEW.request_data,\n response_headers = NEW.response_headers,\n response_body = NEW.response_body,\n response_status = NEW.response_status,\n execution_duration = NEW.execution_duration,\n internal_error_message = NEW.internal_error_message,\n created_at = NEW.created_at,\n updated_at = NEW.updated_at\n WHERE web_hook_logs_archived.id = NEW.id;\nELSIF (TG_OP = 'INSERT') THEN\n INSERT INTO web_hook_logs_archived (id,\n web_hook_id,\n trigger,\n url,\n request_headers,\n request_data,\n response_headers,\n response_body,\n response_status,\n execution_duration,\n internal_error_message,\n created_at,\n updated_at)\n VALUES (NEW.id,\n NEW.web_hook_id,\n NEW.trigger,\n NEW.url,\n NEW.request_headers,\n NEW.request_data,\n NEW.response_headers,\n NEW.response_body,\n NEW.response_status,\n NEW.execution_duration,\n NEW.internal_error_message,\n NEW.created_at,\n NEW.updated_at);\nEND IF;\nRETURN NULL;\n\nEND\n$$ LANGUAGE PLPGSQL\n")
-> 0.0025s
-- execute("COMMENT ON FUNCTION table_sync_function_29bc99d6db IS 'Partitioning migration: table sync for web_hook_logs table'")
-> 0.0007s
-- current_schema()
-> 0.0002s
-- execute("CREATE TRIGGER table_sync_trigger_b99eb6998c\nAFTER INSERT OR UPDATE OR DELETE ON web_hook_logs\nFOR EACH ROW\nEXECUTE FUNCTION table_sync_function_29bc99d6db()\n")
-> 0.0016s
== 20210609125005 DropNonPartitionedWebHookLogs: reverted (0.0218s) ===========
-- Making sure that the revert keeps the schema as it was
$ git status
On branch 323678-drop-non-partitioned-web-hook-logs
Untracked files:
(use "git add <file>..." to include in what will be committed)
db/post_migrate/20210609125005_drop_non_partitioned_web_hook_logs.rb
nothing added to commit but untracked files present (use "git add" to track)
Does this MR meet the acceptance criteria?
Conformity
-
I have included a changelog entry, or it's not needed. (Does this MR need a changelog?) -
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 tested this MR in all supported browsers, or it's not needed.