diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 21:25:58 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 21:25:58 +0300 |
commit | a5f4bba440d7f9ea47046a0a561d49adf0a1e6d4 (patch) | |
tree | fb69158581673816a8cd895f9d352dcb3c678b1e /db/post_migrate/20210609125005_drop_non_partitioned_web_hook_logs.rb | |
parent | d16b2e8639e99961de6ddc93909f3bb5c1445ba1 (diff) |
Add latest changes from gitlab-org/gitlab@14-0-stable-eev14.0.0-rc42
Diffstat (limited to 'db/post_migrate/20210609125005_drop_non_partitioned_web_hook_logs.rb')
-rw-r--r-- | db/post_migrate/20210609125005_drop_non_partitioned_web_hook_logs.rb | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/db/post_migrate/20210609125005_drop_non_partitioned_web_hook_logs.rb b/db/post_migrate/20210609125005_drop_non_partitioned_web_hook_logs.rb new file mode 100644 index 00000000000..596b643e079 --- /dev/null +++ b/db/post_migrate/20210609125005_drop_non_partitioned_web_hook_logs.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +class DropNonPartitionedWebHookLogs < ActiveRecord::Migration[6.1] + include Gitlab::Database::MigrationHelpers + include Gitlab::Database::PartitioningMigrationHelpers::TableManagementHelpers + + DOWNTIME = false + + def up + drop_nonpartitioned_archive_table(:web_hook_logs) + end + + def down + execute(<<~SQL) + CREATE TABLE web_hook_logs_archived ( + id integer NOT NULL, + web_hook_id integer NOT NULL, + trigger character varying, + url character varying, + request_headers text, + request_data text, + response_headers text, + response_body text, + response_status character varying, + execution_duration double precision, + internal_error_message character varying, + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL + ); + + ALTER TABLE ONLY web_hook_logs_archived ADD CONSTRAINT web_hook_logs_archived_pkey PRIMARY KEY (id); + + CREATE INDEX index_web_hook_logs_on_created_at_and_web_hook_id ON web_hook_logs_archived USING btree (created_at, web_hook_id); + CREATE INDEX index_web_hook_logs_on_web_hook_id ON web_hook_logs_archived USING btree (web_hook_id); + + ALTER TABLE ONLY web_hook_logs_archived ADD CONSTRAINT fk_rails_666826e111 FOREIGN KEY (web_hook_id) REFERENCES web_hooks(id) ON DELETE CASCADE; + SQL + + with_lock_retries do + create_trigger_to_sync_tables(:web_hook_logs, :web_hook_logs_archived, 'id') + end + end +end |