Skip to content

Fix integer columns on new VSA table

Adam Hegyi requested to merge replace_analytics_table_with_bigints into master

What does this MR do?

This MR replaces the analytics_cycle_analytics_issue_stage_events with a version where bigints are used. I made a mistake in the previous MR and used integer for the table: !68950 (merged)

The migration is safe to execute on PRD in a standard migration because the table is not in use. The delete + create happens in a single transaction so the application will not notice it.

migration

up:

== 20210903054158 RecreateStageIssueEventsTableWithBigints: migrating =========
-- drop_table(:analytics_cycle_analytics_issue_stage_events)
   -> 0.0076s
-- execute("CREATE TABLE analytics_cycle_analytics_issue_stage_events (\n  stage_event_hash_id bigint NOT NULL,\n  issue_id bigint NOT NULL,\n  group_id bigint NOT NULL,\n  project_id bigint NOT NULL,\n  milestone_id bigint,\n  author_id bigint,\n  start_event_timestamp timestamp with time zone NOT NULL,\n  end_event_timestamp timestamp with time zone,\n  PRIMARY KEY (stage_event_hash_id, issue_id)\n) PARTITION BY HASH (stage_event_hash_id)\n")
   -> 0.0014s
-- transaction()
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_00\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 0);\n")
   -> 0.0193s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_01\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 1);\n")
   -> 0.0033s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_02\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 2);\n")
   -> 0.0029s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_03\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 3);\n")
   -> 0.0027s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_04\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 4);\n")
   -> 0.0047s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_05\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 5);\n")
   -> 0.0036s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_06\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 6);\n")
   -> 0.0034s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_07\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 7);\n")
   -> 0.0028s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_08\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 8);\n")
   -> 0.0028s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_09\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 9);\n")
   -> 0.0028s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_10\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 10);\n")
   -> 0.0030s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_11\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 11);\n")
   -> 0.0032s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_12\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 12);\n")
   -> 0.0028s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_13\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 13);\n")
   -> 0.0030s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_14\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 14);\n")
   -> 0.0028s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_15\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 15);\n")
   -> 0.0028s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_16\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 16);\n")
   -> 0.0034s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_17\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 17);\n")
   -> 0.0031s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_18\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 18);\n")
   -> 0.0029s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_19\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 19);\n")
   -> 0.0030s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_20\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 20);\n")
   -> 0.0028s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_21\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 21);\n")
   -> 0.0034s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_22\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 22);\n")
   -> 0.0034s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_23\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 23);\n")
   -> 0.0030s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_24\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 24);\n")
   -> 0.0037s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_25\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 25);\n")
   -> 0.0039s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_26\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 26);\n")
   -> 0.0049s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_27\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 27);\n")
   -> 0.0038s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_28\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 28);\n")
   -> 0.0038s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_29\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 29);\n")
   -> 0.0037s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_30\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 30);\n")
   -> 0.0041s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_31\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 31);\n")
   -> 0.0034s
   -> 0.1240s
== 20210903054158 RecreateStageIssueEventsTableWithBigints: migrated (0.1331s)

down:

== 20210903054158 RecreateStageIssueEventsTableWithBigints: reverting =========
-- drop_table(:analytics_cycle_analytics_issue_stage_events)
   -> 0.0067s
-- execute("CREATE TABLE analytics_cycle_analytics_issue_stage_events (\n  stage_event_hash_id integer NOT NULL,\n  issue_id integer NOT NULL,\n  group_id integer NOT NULL,\n  project_id integer NOT NULL,\n  milestone_id integer,\n  author_id integer,\n  start_event_timestamp timestamp with time zone NOT NULL,\n  end_event_timestamp timestamp with time zone,\n  PRIMARY KEY (stage_event_hash_id, issue_id)\n) PARTITION BY HASH (stage_event_hash_id)\n")
   -> 0.0016s
-- transaction()
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_00\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 0);\n")
   -> 0.0104s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_01\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 1);\n")
   -> 0.0031s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_02\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 2);\n")
   -> 0.0027s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_03\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 3);\n")
   -> 0.0037s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_04\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 4);\n")
   -> 0.0032s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_05\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 5);\n")
   -> 0.0027s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_06\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 6);\n")
   -> 0.0028s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_07\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 7);\n")
   -> 0.0037s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_08\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 8);\n")
   -> 0.0031s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_09\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 9);\n")
   -> 0.0036s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_10\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 10);\n")
   -> 0.0038s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_11\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 11);\n")
   -> 0.0026s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_12\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 12);\n")
   -> 0.0026s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_13\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 13);\n")
   -> 0.0038s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_14\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 14);\n")
   -> 0.0032s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_15\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 15);\n")
   -> 0.0030s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_16\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 16);\n")
   -> 0.0027s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_17\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 17);\n")
   -> 0.0022s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_18\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 18);\n")
   -> 0.0049s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_19\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 19);\n")
   -> 0.0029s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_20\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 20);\n")
   -> 0.0029s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_21\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 21);\n")
   -> 0.0034s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_22\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 22);\n")
   -> 0.0030s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_23\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 23);\n")
   -> 0.0030s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_24\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 24);\n")
   -> 0.0036s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_25\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 25);\n")
   -> 0.0030s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_26\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 26);\n")
   -> 0.0031s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_27\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 27);\n")
   -> 0.0025s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_28\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 28);\n")
   -> 0.0030s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_29\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 29);\n")
   -> 0.0089s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_30\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 30);\n")
   -> 0.0027s
-- execute("CREATE TABLE gitlab_partitions_static.analytics_cycle_analytics_issue_stage_events_31\nPARTITION OF analytics_cycle_analytics_issue_stage_events\nFOR VALUES WITH (MODULUS 32, REMAINDER 31);\n")
   -> 0.0029s
   -> 0.1144s
== 20210903054158 RecreateStageIssueEventsTableWithBigints: reverted (0.1229s)

Screenshots or Screencasts (strongly suggested)

How to setup and validate locally (strongly suggested)

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

Does this MR contain changes to processing or storing of credentials or tokens, authorization and authentication methods or other items described in the security review guidelines? If not, then delete this Security section.

  • [-] 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
Edited by Mayra Cabrera

Merge request reports

Loading