https://serverless-stack.com/ logo
#sst
Title
# sst
j

jamlen

03/10/2022, 9:21 AM
With the migrations for RDS databases, if I create multiple database, how do the migrations know which database to run them against?
Is it just that I keep the scripts for each DB separate?
Copy code
new sst.RDS(this, "CustomersDb", {
            engine: "postgresql10.14",
            defaultDatabaseName: "Customers",
            migrations: "scripts/migrations/customers",
        })

        new sst.RDS(this, "FulfillmentDb", {
            engine: "postgresql10.14",
            defaultDatabaseName: "Fulfillment",
            migrations: "scripts/migrations/fulfillment",
        })
t

thdxr

03/10/2022, 2:13 PM
we pass in the right DB when executing the script
each cluster gets its own lambda function that runs migrations
f

Frank

03/10/2022, 5:19 PM
@jamlen by “multiple database” you mean multiple
RDS
constructs like the snippet above right?
j

jamlen

03/10/2022, 5:20 PM
@Frank yes, each of our stacks are having their own RDS DB
f

Frank

03/10/2022, 5:22 PM
I see.. b/c each RDS construct can contain multiple databases. Just wanted to clarify it.
So yeah, if u have multiple RDS constructs, each get their own
migrations
lambda function
j

jamlen

03/10/2022, 5:32 PM
@Frank do the migration files have to be in js format? I'm getting
Copy code
ERROR TypeError: Unknown file extension ".ts" for ~/dev/src/github.com/jamlen/demo/backend/scripts/migrations/customers/00001-init-customers.ts
Its not very clear in the docs
t

thdxr

03/10/2022, 5:47 PM
yeah we currently require them to be in js, have ideas for supporting ts but not implemented yet
3 Views