Skip to content
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

fix(connections): add FK to end users #2883

Merged
merged 6 commits into from
Oct 24, 2024

Conversation

bodinsamuel
Copy link
Collaborator

@bodinsamuel bodinsamuel commented Oct 24, 2024

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

@bodinsamuel bodinsamuel self-assigned this Oct 24, 2024
Copy link

linear bot commented Oct 24, 2024

@@ -7,6 +7,7 @@ export type ConnectionConfig = Record<string, any>;
export interface BaseConnection extends TimestampsAndDeleted {
id?: number;
config_id?: number;
end_user_id?: number;
Copy link
Collaborator Author

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`);
Copy link
Collaborator

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;

Copy link
Collaborator Author

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

@bodinsamuel bodinsamuel merged commit 7bc3a17 into master Oct 24, 2024
21 checks passed
@bodinsamuel bodinsamuel deleted the sam/fix/connections-fk-end-users branch October 24, 2024 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants