-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Add schema support for ensureTableInDatabase
#4504
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Thank you! |
Oh hey - should this be in quotes like this? |
Would setting the default schema like this not be breaking for users who've set a search path other than "public" ? |
I'll change it |
@MJDeligan Yes, you are right. The example below overrides schema just fine await store.appDataSource.query(`set search_path=${schema}`);
await store..ensureTableInDatabase(); I guess this PR is no longer needed. |
We could use a different query based on the presence/absence of Sort of like this: #4543 |
And thanks for flagging @MJDeligan! |
Oh right, so when the schema is present I prepend it with the table name otherwise it stays as it is. |
Looks good! I'm not familiar with TypeORM. How does it know to use the schema for the other operations? Would that have to passed as part of the postgres connection options? |
Yes, in TypeORM schema can be specified when driver is Postgres. When it's omitted it fallbacks to public at least in most cases but the logic can be seen here https://github.com/typeorm/typeorm/blob/master/src/driver/postgres/PostgresDriver.ts#L360 |
@jacoblee93 wdyt? |
Added schema name to override it when needed.
It's backward-compatible and should not break existing functionality.
Fixes #4503