-
Notifications
You must be signed in to change notification settings - Fork 10
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
Introduce Postgres DB Adapter #1157
Introduce Postgres DB Adapter #1157
Conversation
let result = await adapter.execute(` | ||
SELECT column_name | ||
FROM information_schema.columns | ||
WHERE table_schema = 'public' -- Replace 'public' with the schema name if it's different |
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.
Maybe this comment isn’t needed three times? Or at all, in a test 🤔
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.
Copy-pasta from chat gpt—I’ll clean up
} | ||
|
||
await migrate({ | ||
direction: 'up', |
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.
Should we also add support for rollbacks by providing direction (up, down) as a param to migrateDb
?
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.
So you can run migrations from the command line to go up or down. But when the realm server spins up we don’t want to run migrations down—ever.
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’ll add docs for running migrations from command line as well as generating the schema file for sql lite as part of the same PR)
prepareTestDB(); | ||
}); | ||
|
||
test('it can connect to the DB and run migrations', async function (assert) { |
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.
Maybe I am missing something but I don't see how this test exercises migrations?
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 I see, the migrations are run in the setup and then this test checks whether the migration succeeded.
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.
Are we planning on adding support for having a schema and a seed file, and use that for setting up the test db, as opposed to running all the migrations on setup?
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.
Yeah, the fact we even have a table with columns is because migrations ran.
Yes there will be a schema file that is generated from the db. That’s the next ticket that I’m working on 😉
This PR introduces a postgres DB adapter that has the ability to run migrations. I'm using docker to run postgres which makes it really convenient for running locally on dev's machines as well as CI. With docker there is nothing extra that a dev has to do in order to get postgres running. I'm running postgres on port 5435 for dev and test so if you do happen to have postgres installed natively on your system it wont collide with that. The postgres DB will start automatically as part of running
pnpm start:all
in packages/realm-server