-
Notifications
You must be signed in to change notification settings - Fork 465
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
fix(connections): add FK to end users #2883
Conversation
@@ -7,6 +7,7 @@ export type ConnectionConfig = Record<string, any>; | |||
export interface BaseConnection extends TimestampsAndDeleted { | |||
id?: number; | |||
config_id?: number; | |||
end_user_id?: number; |
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.
undefined on purpose until I fix the implementation
*/ | ||
exports.up = async function (knex) { | ||
await knex.raw(`ALTER TABLE "_nango_connections" ADD COLUMN "end_user_id" int4`); | ||
await knex.raw(`ALTER TABLE "_nango_connections" ADD FOREIGN KEY ("end_user_id") REFERENCES "end_users" ("id") ON DELETE SET NULL`); |
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.
can we not do that in one single query:
ALTER TABLE "_nango_connections"
ADD COLUMN "end_user_id" int4,
ADD FOREIGN KEY ("end_user_id") REFERENCES "end_users" ("id") ON DELETE SET NULL;
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'm sure I could, not sure what would be the benefit, it's 2 different queries
Describe your changes
Contributes to https://linear.app/nango/issue/NAN-1944/connect-end-users-to-connections
Add Foreign Key from connections to end_users
Implementation will come after
Add Foreign Key from oauth_session to connect_session to be able to get back the session on the callback
Implementation will come after