@@ -30,7 +30,9 @@ export async function setupDynamoDBContainer() {
3030 region : 'us-west-2' ,
3131 endpoint,
3232 lettersTableName : 'letters' ,
33- ttlHours : 1
33+ miTableName : 'management-info' ,
34+ lettersTtlHours : 1 ,
35+ miTtlHours : 1
3436 } ;
3537
3638 return {
@@ -44,10 +46,7 @@ export async function setupDynamoDBContainer() {
4446
4547export type DBContext = Awaited < ReturnType < typeof setupDynamoDBContainer > > ;
4648
47- export async function createTables ( context : DBContext ) {
48- const { ddbClient } = context ;
49-
50- await ddbClient . send ( new CreateTableCommand ( {
49+ const createLetterTableCommand = new CreateTableCommand ( {
5150 TableName : 'letters' ,
5251 BillingMode : 'PAY_PER_REQUEST' ,
5352 KeySchema : [
@@ -72,15 +71,37 @@ export async function createTables(context: DBContext) {
7271 { AttributeName : 'supplierStatus' , AttributeType : 'S' } ,
7372 { AttributeName : 'supplierStatusSk' , AttributeType : 'S' } ,
7473 ]
75- } ) ) ;
74+ } ) ;
7675
77- await ddbClient . send ( new UpdateTimeToLiveCommand ( {
76+ const updateTimeToLiveCommand = new UpdateTimeToLiveCommand ( {
7877 TableName : 'letters' ,
7978 TimeToLiveSpecification : {
8079 AttributeName : 'ttl' ,
8180 Enabled : true
8281 }
83- } ) ) ;
82+ } ) ;
83+
84+ const createMITableCommand = new CreateTableCommand ( {
85+ TableName : 'management-info' ,
86+ BillingMode : 'PAY_PER_REQUEST' ,
87+ KeySchema : [
88+ { AttributeName : 'supplierId' , KeyType : 'HASH' } , // Partition key
89+ { AttributeName : 'id' , KeyType : 'RANGE' } // Sort key
90+ ] ,
91+ AttributeDefinitions : [
92+ { AttributeName : 'supplierId' , AttributeType : 'S' } ,
93+ { AttributeName : 'id' , AttributeType : 'S' } ,
94+ ]
95+ } ) ;
96+
97+
98+ export async function createTables ( context : DBContext ) {
99+ const { ddbClient } = context ;
100+
101+ await ddbClient . send ( createLetterTableCommand ) ;
102+ await ddbClient . send ( updateTimeToLiveCommand ) ;
103+
104+ await ddbClient . send ( createMITableCommand ) ;
84105}
85106
86107
@@ -90,4 +111,8 @@ export async function deleteTables(context: DBContext) {
90111 await ddbClient . send ( new DeleteTableCommand ( {
91112 TableName : 'letters'
92113 } ) ) ;
114+
115+ await ddbClient . send ( new DeleteTableCommand ( {
116+ TableName : 'management-info'
117+ } ) ) ;
93118}
0 commit comments