-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into link-folders
- Loading branch information
Showing
12 changed files
with
1,853 additions
and
1,488 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { prisma } from "@dub/prisma"; | ||
import "dotenv-flow/config"; | ||
import { bulkDeleteLinks } from "../lib/api/links/bulk-delete-links"; | ||
|
||
async function main() { | ||
const partners = await prisma.partner.findMany({ | ||
where: { | ||
programs: { | ||
some: { | ||
programId: "prog_xxx", | ||
}, | ||
}, | ||
}, | ||
include: { | ||
programs: { | ||
select: { | ||
links: true, | ||
}, | ||
}, | ||
}, | ||
take: 1, | ||
}); | ||
|
||
for (const partner of partners) { | ||
const programEnrollment = partner.programs[0]; | ||
const links = programEnrollment.links; | ||
|
||
const deleteLinkCaches = await bulkDeleteLinks(links); | ||
console.log("Deleted link caches", deleteLinkCaches); | ||
|
||
const deleteLinks = await prisma.link.deleteMany({ | ||
where: { | ||
id: { | ||
in: links.map((link) => link.id), | ||
}, | ||
}, | ||
}); | ||
console.log("Deleted links", deleteLinks); | ||
|
||
const deleteSales = await prisma.sale.deleteMany({ | ||
where: { | ||
partnerId: partner.id, | ||
}, | ||
}); | ||
console.log("Deleted sales", deleteSales); | ||
|
||
const deletePayouts = await prisma.payout.deleteMany({ | ||
where: { | ||
partnerId: partner.id, | ||
}, | ||
}); | ||
console.log("Deleted payouts", deletePayouts); | ||
|
||
const deletePartner = await prisma.partner.delete({ | ||
where: { | ||
id: partner.id, | ||
}, | ||
}); | ||
console.log("Deleted partner", deletePartner); | ||
} | ||
} | ||
|
||
main(); |
Oops, something went wrong.