-
-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate schema definition and migrations to Drizzle #433
base: main
Are you sure you want to change the base?
Conversation
🚅 Deployed to the one-pr-433 environment in onestack.dev
|
apps/chat/docker-compose.yml
Outdated
@@ -5,15 +5,15 @@ services: | |||
user: postgres | |||
restart: always | |||
healthcheck: | |||
test: 'pg_isready -U user --dbname=postgres' | |||
test: 'pg_isready -U user --dbname=onechat' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a diff between the database name in the .env
you provided earlier and the actual setup, so I adjusted it to match the environment variables. @natew
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you are creating a Database onechat inside init.sql, i dont think you intended to make the onechat as an default DB. Sticking to postgres as default one is correct (or at least should have different name than onechat if you want to create onechat inside init.sql)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense @cermakondrej
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yeah you are right, thank you! @cermakondrej
apps/chat/src/postgres/seed.ts
Outdated
) | ||
VALUES ${valueStrings.join(',')} | ||
`, | ||
values: values.flatMap((v) => [v.id, v.value, v.keyword, v.created_at, v.updated_at]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can also define the seed data here in TypeScript with Drizzle, which was previously defined in the raw seed.sql.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i had some of that work in the old pr
@poteboy lets update this and see if it works with the new drizzle zero so we can merge |
This PR migrates our schema management from Zero to Drizzle as Drizzle now supports many-to-many relationships. I'm also separating database initialization from schema management, where Docker only handles database creation while Drizzle manages schema and migrations.
Please review the schema mappings carefully, as there might be subtle differences in how relationships are defined between Zero and Drizzle. @natew
Changes
seed.sql
, keeping only database creation ininit.sql
Technical Details
init.sql
in DockerNext Steps
drizzle-zero
to support self-referential many-to-many relationships (feat: add handling keypress inputs #29)Related Issues