private async Task UpdateTableAsync(IAmazonDynamoDB client, string rolesTableName,
                                            List <GlobalSecondaryIndexUpdate> indexUpdates)
        {
            await client.UpdateTableAsync(new UpdateTableRequest
            {
                TableName = rolesTableName,
                GlobalSecondaryIndexUpdates = indexUpdates
            });

            await DynamoUtils.WaitForActiveTableAsync(client, rolesTableName);
        }
예제 #2
0
        private async Task CreateTableAsync(IAmazonDynamoDB client, string userTableName,
                                            ProvisionedThroughput provisionedThroughput, List <GlobalSecondaryIndex> globalSecondaryIndexes)
        {
            var response = await client.CreateTableAsync(new CreateTableRequest
            {
                TableName             = userTableName,
                ProvisionedThroughput = provisionedThroughput,
                KeySchema             = new List <KeySchemaElement>
                {
                    new KeySchemaElement
                    {
                        AttributeName = "Id",
                        KeyType       = KeyType.HASH
                    },
                    new KeySchemaElement
                    {
                        AttributeName = "DeletedOn",
                        KeyType       = KeyType.RANGE
                    }
                },
                AttributeDefinitions = new List <AttributeDefinition>
                {
                    new AttributeDefinition
                    {
                        AttributeName = "Id",
                        AttributeType = ScalarAttributeType.S
                    },
                    new AttributeDefinition
                    {
                        AttributeName = "DeletedOn",
                        AttributeType = ScalarAttributeType.S
                    },
                    new AttributeDefinition
                    {
                        AttributeName = "NormalizedUserName",
                        AttributeType = ScalarAttributeType.S
                    },
                    new AttributeDefinition
                    {
                        AttributeName = "NormalizedEmail",
                        AttributeType = ScalarAttributeType.S
                    }
                },
                GlobalSecondaryIndexes = globalSecondaryIndexes
            });

            if (response.HttpStatusCode != HttpStatusCode.OK)
            {
                throw new Exception($"Couldn't create table {userTableName}");
            }

            await DynamoUtils.WaitForActiveTableAsync(client, userTableName);
        }