-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TECH] Ajouter une contrainte sur la table last-user-application-conn…
- Loading branch information
Showing
2 changed files
with
27 additions
and
7 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
.../migrations/20250228155843_add-unicity-constraint-in-last-user-application-connections.js
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,23 @@ | ||
const TABLE_NAME = 'last-user-application-connections'; | ||
|
||
/** | ||
* @param { import("knex").Knex } knex | ||
* @returns { Promise<void> } | ||
*/ | ||
const up = async function (knex) { | ||
return knex.schema.table(TABLE_NAME, (table) => { | ||
table.unique(['userId', 'application']); | ||
}); | ||
}; | ||
|
||
/** | ||
* @param { import("knex").Knex } knex | ||
* @returns { Promise<void> } | ||
*/ | ||
const down = async function (knex) { | ||
return knex.schema.table(TABLE_NAME, (table) => { | ||
table.dropUnique(['userId', 'application']); | ||
}); | ||
}; | ||
|
||
export { down, up }; |
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