mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-08 14:28:20 +00:00
Merge pull request #1719 from Infisical/daniel/migration-fix
Fix: Duplicate org membership migration
This commit is contained in:
@@ -42,6 +42,7 @@ export async function up(knex: Knex): Promise<void> {
|
|||||||
await knex.transaction(async (tx) => {
|
await knex.transaction(async (tx) => {
|
||||||
const duplicateRows = await tx(TableName.OrgMembership)
|
const duplicateRows = await tx(TableName.OrgMembership)
|
||||||
.select("userId", "orgId") // Select the userId and orgId so we can group by them
|
.select("userId", "orgId") // Select the userId and orgId so we can group by them
|
||||||
|
.whereNotNull("userId") // Ensure that the userId is not null
|
||||||
.count("* as cnt") // Count the number of rows for each userId and orgId, so we can make sure there are more than 1 row (a duplicate)
|
.count("* as cnt") // Count the number of rows for each userId and orgId, so we can make sure there are more than 1 row (a duplicate)
|
||||||
.groupBy("userId", "orgId")
|
.groupBy("userId", "orgId")
|
||||||
.havingRaw("count(*) > ?", [1]); // Using havingRaw for direct SQL expressions
|
.havingRaw("count(*) > ?", [1]); // Using havingRaw for direct SQL expressions
|
||||||
|
|||||||
Reference in New Issue
Block a user