-
Notifications
You must be signed in to change notification settings - Fork 428
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(connections): add FK to end users (#2883)
## 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
- Loading branch information
1 parent
5f5d9e3
commit 7bc3a17
Showing
5 changed files
with
22 additions
and
0 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
packages/database/lib/migrations/20241024094439_connections_end_user.cjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* @param {import('knex').Knex} knex | ||
*/ | ||
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`); | ||
|
||
await knex.raw(`ALTER TABLE "_nango_oauth_sessions" ADD COLUMN "connect_session_id" int4`); | ||
await knex.raw(`ALTER TABLE "_nango_oauth_sessions" ADD FOREIGN KEY ("connect_session_id") REFERENCES "connect_sessions" ("id") ON DELETE SET NULL`); | ||
}; | ||
|
||
/** | ||
* @param {import('knex').Knex} knex | ||
*/ | ||
exports.down = async function (knex) { | ||
await knex.raw(`ALTER TABLE "_nango_connections" DROP COLUMN "end_user_id"`); | ||
await knex.raw(`ALTER TABLE "_nango_oauth_sessions" DROP COLUMN "connect_session_id"`); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters