From 4884f735a7f3bd8863acf763bdac15b76fac9b2a Mon Sep 17 00:00:00 2001 From: Saloni Shah Date: Fri, 16 Sep 2022 15:07:59 -0400 Subject: [PATCH] [BW-1398] Migrate PKs to BIGINT (#6907) --- CHANGELOG.md | 10 +++ .../src/main/resources/changelog.xml | 3 + .../enlarge_docker_hash_store_entry_id.xml | 41 ++++++++++ .../enlarge_sub_workflow_store_entry_id.xml | 41 ++++++++++ .../enlarge_workflow_store_entry_id.xml | 82 +++++++++++++++++++ .../DockerHashStoreEntryComponent.scala | 2 +- .../SubWorkflowStoreEntryComponent.scala | 6 +- .../tables/WorkflowStoreEntryComponent.scala | 2 +- .../sql/tables/DockerHashStoreEntry.scala | 2 +- .../sql/tables/SubWorkflowStoreEntry.scala | 4 +- .../sql/tables/WorkflowStoreEntry.scala | 2 +- 11 files changed, 186 insertions(+), 9 deletions(-) create mode 100644 database/migration/src/main/resources/changesets/enlarge_docker_hash_store_entry_id.xml create mode 100644 database/migration/src/main/resources/changesets/enlarge_sub_workflow_store_entry_id.xml create mode 100644 database/migration/src/main/resources/changesets/enlarge_workflow_store_entry_id.xml diff --git a/CHANGELOG.md b/CHANGELOG.md index e1158be3ca4..4dcab0dfa3f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Cromwell Change Log +## 85 Release Notes + +### Migration of PKs to BIGINT + +The PK of below tables will be migrated from INT to BIGINT. Also, since `ROOT_WORKFLOW_ID` in `SUB_WORKFLOW_STORE_ENTRY` is a FK to `WORKFLOW_STORE_ENTRY_ID` in `WORKFLOW_STORE_ENTRY` +it is also being migrated from INT to BIGINT. +* DOCKER_HASH_STORE_ENTRY +* WORKFLOW_STORE_ENTRY +* SUB_WORKFLOW_STORE_ENTRY + ## 84 Release Notes ### CromIAM enabled user checks diff --git a/database/migration/src/main/resources/changelog.xml b/database/migration/src/main/resources/changelog.xml index 5d711061c31..49d568766b3 100644 --- a/database/migration/src/main/resources/changelog.xml +++ b/database/migration/src/main/resources/changelog.xml @@ -87,6 +87,9 @@ + + + diff --git a/database/migration/src/main/resources/changesets/enlarge_docker_hash_store_entry_id.xml b/database/migration/src/main/resources/changesets/enlarge_docker_hash_store_entry_id.xml new file mode 100644 index 00000000000..fc7992268e6 --- /dev/null +++ b/database/migration/src/main/resources/changesets/enlarge_docker_hash_store_entry_id.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + SELECT count(*) + FROM information_schema.sequences + WHERE sequence_name = 'DOCKER_HASH_STORE_ENTRY_DOCKER_HASH_STORE_ENTRY_ID_seq' + AND data_type = 'bigint'; + + + alter sequence "DOCKER_HASH_STORE_ENTRY_DOCKER_HASH_STORE_ENTRY_ID_seq" as bigint; + + + + diff --git a/database/migration/src/main/resources/changesets/enlarge_sub_workflow_store_entry_id.xml b/database/migration/src/main/resources/changesets/enlarge_sub_workflow_store_entry_id.xml new file mode 100644 index 00000000000..57894db824b --- /dev/null +++ b/database/migration/src/main/resources/changesets/enlarge_sub_workflow_store_entry_id.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + SELECT count(*) + FROM information_schema.sequences + WHERE sequence_name = 'SUB_WORKFLOW_STORE_ENTRY_SUB_WORKFLOW_STORE_ENTRY_ID_seq' + AND data_type = 'bigint'; + + + alter sequence "SUB_WORKFLOW_STORE_ENTRY_SUB_WORKFLOW_STORE_ENTRY_ID_seq" as bigint; + + + + diff --git a/database/migration/src/main/resources/changesets/enlarge_workflow_store_entry_id.xml b/database/migration/src/main/resources/changesets/enlarge_workflow_store_entry_id.xml new file mode 100644 index 00000000000..ea2b498fd51 --- /dev/null +++ b/database/migration/src/main/resources/changesets/enlarge_workflow_store_entry_id.xml @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + SELECT count(*) + FROM information_schema.sequences + WHERE sequence_name = 'WORKFLOW_STORE_ENTRY_WORKFLOW_STORE_ENTRY_ID_seq' + AND data_type = 'bigint'; + + + alter sequence "WORKFLOW_STORE_ENTRY_WORKFLOW_STORE_ENTRY_ID_seq" as bigint; + + + + + + + + + + + + + + + + + + + + + + diff --git a/database/sql/src/main/scala/cromwell/database/slick/tables/DockerHashStoreEntryComponent.scala b/database/sql/src/main/scala/cromwell/database/slick/tables/DockerHashStoreEntryComponent.scala index e258b40f3b7..5929b2e5a6a 100644 --- a/database/sql/src/main/scala/cromwell/database/slick/tables/DockerHashStoreEntryComponent.scala +++ b/database/sql/src/main/scala/cromwell/database/slick/tables/DockerHashStoreEntryComponent.scala @@ -9,7 +9,7 @@ trait DockerHashStoreEntryComponent { import driver.api._ class DockerHashStoreEntries(tag: Tag) extends Table[DockerHashStoreEntry](tag, "DOCKER_HASH_STORE_ENTRY") { - def dockerHashStoreEntryId = column[Int]("DOCKER_HASH_STORE_ENTRY_ID", O.PrimaryKey, O.AutoInc) + def dockerHashStoreEntryId = column[Long]("DOCKER_HASH_STORE_ENTRY_ID", O.PrimaryKey, O.AutoInc) def workflowExecutionUuid = column[String]("WORKFLOW_EXECUTION_UUID", O.Length(255)) diff --git a/database/sql/src/main/scala/cromwell/database/slick/tables/SubWorkflowStoreEntryComponent.scala b/database/sql/src/main/scala/cromwell/database/slick/tables/SubWorkflowStoreEntryComponent.scala index 2ea7b36782c..11fa2191cb2 100644 --- a/database/sql/src/main/scala/cromwell/database/slick/tables/SubWorkflowStoreEntryComponent.scala +++ b/database/sql/src/main/scala/cromwell/database/slick/tables/SubWorkflowStoreEntryComponent.scala @@ -10,9 +10,9 @@ trait SubWorkflowStoreEntryComponent { import driver.api._ class SubWorkflowStoreEntries(tag: Tag) extends Table[SubWorkflowStoreEntry](tag, "SUB_WORKFLOW_STORE_ENTRY") { - def subWorkflowStoreEntryId = column[Int]("SUB_WORKFLOW_STORE_ENTRY_ID", O.PrimaryKey, O.AutoInc) + def subWorkflowStoreEntryId = column[Long]("SUB_WORKFLOW_STORE_ENTRY_ID", O.PrimaryKey, O.AutoInc) - def rootWorkflowId = column[Int]("ROOT_WORKFLOW_ID") + def rootWorkflowId = column[Long]("ROOT_WORKFLOW_ID") def parentWorkflowExecutionUuid = column[String]("PARENT_WORKFLOW_EXECUTION_UUID", O.Length(255)) @@ -40,7 +40,7 @@ trait SubWorkflowStoreEntryComponent { val subWorkflowStoreEntryIdsAutoInc = subWorkflowStoreEntries returning subWorkflowStoreEntries.map(_.subWorkflowStoreEntryId) val subWorkflowStoreEntriesForRootWorkflowId = Compiled( - (rootWorkflowId: Rep[Int]) => for { + (rootWorkflowId: Rep[Long]) => for { subWorkflowStoreEntry <- subWorkflowStoreEntries if subWorkflowStoreEntry.rootWorkflowId === rootWorkflowId } yield subWorkflowStoreEntry diff --git a/database/sql/src/main/scala/cromwell/database/slick/tables/WorkflowStoreEntryComponent.scala b/database/sql/src/main/scala/cromwell/database/slick/tables/WorkflowStoreEntryComponent.scala index 0e29cee651f..847fa862405 100644 --- a/database/sql/src/main/scala/cromwell/database/slick/tables/WorkflowStoreEntryComponent.scala +++ b/database/sql/src/main/scala/cromwell/database/slick/tables/WorkflowStoreEntryComponent.scala @@ -11,7 +11,7 @@ trait WorkflowStoreEntryComponent { import driver.api._ class WorkflowStoreEntries(tag: Tag) extends Table[WorkflowStoreEntry](tag, "WORKFLOW_STORE_ENTRY") { - def workflowStoreEntryId = column[Int]("WORKFLOW_STORE_ENTRY_ID", O.PrimaryKey, O.AutoInc) + def workflowStoreEntryId = column[Long]("WORKFLOW_STORE_ENTRY_ID", O.PrimaryKey, O.AutoInc) def workflowExecutionUuid = column[String]("WORKFLOW_EXECUTION_UUID", O.Length(255)) diff --git a/database/sql/src/main/scala/cromwell/database/sql/tables/DockerHashStoreEntry.scala b/database/sql/src/main/scala/cromwell/database/sql/tables/DockerHashStoreEntry.scala index a4a5b1247ee..542558324f5 100644 --- a/database/sql/src/main/scala/cromwell/database/sql/tables/DockerHashStoreEntry.scala +++ b/database/sql/src/main/scala/cromwell/database/sql/tables/DockerHashStoreEntry.scala @@ -6,5 +6,5 @@ case class DockerHashStoreEntry dockerTag: String, dockerHash: String, dockerSize: Option[Long], - dockerHashStoreEntryId: Option[Int] = None + dockerHashStoreEntryId: Option[Long] = None ) diff --git a/database/sql/src/main/scala/cromwell/database/sql/tables/SubWorkflowStoreEntry.scala b/database/sql/src/main/scala/cromwell/database/sql/tables/SubWorkflowStoreEntry.scala index 96ac39aa672..4cf89381ad0 100644 --- a/database/sql/src/main/scala/cromwell/database/sql/tables/SubWorkflowStoreEntry.scala +++ b/database/sql/src/main/scala/cromwell/database/sql/tables/SubWorkflowStoreEntry.scala @@ -2,11 +2,11 @@ package cromwell.database.sql.tables case class SubWorkflowStoreEntry ( - rootWorkflowId: Option[Int], + rootWorkflowId: Option[Long], parentWorkflowExecutionUuid: String, callFullyQualifiedName: String, callIndex: Int, callAttempt: Int, subWorkflowExecutionUuid: String, - subWorkflowStoreEntryId: Option[Int] = None + subWorkflowStoreEntryId: Option[Long] = None ) diff --git a/database/sql/src/main/scala/cromwell/database/sql/tables/WorkflowStoreEntry.scala b/database/sql/src/main/scala/cromwell/database/sql/tables/WorkflowStoreEntry.scala index 6c03db87014..efb594444d4 100644 --- a/database/sql/src/main/scala/cromwell/database/sql/tables/WorkflowStoreEntry.scala +++ b/database/sql/src/main/scala/cromwell/database/sql/tables/WorkflowStoreEntry.scala @@ -21,5 +21,5 @@ case class WorkflowStoreEntry cromwellId: Option[String], heartbeatTimestamp: Option[Timestamp], hogGroup: Option[String], - workflowStoreEntryId: Option[Int] = None + workflowStoreEntryId: Option[Long] = None )