Skip to content

Add fields to AbuseReports to facilitate automations

Ethan Urie requested to merge eurie-add-fields-to-abuse-reports into master

What does this MR do and why?

Adds fields to the abuse_reports table to facilitate wider automation and uses.

See https://gitlab.com/gitlab-org/modelops/anti-abuse/team-tasks/-/issues/222 for more details.

Screenshots or screen recordings

20230214212644 AddFieldsToAbuseReports

Migrate up

main: == [advisory_lock_connection] object_id: 275420, pg_backend_pid: 40584
main: == 20230214212644 AddFieldsToAbuseReports: migrating ==========================
main: -- transaction_open?()
main:    -> 0.0000s
main: -- add_column(:abuse_reports, :resolved_by_id, :int, {:null=>true})
main:    -> 0.0020s
main: -- add_column(:abuse_reports, :assignee_id, :int, {:null=>true})
main:    -> 0.0004s
main: -- add_column(:abuse_reports, :mitigation_steps, :text, {:null=>true})
main:    -> 0.0002s
main: -- add_column(:abuse_reports, :evidence, :jsonb, {:null=>true})
main:    -> 0.0005s
main: -- transaction_open?()
main:    -> 0.0000s
main: -- transaction_open?()
main:    -> 0.0001s
main: -- execute("ALTER TABLE abuse_reports\nADD CONSTRAINT check_f3c0947a2d\nCHECK ( char_length(mitigation_steps) <= 1000 )\nNOT VALID;\n")
main:    -> 0.0027s
main: -- execute("SET statement_timeout TO 0")
main:    -> 0.0002s
main: -- execute("ALTER TABLE abuse_reports VALIDATE CONSTRAINT check_f3c0947a2d;")
main:    -> 0.0008s
main: -- execute("RESET statement_timeout")
main:    -> 0.0002s
main: == 20230214212644 AddFieldsToAbuseReports: migrated (0.1837s) =================

main: == [advisory_lock_connection] object_id: 275420, pg_backend_pid: 40584

Migrate down

main: == [advisory_lock_connection] object_id: 275500, pg_backend_pid: 40180
main: == 20230214212644 AddFieldsToAbuseReports: reverting ==========================
main: -- change_table(:abuse_reports)
main:    -> 0.0135s
main: == 20230214212644 AddFieldsToAbuseReports: reverted (0.0174s) =================

main: == [advisory_lock_connection] object_id: 275500, pg_backend_pid: 40180

Migrate up: 20230317180348 AddForeignKeyConstraintsToAbuseReports

main: == [advisory_lock_connection] object_id: 275460, pg_backend_pid: 20311
main: == 20230317180348 AddForeignKeyConstraintsToAbuseReports: migrating ===========
main: -- transaction_open?()
main:    -> 0.0000s
main: -- transaction_open?()
main:    -> 0.0000s
main: -- execute("ALTER TABLE abuse_reports ADD CONSTRAINT fk_f10de8b524 FOREIGN KEY (resolved_by_id) REFERENCES users (id) ON DELETE SET NULL NOT VALID;")
main:    -> 0.0053s
main: -- execute("SET statement_timeout TO 0")
main:    -> 0.0001s
main: -- execute("ALTER TABLE abuse_reports VALIDATE CONSTRAINT fk_f10de8b524;")
main:    -> 0.0114s
main: -- execute("RESET statement_timeout")
main:    -> 0.0002s
main: == 20230317180348 AddForeignKeyConstraintsToAbuseReports: migrated (0.1489s) ==

Migrate down:

main: == [advisory_lock_connection] object_id: 275560, pg_backend_pid: 19867
main: == 20230317180348 AddForeignKeyConstraintsToAbuseReports: reverting ===========
main: -- transaction_open?()
main:    -> 0.0000s
main: == 20230317180348 AddForeignKeyConstraintsToAbuseReports: reverted (0.1573s) ==

main: == [advisory_lock_connection] object_id: 275560, pg_backend_pid: 19867

2023051‎2190456 AddForeignKeyToAbuseReportsForAssignee

Migrate up:

main: == [advisory_lock_connection] object_id: 275440, pg_backend_pid: 29750
main: == 20230512190456 AddForeignKeyToAbuseReportsForAssignee: migrating ===========
main: -- transaction_open?()
main:    -> 0.0000s
main: -- transaction_open?()
main:    -> 0.0000s
main: -- execute("ALTER TABLE abuse_reports ADD CONSTRAINT fk_3fe6467b93 FOREIGN KEY (assignee_id) REFERENCES users (id) ON DELETE SET NULL NOT VALID;")
main:    -> 0.0014s
main: -- execute("SET statement_timeout TO 0")
main:    -> 0.0001s
main: -- execute("ALTER TABLE abuse_reports VALIDATE CONSTRAINT fk_3fe6467b93;")
main:    -> 0.0050s
main: -- execute("RESET statement_timeout")
main:    -> 0.0003s
main: == 20230512190456 AddForeignKeyToAbuseReportsForAssignee: migrated (0.1413s) ==

main: == [advisory_lock_connection] object_id: 275440, pg_backend_pid: 29750

Migrate down:

main: == [advisory_lock_connection] object_id: 275520, pg_backend_pid: 29315
main: == 20230512190456 AddForeignKeyToAbuseReportsForAssignee: reverting ===========
main: -- transaction_open?()
main:    -> 0.0000s
main: -- remove_foreign_key(:abuse_reports, {:column=>:assignee_id})
main:    -> 0.0043s
main: == 20230512190456 AddForeignKeyToAbuseReportsForAssignee: reverted (0.1347s) ==

main: == [advisory_lock_connection] object_id: 275520, pg_backend_pid: 29315

How to set up and validate locally

N/A

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 Ethan Urie

Merge request reports

Loading