-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Database migration from Mongo to Postgres throwing type error in existing files. #9565
Comments
jacobsfletch
pushed a commit
that referenced
this issue
Nov 27, 2024
Fixes #9565 multi-tenant compatibility with Postgres (and custom IDs) Adds a useful `extractID` utility: ```ts import { Config } from '@/payload-types' import type { CollectionSlug } from 'payload' export const extractID = <T extends Config['collections'][CollectionSlug]>( objectOrID: T | T['id'], ): T['id'] => { if (objectOrID && typeof objectOrID === 'object') return objectOrID.id return objectOrID } ```
This issue has been automatically locked. |
🚀 This is included in version v3.2.2 |
kendelljoseph
pushed a commit
that referenced
this issue
Feb 21, 2025
Fixes #9565 multi-tenant compatibility with Postgres (and custom IDs) Adds a useful `extractID` utility: ```ts import { Config } from '@/payload-types' import type { CollectionSlug } from 'payload' export const extractID = <T extends Config['collections'][CollectionSlug]>( objectOrID: T | T['id'], ): T['id'] => { if (objectOrID && typeof objectOrID === 'object') return objectOrID.id return objectOrID } ```
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Describe the Bug
I'm working on a multi-tenancy project by following this example here.
and it works fine.
Then later I shifted the database from Mongo to Postgres and got a lot of type errors and bugs. I think it will be better to have a proper type check even if we switch the database
Sample screenshots:
Throwing type error while getting the TenantAccessIDs (Unable to login as tenant-admin)
Throws undefined in the getTenantAccessIDs function
Select tenant dropdown value is not updating properly.
Link to the code that reproduces this issue
https://github.com/payloadcms/payload/tree/main/examples/multi-tenant
Reproduction Steps
Follow the readme from this example - https://github.com/payloadcms/payload/tree/main/examples/multi-tenant
Try switching the database from MongoDB to Postgres
Note: I even got some errors in seeding. Then this is what I did, remove
ensureUniqueUsername
from this path(examples/multi-tenant/src/collections/Users/index.ts
) then delete the multi-admin creation from seed.ts thenmigrate:create
followed bymigrate:fresh
Which area(s) are affected? (Select all that apply)
db-postgres
Environment Info
The text was updated successfully, but these errors were encountered: