Skip to content

Remove type column from audit_events table

Tan Le requested to merge 229727-drop-type-on-audit-events into master

What does this MR do?

Remove type column from audit_events table.

Followed development guideline on dropping column.

  • Step 1: Ignoring the column (release 13.4) (!39082 (merged))
  • Step 2: Dropping the column (release 13.5) (this MR)

Relates to #229727 (closed)

Database log

== 20200929113254 RemoveTypeFromAuditEvents: reverting ========================
-- add_column("audit_events", :type, :string)
   -> 0.0016s
-- add_column("audit_events_part_5fc467ac26", :type, :string)
   -> 0.0014s
-- execute("CREATE OR REPLACE FUNCTION table_sync_function_2be879775d()\nRETURNS TRIGGER AS\n$$\nBEGIN\nIF (TG_OP = 'DELETE') THEN\n  DELETE FROM audit_events_part_5fc467ac26 where id = OLD.id;\nELSIF (TG_OP = 'UPDATE') THEN\n  UPDATE audit_events_part_5fc467ac26\n  SET author_id = NEW.author_id,\n    type = NEW.type,\n    entity_id = NEW.entity_id,\n    entity_type = NEW.entity_type,\n    details = NEW.details,\n    updated_at = NEW.updated_at,\n    ip_address = NEW.ip_address,\n    author_name = NEW.author_name,\n    entity_path = NEW.entity_path,\n    target_details = NEW.target_details,\n    target_type = NEW.target_type,\n    target_id = NEW.target_id,\n    created_at = NEW.created_at\n  WHERE audit_events_part_5fc467ac26.id = NEW.id;\nELSIF (TG_OP = 'INSERT') THEN\n  INSERT INTO audit_events_part_5fc467ac26 (id,\n    author_id,\n    type,\n    entity_id,\n    entity_type,\n    details,\n    updated_at,\n    ip_address,\n    author_name,\n    entity_path,\n    target_details,\n    target_type,\n    target_id,\n    created_at)\n  VALUES (NEW.id,\n    NEW.author_id,\n    NEW.type,\n    NEW.entity_id,\n    NEW.entity_type,\n    NEW.details,\n    NEW.updated_at,\n    NEW.ip_address,\n    NEW.author_name,\n    NEW.entity_path,\n    NEW.target_details,\n    NEW.target_type,\n    NEW.target_id,\n    NEW.created_at);\nEND IF;\nRETURN NULL;\n\nEND\n$$ LANGUAGE PLPGSQL\n")
   -> 0.0038s
== 20200929113254 RemoveTypeFromAuditEvents: reverted (0.0149s) ===============

== 20200929113254 RemoveTypeFromAuditEvents: migrating ========================
-- remove_column("audit_events", :type)
   -> 0.0012s
-- execute("CREATE OR REPLACE FUNCTION table_sync_function_2be879775d()\nRETURNS TRIGGER AS\n$$\nBEGIN\nIF (TG_OP = 'DELETE') THEN\n  DELETE FROM audit_events_part_5fc467ac26 where id = OLD.id;\nELSIF (TG_OP = 'UPDATE') THEN\n  UPDATE audit_events_part_5fc467ac26\n  SET author_id = NEW.author_id,\n    entity_id = NEW.entity_id,\n    entity_type = NEW.entity_type,\n    details = NEW.details,\n    ip_address = NEW.ip_address,\n    author_name = NEW.author_name,\n    entity_path = NEW.entity_path,\n    target_details = NEW.target_details,\n    target_type = NEW.target_type,\n    target_id = NEW.target_id,\n    created_at = NEW.created_at\n  WHERE audit_events_part_5fc467ac26.id = NEW.id;\nELSIF (TG_OP = 'INSERT') THEN\n  INSERT INTO audit_events_part_5fc467ac26 (id,\n    author_id,\n    entity_id,\n    entity_type,\n    details,\n    ip_address,\n    author_name,\n    entity_path,\n    target_details,\n    target_type,\n    target_id,\n    created_at)\n  VALUES (NEW.id,\n    NEW.author_id,\n    NEW.entity_id,\n    NEW.entity_type,\n    NEW.details,\n    NEW.ip_address,\n    NEW.author_name,\n    NEW.entity_path,\n    NEW.target_details,\n    NEW.target_type,\n    NEW.target_id,\n    NEW.created_at);\nEND IF;\nRETURN NULL;\n\nEND\n$$ LANGUAGE PLPGSQL\n")
   -> 0.0055s
-- remove_column("audit_events_part_5fc467ac26", :type)
   -> 0.0040s
== 20200929113254 RemoveTypeFromAuditEvents: migrated (0.0144s) ===============

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • [-] Label as security and @ mention @gitlab-com/gl-security/appsec
  • [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • [-] Security reports checked/validated by a reviewer from the AppSec team

Relates to #229727 (closed)

Edited by Tan Le

Merge request reports