private def create()

in lambda/src/main/scala/pricemigrationengine/services/CohortTableDdlLive.scala [29:60]


        private def create(tableName: String) = {
          val createRequest = CreateTableRequest.builder
            .tableName(tableName)
            .keySchema(KeySchemaElement.builder.attributeName(partitionKey).keyType(HASH).build())
            .attributeDefinitions(
              AttributeDefinition.builder.attributeName(partitionKey).attributeType(S).build(),
              AttributeDefinition.builder.attributeName(stageAttribute).attributeType(S).build(),
              AttributeDefinition.builder
                .attributeName(startDateAttribute)
                .attributeType(S)
                .build()
            )
            .globalSecondaryIndexes(
              GlobalSecondaryIndex.builder
                .indexName(stageIndex)
                .keySchema(KeySchemaElement.builder.attributeName(stageAttribute).keyType(HASH).build())
                .projection(Projection.builder.projectionType(ProjectionType.ALL).build())
                .build(),
              GlobalSecondaryIndex.builder
                .indexName(stageAndStartDateIndex)
                .keySchema(
                  KeySchemaElement.builder.attributeName(stageAttribute).keyType(HASH).build(),
                  KeySchemaElement.builder.attributeName(startDateAttribute).keyType(RANGE).build()
                )
                .projection(Projection.builder.projectionType(ProjectionType.ALL).build())
                .build()
            )
            .billingMode(PAY_PER_REQUEST)
            .build()

          dynamoDbClient.createTable(createRequest).mapError(e => CohortTableCreateFailure(e.toString))
        }