🐛 fix: race condition in seeding
This commit is contained in:
@ -6,8 +6,8 @@ async function main() {
|
|||||||
console.log("🌱 Running all seeds...");
|
console.log("🌱 Running all seeds...");
|
||||||
console.log("🔌 Connecting to database...");
|
console.log("🔌 Connecting to database...");
|
||||||
|
|
||||||
await userSystemSeed();
|
const userSystemSeedResult = await userSystemSeed();
|
||||||
await userRoleSeed();
|
const userRoleSeedResult = await userRoleSeed(userSystemSeedResult.id);
|
||||||
|
|
||||||
console.log("🌳 All seeds completed");
|
console.log("🌳 All seeds completed");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,8 @@
|
|||||||
import { SystemAccountId } from "../../src/config/account/system";
|
|
||||||
import { generateUUIDv7 } from "../../src/helpers/databases/uuidv7";
|
import { generateUUIDv7 } from "../../src/helpers/databases/uuidv7";
|
||||||
import { prisma } from "../../src/utils/databases/prisma/connection";
|
import { prisma } from "../../src/utils/databases/prisma/connection";
|
||||||
|
|
||||||
export const userRoleSeed = async () => {
|
export const userRoleSeed = async (SystemAccountId: string) => {
|
||||||
console.log("🔃 Seeding user roles...", SystemAccountId);
|
console.log("🔃 Seeding user roles...");
|
||||||
const roles = [
|
const roles = [
|
||||||
{
|
{
|
||||||
name: "ADMIN",
|
name: "ADMIN",
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import { MediaFullInfoResponse } from "../types/mediaFullInfo.type";
|
|||||||
import { generateSlug } from "../../../helpers/characters/generateSlug";
|
import { generateSlug } from "../../../helpers/characters/generateSlug";
|
||||||
import { bulkInsertCharWithVAService } from "./internal/bulkInsertCharWithVA.service";
|
import { bulkInsertCharWithVAService } from "./internal/bulkInsertCharWithVA.service";
|
||||||
import { generateUUIDv7 } from "../../../helpers/databases/uuidv7";
|
import { generateUUIDv7 } from "../../../helpers/databases/uuidv7";
|
||||||
|
import { SystemAccountId } from "../../../config/account/system";
|
||||||
|
|
||||||
export const bulkInsertAnimeService = async (malId: number) => {
|
export const bulkInsertAnimeService = async (malId: number) => {
|
||||||
try {
|
try {
|
||||||
@ -50,7 +51,7 @@ export const bulkInsertAnimeService = async (malId: number) => {
|
|||||||
mediaType: mediaFullInfo.data.type,
|
mediaType: mediaFullInfo.data.type,
|
||||||
source: mediaFullInfo.data.source,
|
source: mediaFullInfo.data.source,
|
||||||
onDraft: false,
|
onDraft: false,
|
||||||
uploadedBy: "b734b9bc-b4ea-408f-a80e-0a837ce884da",
|
uploadedBy: SystemAccountId,
|
||||||
};
|
};
|
||||||
const insertedMedia = await InsertMediaRepository({
|
const insertedMedia = await InsertMediaRepository({
|
||||||
malId: mediaFullInfo.data.mal_id,
|
malId: mediaFullInfo.data.mal_id,
|
||||||
|
|||||||
Reference in New Issue
Block a user