attempts pt. 2
This commit is contained in:
@@ -25,7 +25,10 @@ async function initDb() {
|
||||
}
|
||||
|
||||
async function serverDb() {
|
||||
const { initDb } = await import("..");
|
||||
if (!import.meta.env.SSR) return null;
|
||||
const { building } = await import("$app/environment");
|
||||
if (building) return null;
|
||||
const { initDb } = await import("../server");
|
||||
return initDb();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import "dotenv/config";
|
||||
import { eq } from "drizzle-orm";
|
||||
import { z } from "zod";
|
||||
import {
|
||||
@@ -12,7 +13,6 @@ import amqArtistsJson from "../../../data/amq-artists.json" with {
|
||||
};
|
||||
import amqGroupsJson from "../../../data/amq-groups.json" with { type: "json" };
|
||||
import amqSongsJson from "../../../data/amq-songs.json" with { type: "json" };
|
||||
import { db } from "./index";
|
||||
import {
|
||||
anime,
|
||||
animeGenres,
|
||||
@@ -30,6 +30,7 @@ import {
|
||||
songs,
|
||||
tags,
|
||||
} from "./schema";
|
||||
import { initDb } from "./server";
|
||||
|
||||
/**
|
||||
* AMQ JSON import routine
|
||||
@@ -182,6 +183,7 @@ export async function importAmqData(
|
||||
}
|
||||
|
||||
// 2) Apply inserts in a transaction
|
||||
const db = await initDb();
|
||||
db.transaction(() => {
|
||||
if (wipeFirst) {
|
||||
// Child tables first, then parents (respect FKs)
|
||||
|
||||
Reference in New Issue
Block a user