|
6 | 6 | */ |
7 | 7 |
|
8 | 8 | import { NextResponse } from "next/server"; |
9 | | -// import prisma from "@/lib/prisma"; |
| 9 | +// import db from "@/lib/db/db"; |
10 | 10 |
|
11 | 11 | export async function GET() { |
12 | | - // Download data from old database |
13 | | - // const users = await prisma.user.findMany(); |
14 | | - // const accounts = await prisma.account.findMany(); |
15 | | - // const sites = await prisma.site.findMany(); |
16 | | - // const posts = await prisma.post.findMany(); |
17 | | - // const examples = await prisma.example.findMany(); |
| 12 | + // Download data from old database |
| 13 | + // const usersResult = await db.query.users.findMany(); |
| 14 | + // const accountsResult = await db.query.accounts.findMany(); |
| 15 | + // const sitesResult = await db.query.sites.findMany(); |
| 16 | + // const postsResult = await db.query.posts.findMany();; |
| 17 | + // const examplesResult = await db.query.examples.findMany();; |
18 | 18 |
|
19 | | - // fs.writeFileSync("users.json", JSON.stringify(users)); |
20 | | - // fs.writeFileSync("accounts.json", JSON.stringify(accounts)); |
21 | | - // fs.writeFileSync("sites.json", JSON.stringify(sites)); |
22 | | - // fs.writeFileSync("posts.json", JSON.stringify(posts)); |
23 | | - // fs.writeFileSync("examples.json", JSON.stringify(examples)); |
| 19 | + // fs.writeFileSync("users.json", JSON.stringify(usersResult)); |
| 20 | + // fs.writeFileSync("accounts.json", JSON.stringify(accountsResult)); |
| 21 | + // fs.writeFileSync("sites.json", JSON.stringify(sitesResult)); |
| 22 | + // fs.writeFileSync("posts.json", JSON.stringify(postsResult)); |
| 23 | + // fs.writeFileSync("examples.json", JSON.stringify(examplesResult)); |
24 | 24 |
|
25 | 25 | // Upload data to new database |
26 | | - // const users = JSON.parse(fs.readFileSync("users.json", "utf8")); |
27 | | - // const accounts = JSON.parse(fs.readFileSync("accounts.json", "utf8")); |
28 | | - // const sites = JSON.parse(fs.readFileSync("sites.json", "utf8")); |
29 | | - // const posts = JSON.parse(fs.readFileSync("posts.json", "utf8")); |
30 | | - // const examples = JSON.parse(fs.readFileSync("examples.json", "utf8")); |
| 26 | + // const parsedUsers = JSON.parse(fs.readFileSync("users.json", "utf8")); |
| 27 | + // const parsedAccounts = JSON.parse(fs.readFileSync("accounts.json", "utf8")); |
| 28 | + // const parsedSites = JSON.parse(fs.readFileSync("sites.json", "utf8")); |
| 29 | + // const parsedPosts = JSON.parse(fs.readFileSync("posts.json", "utf8")); |
| 30 | + // const parsedExamples = JSON.parse(fs.readFileSync("examples.json", "utf8")); |
31 | 31 |
|
32 | 32 | // const response = await Promise.all([ |
33 | | - // prisma.user.createMany({ |
34 | | - // data: users, |
35 | | - // skipDuplicates: true, |
36 | | - // }), |
37 | | - // prisma.account.createMany({ |
38 | | - // data: accounts, |
39 | | - // skipDuplicates: true, |
40 | | - // }), |
41 | | - // prisma.site.createMany({ |
42 | | - // data: sites, |
43 | | - // skipDuplicates: true, |
44 | | - // }), |
45 | | - // prisma.post.createMany({ |
46 | | - // data: posts, |
47 | | - // skipDuplicates: true, |
48 | | - // }), |
49 | | - // prisma.example.createMany({ |
50 | | - // data: examples, |
51 | | - // skipDuplicates: true, |
52 | | - // }) |
| 33 | + // db.insert(users).values(parsedUsers), |
| 34 | + // db.insert(accounts).values(parsedAccounts), |
| 35 | + // db.insert(sites).values(parsedSites), |
| 36 | + // db.insert(posts).values(parsedPosts), |
| 37 | + // db.insert(examples).values(parsedExamples) |
| 38 | + // ]); |
53 | 39 |
|
54 | 40 | return NextResponse.json({ response: "ok" }); |
55 | 41 | } |
0 commit comments