Skip to content

Create Abuse Report Events table

Alex Buijs requested to merge create-abuse-report-events into master

What does this MR do and why?

This MR sets up the ResourceEvents::AbuseReportEvent model for storing actions taken on Abuse Reports.

The table will be used to display history items within Abuse Reports.

This MR contains the DB schema, model definition and tests.

Issue: https://gitlab.com/gitlab-org/modelops/anti-abuse/team-tasks/-/issues/158+

Migration

Up:

main: == [advisory_lock_connection] object_id: 274980, pg_backend_pid: 83332
main: == 20230428101217 CreateAbuseReportEvents: migrating ==========================
main: -- create_table(:abuse_report_events)
main: -- quote_column_name(:comment)
main:    -> 0.0000s
main:    -> 0.0069s
main: == 20230428101217 CreateAbuseReportEvents: migrated (0.1175s) =================

main: == 20230501111636 AddUsersFkToAbuseReportEvents: migrating ====================
main: -- transaction_open?()
main:    -> 0.0000s
main: -- transaction_open?()
main:    -> 0.0000s
main: -- execute("ALTER TABLE abuse_report_events ADD CONSTRAINT fk_18c774c06b FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE SET NULL NOT VALID;")
main:    -> 0.0012s
main: -- execute("SET statement_timeout TO 0")
main:    -> 0.0001s
main: -- execute("ALTER TABLE abuse_report_events VALIDATE CONSTRAINT fk_18c774c06b;")
main:    -> 0.0020s
main: -- execute("RESET statement_timeout")
main:    -> 0.0002s
main: == 20230501111636 AddUsersFkToAbuseReportEvents: migrated (0.0311s) ===========

main: == 20230502083003 AddAbuseReportsFkToAbuseReportEvents: migrating =============
main: -- transaction_open?()
main:    -> 0.0000s
main: -- transaction_open?()
main:    -> 0.0000s
main: -- execute("ALTER TABLE abuse_report_events ADD CONSTRAINT fk_fdd4d610e0 FOREIGN KEY (abuse_report_id) REFERENCES abuse_reports (id) ON DELETE CASCADE NOT VALID;")
main:    -> 0.0006s
main: -- execute("ALTER TABLE abuse_report_events VALIDATE CONSTRAINT fk_fdd4d610e0;")
main:    -> 0.0017s
main: == 20230502083003 AddAbuseReportsFkToAbuseReportEvents: migrated (0.0135s) ====

main: == [advisory_lock_connection] object_id: 274980, pg_backend_pid: 83332
ci: == [advisory_lock_connection] object_id: 275440, pg_backend_pid: 83334
ci: == 20230425114355 RemoveApplicationSettingsClickhouseConnectionString: migrating
ci: -- remove_column(:application_settings, :clickhouse_connection_string)
ci:    -> 0.0015s
ci: == 20230425114355 RemoveApplicationSettingsClickhouseConnectionString: migrated (0.0098s)

ci: == 20230426102200 FixImportSourcesOnApplicationSettingsAfterPhabricatorRemoval: migrating
ci: -- The migration is skipped since it modifies the schemas: [:gitlab_main].
ci: -- This database can only apply migrations in one of the following schemas: [:gitlab_ci, :gitlab_shared, :gitlab_internal].
ci: == 20230426102200 FixImportSourcesOnApplicationSettingsAfterPhabricatorRemoval: migrated (0.0084s)

ci: == 20230428101217 CreateAbuseReportEvents: migrating ==========================
ci: -- create_table(:abuse_report_events)
ci: -- quote_column_name(:comment)
ci:    -> 0.0000s
ci:    -> 0.0059s
I, [2023-05-02T10:33:28.241176 #83189]  INFO -- : Database: 'ci', Table: 'abuse_report_events': Lock Writes
ci: == 20230428101217 CreateAbuseReportEvents: migrated (0.0176s) =================

ci: == 20230501111636 AddUsersFkToAbuseReportEvents: migrating ====================
ci: -- transaction_open?()
ci:    -> 0.0000s
ci: -- transaction_open?()
ci:    -> 0.0000s
ci: -- execute("ALTER TABLE abuse_report_events ADD CONSTRAINT fk_18c774c06b FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE SET NULL NOT VALID;")
ci:    -> 0.0009s
ci: -- execute("SET statement_timeout TO 0")
ci:    -> 0.0003s
ci: -- execute("ALTER TABLE abuse_report_events VALIDATE CONSTRAINT fk_18c774c06b;")
ci:    -> 0.0022s
ci: -- execute("RESET statement_timeout")
ci:    -> 0.0005s
ci: == 20230501111636 AddUsersFkToAbuseReportEvents: migrated (0.0250s) ===========

ci: == 20230502083003 AddAbuseReportsFkToAbuseReportEvents: migrating =============
ci: -- transaction_open?()
ci:    -> 0.0001s
ci: -- transaction_open?()
ci:    -> 0.0000s
ci: -- execute("ALTER TABLE abuse_report_events ADD CONSTRAINT fk_fdd4d610e0 FOREIGN KEY (abuse_report_id) REFERENCES abuse_reports (id) ON DELETE CASCADE NOT VALID;")
ci:    -> 0.0015s
ci: -- execute("ALTER TABLE abuse_report_events VALIDATE CONSTRAINT fk_fdd4d610e0;")
ci:    -> 0.0043s
ci: == 20230502083003 AddAbuseReportsFkToAbuseReportEvents: migrated (0.0242s) ====

ci: == [advisory_lock_connection] object_id: 275440, pg_backend_pid: 83334

Down:

main: == [advisory_lock_connection] object_id: 308280, pg_backend_pid: 84406
main: == 20230502083003 AddAbuseReportsFkToAbuseReportEvents: reverting =============
main: -- transaction_open?()
main:    -> 0.0000s
main: -- remove_foreign_key(:abuse_report_events, {:column=>:abuse_report_id})
main:    -> 0.0025s
main: == 20230502083003 AddAbuseReportsFkToAbuseReportEvents: reverted (0.1227s) ====

main: == 20230501111636 AddUsersFkToAbuseReportEvents: reverting ====================
main: -- transaction_open?()
main:    -> 0.0000s
main: -- remove_foreign_key(:abuse_report_events, {:column=>:user_id})
main:    -> 0.0024s
main: == 20230501111636 AddUsersFkToAbuseReportEvents: reverted (0.0097s) ===========

main: == 20230428101217 CreateAbuseReportEvents: reverting ==========================
main: -- drop_table(:abuse_report_events)
main:    -> 0.0011s
main: == 20230428101217 CreateAbuseReportEvents: reverted (0.0046s) =================

main: == [advisory_lock_connection] object_id: 308280, pg_backend_pid: 84406
ci: == [advisory_lock_connection] object_id: 323540, pg_backend_pid: 84659
ci: == 20230502083003 AddAbuseReportsFkToAbuseReportEvents: reverting =============
ci: -- transaction_open?()
ci:    -> 0.0000s
ci: -- remove_foreign_key(:abuse_report_events, {:column=>:abuse_report_id})
ci:    -> 0.0032s
ci: == 20230502083003 AddAbuseReportsFkToAbuseReportEvents: reverted (0.0374s) ====

ci: == 20230501111636 AddUsersFkToAbuseReportEvents: reverting ====================
ci: -- transaction_open?()
ci:    -> 0.0000s
ci: -- remove_foreign_key(:abuse_report_events, {:column=>:user_id})
ci:    -> 0.0039s
ci: == 20230501111636 AddUsersFkToAbuseReportEvents: reverted (0.0345s) ===========

ci: == 20230428101217 CreateAbuseReportEvents: reverting ==========================
ci: -- drop_table(:abuse_report_events)
ci:    -> 0.0011s
ci: == 20230428101217 CreateAbuseReportEvents: reverted (0.0110s) =================

ci: == [advisory_lock_connection] object_id: 323540, pg_backend_pid: 84659

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Alex Buijs

Merge request reports

Loading