@@ -31,6 +31,7 @@ export async function setupDynamoDBContainer() {
3131 endpoint,
3232 lettersTableName : 'letters' ,
3333 miTableName : 'management-info' ,
34+ suppliersTableName : 'suppliers' ,
3435 lettersTtlHours : 1 ,
3536 miTtlHours : 1
3637 } ;
@@ -94,6 +95,29 @@ const createMITableCommand = new CreateTableCommand({
9495 ]
9596 } ) ;
9697
98+ const createSupplierTableCommand = new CreateTableCommand ( {
99+ TableName : 'suppliers' ,
100+ BillingMode : 'PAY_PER_REQUEST' ,
101+ KeySchema : [
102+ { AttributeName : 'id' , KeyType : 'HASH' } // Partition key
103+ ] ,
104+ GlobalSecondaryIndexes : [
105+ {
106+ IndexName : 'supplier-apim-index' ,
107+ KeySchema : [
108+ { AttributeName : 'apimId' , KeyType : 'HASH' } // Partition key for GSI
109+ ] ,
110+ Projection : {
111+ ProjectionType : 'ALL'
112+ }
113+ }
114+ ] ,
115+ AttributeDefinitions : [
116+ { AttributeName : 'id' , AttributeType : 'S' } ,
117+ { AttributeName : 'apimId' , AttributeType : 'S' }
118+ ]
119+ } ) ;
120+
97121
98122export async function createTables ( context : DBContext ) {
99123 const { ddbClient } = context ;
@@ -102,6 +126,7 @@ export async function createTables(context: DBContext) {
102126 await ddbClient . send ( updateTimeToLiveCommand ) ;
103127
104128 await ddbClient . send ( createMITableCommand ) ;
129+ await ddbClient . send ( createSupplierTableCommand ) ;
105130}
106131
107132
@@ -115,4 +140,8 @@ export async function deleteTables(context: DBContext) {
115140 await ddbClient . send ( new DeleteTableCommand ( {
116141 TableName : 'management-info'
117142 } ) ) ;
143+
144+ await ddbClient . send ( new DeleteTableCommand ( {
145+ TableName : 'suppliers'
146+ } ) ) ;
118147}
0 commit comments