hey folks, my team is planning to use Aurora Postg...
# help
m
hey folks, my team is planning to use Aurora Postgresql Is there any pattern/good practices using SST for schema migration?
s
if you mean migration in the sense of knex-style migration (building up iterations of DB table changes), I just use knex in my SST project. I have a
db
folder that has migrations & seeds in it
m
@Sam Hulick, that’s exactly what I mean
how do you run this migration?
t
we're putting together a more advanced sample project that will have this
in there we're using
kysely
and running migrations through
sst.Script
s
@Marcos Sampaio I'll dump some examples here in a bit
@Marcos Sampaio this is my project structure (SST project).. just the database part:
Copy code
├── knex-get-secrets.js
├── knex-util.js
├── knexfile.js
├── migrations
│   ├── 005_create_functions.js
│   ├── 010_create_types.js
│   ├── 020_create_users.js
│   └── ...etc...
└── seeds
    ├── 10_themes.js
    ├── 20_plans.js
    ├── 30_features.js
    └── 40_groups.js
I’ve got a couple of scripts in package.json
Copy code
"db:migrate": "knex --knexfile db/knexfile.js migrate:latest",
    "db:seed": "knex --knexfile db/knexfile.js seed:run",
that’s really about it!
I mean, assuming you’re familiar with knex.. all that above should make sense
and if I make changes to the DB, I just do
yarn knex migrate:make whatever
and then
yarn db:migrate
m
thanks guys
t
This is still very rough with little documentation but if you want a preview of our kysely + migrations setup checkout this: https://github.com/serverless-stack/graphql-stack/tree/main/backend
We have a migrator functioin in there that youc an invoke from console to run migrations
m
thank you so much, @thdxr!