@@ -30,6 +30,7 @@ export async function setupDynamoDBContainer() {
3030 region : 'us-west-2' ,
3131 endpoint,
3232 lettersTableName : 'letters' ,
33+ miTableName : 'management-info' ,
3334 ttlHours : 1
3435 } ;
3536
@@ -44,10 +45,7 @@ export async function setupDynamoDBContainer() {
4445
4546export type DBContext = Awaited < ReturnType < typeof setupDynamoDBContainer > > ;
4647
47- export async function createTables ( context : DBContext ) {
48- const { ddbClient } = context ;
49-
50- await ddbClient . send ( new CreateTableCommand ( {
48+ const createLetterTableCommand = new CreateTableCommand ( {
5149 TableName : 'letters' ,
5250 BillingMode : 'PAY_PER_REQUEST' ,
5351 KeySchema : [
@@ -72,15 +70,37 @@ export async function createTables(context: DBContext) {
7270 { AttributeName : 'supplierStatus' , AttributeType : 'S' } ,
7371 { AttributeName : 'supplierStatusSk' , AttributeType : 'S' } ,
7472 ]
75- } ) ) ;
73+ } ) ;
7674
77- await ddbClient . send ( new UpdateTimeToLiveCommand ( {
75+ const updateTimeToLiveCommand = new UpdateTimeToLiveCommand ( {
7876 TableName : 'letters' ,
7977 TimeToLiveSpecification : {
8078 AttributeName : 'ttl' ,
8179 Enabled : true
8280 }
83- } ) ) ;
81+ } ) ;
82+
83+ const createMITableCommand = new CreateTableCommand ( {
84+ TableName : 'management-info' ,
85+ BillingMode : 'PAY_PER_REQUEST' ,
86+ KeySchema : [
87+ { AttributeName : 'supplierId' , KeyType : 'HASH' } , // Partition key
88+ { AttributeName : 'id' , KeyType : 'RANGE' } // Sort key
89+ ] ,
90+ AttributeDefinitions : [
91+ { AttributeName : 'supplierId' , AttributeType : 'S' } ,
92+ { AttributeName : 'id' , AttributeType : 'S' } ,
93+ ]
94+ } ) ;
95+
96+
97+ export async function createTables ( context : DBContext ) {
98+ const { ddbClient } = context ;
99+
100+ await ddbClient . send ( createLetterTableCommand ) ;
101+ await ddbClient . send ( updateTimeToLiveCommand ) ;
102+
103+ await ddbClient . send ( createMITableCommand ) ;
84104}
85105
86106
@@ -90,4 +110,8 @@ export async function deleteTables(context: DBContext) {
90110 await ddbClient . send ( new DeleteTableCommand ( {
91111 TableName : 'letters'
92112 } ) ) ;
113+
114+ await ddbClient . send ( new DeleteTableCommand ( {
115+ TableName : 'management-info'
116+ } ) ) ;
93117}
0 commit comments