upgrade to prisma 3

This commit is contained in:
keyan 2023-07-26 11:01:31 -05:00
parent 5a4f63b1d5
commit 672853a7ea
18 changed files with 542 additions and 589 deletions

View File

@ -65,7 +65,7 @@ export default {
Query: {
registrationGrowth: async (parent, { when }, { models }) => {
if (when !== 'day') {
return await models.$queryRaw(`
return await models.$queryRawUnsafe(`
SELECT date_trunc('${timeUnit(when)}', day) as time, json_build_array(
json_build_object('name', 'referrals', 'value', sum(referrals)),
json_build_object('name', 'organic', 'value', sum(organic))
@ -76,7 +76,7 @@ export default {
ORDER BY time ASC`)
}
return await models.$queryRaw(
return await models.$queryRawUnsafe(
`${withClause(when)}
SELECT time, json_build_array(
json_build_object('name', 'referrals', 'value', count("referrerId")),
@ -89,7 +89,7 @@ export default {
},
spenderGrowth: async (parent, { when }, { models }) => {
if (when !== 'day') {
return await models.$queryRaw(`
return await models.$queryRawUnsafe(`
SELECT date_trunc('${timeUnit(when)}', day) as time, json_build_array(
json_build_object('name', 'any', 'value', floor(avg("any"))),
json_build_object('name', 'jobs', 'value', floor(avg(jobs))),
@ -104,7 +104,7 @@ export default {
ORDER BY time ASC`)
}
return await models.$queryRaw(
return await models.$queryRawUnsafe(
`${withClause(when)}
SELECT time, json_build_array(
json_build_object('name', 'any', 'value', count(DISTINCT "userId")),
@ -128,7 +128,7 @@ export default {
},
itemGrowth: async (parent, { when }, { models }) => {
if (when !== 'day') {
return await models.$queryRaw(`
return await models.$queryRawUnsafe(`
SELECT date_trunc('${timeUnit(when)}', day) as time, json_build_array(
json_build_object('name', 'posts', 'value', sum(posts)),
json_build_object('name', 'comments', 'value', sum(comments)),
@ -140,7 +140,7 @@ export default {
ORDER BY time ASC`)
}
return await models.$queryRaw(
return await models.$queryRawUnsafe(
`${withClause(when)}
SELECT time, json_build_array(
json_build_object('name', 'comments', 'value', count("parentId")),
@ -154,7 +154,7 @@ export default {
},
spendingGrowth: async (parent, { when }, { models }) => {
if (when !== 'day') {
return await models.$queryRaw(`
return await models.$queryRawUnsafe(`
SELECT date_trunc('${timeUnit(when)}', day) as time, json_build_array(
json_build_object('name', 'jobs', 'value', sum(jobs)),
json_build_object('name', 'boost', 'value', sum(boost)),
@ -168,7 +168,7 @@ export default {
ORDER BY time ASC`)
}
return await models.$queryRaw(
return await models.$queryRawUnsafe(
`${withClause(when)}
SELECT time, json_build_array(
json_build_object('name', 'jobs', 'value', coalesce(floor(sum(CASE WHEN act = 'STREAM' THEN msats ELSE 0 END)/1000),0)),
@ -191,7 +191,7 @@ export default {
},
stackerGrowth: async (parent, { when }, { models }) => {
if (when !== 'day') {
return await models.$queryRaw(`
return await models.$queryRawUnsafe(`
SELECT date_trunc('${timeUnit(when)}', day) as time, json_build_array(
json_build_object('name', 'any', 'value', floor(avg("any"))),
json_build_object('name', 'posts', 'value', floor(avg(posts))),
@ -205,7 +205,7 @@ export default {
ORDER BY time ASC`)
}
return await models.$queryRaw(
return await models.$queryRawUnsafe(
`${withClause(when)}
SELECT time, json_build_array(
json_build_object('name', 'any', 'value', count(distinct user_id)),
@ -233,7 +233,7 @@ export default {
},
stackingGrowth: async (parent, { when }, { models }) => {
if (when !== 'day') {
return await models.$queryRaw(`
return await models.$queryRawUnsafe(`
SELECT date_trunc('${timeUnit(when)}', day) as time, json_build_array(
json_build_object('name', 'rewards', 'value', sum(rewards)),
json_build_object('name', 'posts', 'value', sum(posts)),
@ -246,7 +246,7 @@ export default {
ORDER BY time ASC`)
}
return await models.$queryRaw(
return await models.$queryRawUnsafe(
`${withClause(when)}
SELECT time, json_build_array(
json_build_object('name', 'rewards', 'value', coalesce(floor(sum(airdrop)/1000),0)),

View File

@ -52,12 +52,12 @@ async function comments (me, models, id, sort) {
const filter = await commentFilterClause(me, models)
if (me) {
const [{ item_comments_with_me: comments }] = await models.$queryRaw(
const [{ item_comments_with_me: comments }] = await models.$queryRawUnsafe(
'SELECT item_comments_with_me($1, $2, $3, $4, $5)', Number(id), Number(me.id), COMMENT_DEPTH_LIMIT, filter, orderBy)
return comments
}
const [{ item_comments: comments }] = await models.$queryRaw(
const [{ item_comments: comments }] = await models.$queryRawUnsafe(
'SELECT item_comments($1, $2, $3, $4)', Number(id), COMMENT_DEPTH_LIMIT, filter, orderBy)
return comments
}
@ -211,7 +211,7 @@ function typeClause (type) {
// joining does not preserve the order of the inner query
async function itemQueryWithMeta ({ me, models, query, orderBy = '' }, ...args) {
if (!me) {
return await models.$queryRaw(`
return await models.$queryRawUnsafe(`
SELECT "Item".*, to_json(users.*) as user
FROM (
${query}
@ -219,7 +219,7 @@ async function itemQueryWithMeta ({ me, models, query, orderBy = '' }, ...args)
JOIN users ON "Item"."userId" = users.id
${orderBy}`, ...args)
} else {
return await models.$queryRaw(`
return await models.$queryRawUnsafe(`
SELECT "Item".*, to_json(users.*) as user, COALESCE("ItemAct"."meMsats", 0) as "meMsats",
COALESCE("ItemAct"."meDontLike", false) as "meDontLike", "Bookmark"."itemId" IS NOT NULL AS "meBookmark",
"ThreadSubscription"."itemId" IS NOT NULL AS "meSubscription"
@ -272,7 +272,7 @@ export default {
itemRepetition: async (parent, { parentId }, { me, models }) => {
if (!me) return 0
// how many of the parents starting at parentId belong to me
const [{ item_spam: count }] = await models.$queryRaw(`SELECT item_spam($1, $2, '${ITEM_SPAM_INTERVAL}')`,
const [{ item_spam: count }] = await models.$queryRawUnsafe(`SELECT item_spam($1, $2, '${ITEM_SPAM_INTERVAL}')`,
Number(parentId), Number(me.id))
return count
@ -621,7 +621,7 @@ export default {
throw new GraphQLError('item does not belong to you', { extensions: { code: 'FORBIDDEN' } })
}
const [item] = await serialize(models,
models.$queryRaw(`${SELECT} FROM update_poll($1, $2, $3, $4, $5, $6, $7) AS "Item"`,
models.$queryRawUnsafe(`${SELECT} FROM update_poll($1, $2, $3, $4, $5, $6, $7) AS "Item"`,
sub || 'bitcoin', Number(id), title, text, Number(boost || 0), options, Number(fwdUser?.id)))
await createMentions(item, models)
@ -629,7 +629,7 @@ export default {
return item
} else {
const [item] = await serialize(models,
models.$queryRaw(`${SELECT} FROM create_poll($1, $2, $3, $4, $5, $6, $7, $8, '${ITEM_SPAM_INTERVAL}') AS "Item"`,
models.$queryRawUnsafe(`${SELECT} FROM create_poll($1, $2, $3, $4, $5, $6, $7, $8, '${ITEM_SPAM_INTERVAL}') AS "Item"`,
sub || 'bitcoin', title, text, 1, Number(boost || 0), Number(me.id), options, Number(fwdUser?.id)))
await createMentions(item, models)
@ -658,12 +658,12 @@ export default {
throw new GraphQLError('item does not belong to you', { extensions: { code: 'FORBIDDEN' } })
}
([item] = await serialize(models,
models.$queryRaw(
models.$queryRawUnsafe(
`${SELECT} FROM update_job($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) AS "Item"`,
Number(id), title, url, text, Number(maxBid), company, loc, remote, Number(logo), status)))
} else {
([item] = await serialize(models,
models.$queryRaw(
models.$queryRawUnsafe(
`${SELECT} FROM create_job($1, $2, $3, $4, $5, $6, $7, $8, $9) AS "Item"`,
title, url, text, Number(me.id), Number(maxBid), company, loc, remote, Number(logo))))
}
@ -678,7 +678,7 @@ export default {
// fetch user to get up-to-date name
const user = await models.user.findUnique({ where: { id: me.id } })
const parents = await models.$queryRaw(
const parents = await models.$queryRawUnsafe(
'SELECT DISTINCT p."userId" FROM "Item" i JOIN "Item" p ON p.path @> i.path WHERE i.id = $1 and p."userId" <> $2',
Number(item.parentId), Number(me.id))
Promise.allSettled(
@ -702,7 +702,7 @@ export default {
}
await serialize(models,
models.$queryRaw(`${SELECT} FROM poll_vote($1, $2) AS "Item"`,
models.$queryRawUnsafe(`${SELECT} FROM poll_vote($1, $2) AS "Item"`,
Number(id), Number(me.id)))
return id
@ -716,7 +716,7 @@ export default {
await ssValidate(amountSchema, { amount: sats })
// disallow self tips
const [item] = await models.$queryRaw(`
const [item] = await models.$queryRawUnsafe(`
${SELECT}
FROM "Item"
WHERE id = $1 AND "userId" = $2`, Number(id), me.id)
@ -747,7 +747,7 @@ export default {
}
// disallow self down votes
const [item] = await models.$queryRaw(`
const [item] = await models.$queryRawUnsafe(`
${SELECT}
FROM "Item"
WHERE id = $1 AND "userId" = $2`, Number(id), me.id)
@ -858,8 +858,8 @@ export default {
if (!me) return 0
if (typeof item.meMsats === 'number') return msatsToSats(item.meMsats)
const { sum: { msats } } = await models.itemAct.aggregate({
sum: {
const { _sum: { msats } } = await models.itemAct.aggregate({
_sum: {
msats: true
},
where: {
@ -1034,7 +1034,7 @@ export const updateItem = async (parent, { id, data: { sub, title, url, text, bo
text = await proxyImages(text)
const [item] = await serialize(models,
models.$queryRaw(
models.$queryRawUnsafe(
`${SELECT} FROM update_item($1, $2, $3, $4, $5, $6, $7, $8) AS "Item"`,
old.parentId ? null : sub || 'bitcoin', Number(id), title, url, text,
Number(boost || 0), bounty ? Number(bounty) : null, Number(fwdUser?.id)))
@ -1070,7 +1070,7 @@ const createItem = async (parent, { sub, title, url, text, boost, forward, bount
const [item] = await serialize(
models,
models.$queryRaw(
models.$queryRawUnsafe(
`${SELECT} FROM create_item($1, $2, $3, $4, $5, $6, $7, $8, $9, '${ITEM_SPAM_INTERVAL}') AS "Item"`,
parentId ? null : sub || 'bitcoin',
title,

View File

@ -194,7 +194,7 @@ export default {
}
// we do all this crazy subquery stuff to make 'reward' islands
const notifications = await models.$queryRaw(
const notifications = await models.$queryRawUnsafe(
`SELECT MAX(id) AS id, MAX("sortTime") AS "sortTime", sum("earnedSats") AS "earnedSats", type,
MIN("sortTime") AS "minSortTime"
FROM
@ -286,7 +286,7 @@ export default {
},
Earn: {
sources: async (n, args, { me, models }) => {
const [sources] = await models.$queryRaw(`
const [sources] = await models.$queryRawUnsafe(`
SELECT
FLOOR(sum(msats) FILTER(WHERE type = 'POST') / 1000) AS posts,
FLOOR(sum(msats) FILTER(WHERE type = 'COMMENT') / 1000) AS comments,

View File

@ -8,21 +8,21 @@ export default {
throw new GraphQLError('you must be logged in', { extensions: { code: 'UNAUTHENTICATED' } })
}
const [{ totalSats }] = await models.$queryRaw(`
const [{ totalSats }] = await models.$queryRawUnsafe(`
SELECT COALESCE(FLOOR(sum(msats) / 1000), 0) as "totalSats"
FROM "ReferralAct"
WHERE ${intervalClause(when, 'ReferralAct', true)}
"ReferralAct"."referrerId" = $1
`, Number(me.id))
const [{ totalReferrals }] = await models.$queryRaw(`
const [{ totalReferrals }] = await models.$queryRawUnsafe(`
SELECT count(*) as "totalReferrals"
FROM users
WHERE ${intervalClause(when, 'users', true)}
"referrerId" = $1
`, Number(me.id))
const stats = await models.$queryRaw(
const stats = await models.$queryRawUnsafe(
`${withClause(when)}
SELECT time, json_build_array(
json_build_object('name', 'referrals', 'value', count(*) FILTER (WHERE act = 'REFERREE')),

View File

@ -42,7 +42,7 @@ export default {
await ssValidate(amountSchema, { amount: sats })
await serialize(models,
models.$queryRaw(
models.$queryRawUnsafe(
'SELECT donate($1, $2)',
sats, Number(me.id)))

View File

@ -5,7 +5,7 @@ async function serialize (models, call) {
return await retry(async bail => {
try {
const [, result] = await models.$transaction([
models.$executeRaw(SERIALIZE),
models.$executeRawUnsafe(SERIALIZE),
call
])
return result

View File

@ -119,7 +119,7 @@ export default {
},
topCowboys: async (parent, { cursor }, { models, me }) => {
const decodedCursor = decodeCursor(cursor)
const users = await models.$queryRaw(`
const users = await models.$queryRawUnsafe(`
SELECT users.*, floor(sum(msats_spent)/1000) as spent,
sum(posts) as nposts, sum(comments) as ncomments, sum(referrals) as referrals,
floor(sum(msats_stacked)/1000) as stacked
@ -149,7 +149,7 @@ export default {
default: column = 'stacked'; break
}
users = await models.$queryRaw(`
users = await models.$queryRawUnsafe(`
WITH u AS (
SELECT users.*, floor(sum(msats_spent)/1000) as spent,
sum(posts) as nposts, sum(comments) as ncomments, sum(referrals) as referrals,
@ -172,7 +172,7 @@ export default {
}
if (by === 'spent') {
users = await models.$queryRaw(`
users = await models.$queryRawUnsafe(`
SELECT users.*, sum(sats_spent) as spent
FROM
((SELECT "userId", floor(sum("ItemAct".msats)/1000) as sats_spent
@ -192,7 +192,7 @@ export default {
OFFSET $2
LIMIT ${LIMIT}`, decodedCursor.time, decodedCursor.offset)
} else if (by === 'posts') {
users = await models.$queryRaw(`
users = await models.$queryRawUnsafe(`
SELECT users.*, count(*) as nposts
FROM users
JOIN "Item" on "Item"."userId" = users.id
@ -204,7 +204,7 @@ export default {
OFFSET $2
LIMIT ${LIMIT}`, decodedCursor.time, decodedCursor.offset)
} else if (by === 'comments') {
users = await models.$queryRaw(`
users = await models.$queryRawUnsafe(`
SELECT users.*, count(*) as ncomments
FROM users
JOIN "Item" on "Item"."userId" = users.id
@ -216,7 +216,7 @@ export default {
OFFSET $2
LIMIT ${LIMIT}`, decodedCursor.time, decodedCursor.offset)
} else if (by === 'referrals') {
users = await models.$queryRaw(`
users = await models.$queryRawUnsafe(`
SELECT users.*, count(*) as referrals
FROM users
JOIN "users" referree on users.id = referree."referrerId"
@ -228,7 +228,7 @@ export default {
OFFSET $2
LIMIT ${LIMIT}`, decodedCursor.time, decodedCursor.offset)
} else {
users = await models.$queryRaw(`
users = await models.$queryRawUnsafe(`
SELECT u.id, u.name, u.streak, u."photoId", u."hideCowboyHat", floor(sum(amount)/1000) as stacked
FROM
((SELECT users.*, "ItemAct".msats as amount
@ -270,7 +270,7 @@ export default {
// check if any votes have been cast for them since checkedNotesAt
if (user.noteItemSats) {
const votes = await models.$queryRaw(`
const votes = await models.$queryRawUnsafe(`
SELECT 1
FROM "Item"
JOIN "ItemAct" ON
@ -286,7 +286,7 @@ export default {
}
// check if they have any replies since checkedNotesAt
const newReplies = await models.$queryRaw(`
const newReplies = await models.$queryRawUnsafe(`
SELECT 1
FROM "Item"
JOIN "Item" p ON
@ -302,7 +302,7 @@ export default {
}
// break out thread subscription to decrease the search space of the already expensive reply query
const newtsubs = await models.$queryRaw(`
const newtsubs = await models.$queryRawUnsafe(`
SELECT 1
FROM "ThreadSubscription"
JOIN "Item" p ON "ThreadSubscription"."itemId" = p.id
@ -318,7 +318,7 @@ export default {
// check if they have any mentions since checkedNotesAt
if (user.noteMentions) {
const newMentions = await models.$queryRaw(`
const newMentions = await models.$queryRawUnsafe(`
SELECT "Item".id, "Item".created_at
FROM "Mention"
JOIN "Item" ON "Mention"."itemId" = "Item".id
@ -379,7 +379,7 @@ export default {
// check if new invites have been redeemed
if (user.noteInvites) {
const newInvitees = await models.$queryRaw(`
const newInvitees = await models.$queryRawUnsafe(`
SELECT "Invite".id
FROM users JOIN "Invite" on users."inviteId" = "Invite".id
WHERE "Invite"."userId" = $1
@ -503,7 +503,7 @@ export default {
await updateItem(parent, { id: user.bioId, data: { text: bio, title: `@${user.name}'s bio` } }, { me, models })
} else {
const [item] = await serialize(models,
models.$queryRaw(`${SELECT} FROM create_bio($1, $2, $3) AS "Item"`,
models.$queryRawUnsafe(`${SELECT} FROM create_bio($1, $2, $3) AS "Item"`,
`@${user.name}'s bio`, bio, Number(me.id)))
await createMentions(item, models)
}
@ -645,7 +645,7 @@ export default {
// forever
return (user.stackedMsats && msatsToSats(user.stackedMsats)) || 0
} else if (when === 'day') {
const [{ stacked }] = await models.$queryRaw(`
const [{ stacked }] = await models.$queryRawUnsafe(`
SELECT sum(amount) as stacked
FROM
((SELECT coalesce(sum("ItemAct".msats),0) as amount
@ -673,8 +673,8 @@ export default {
return user.spent
}
const { sum: { msats } } = await models.itemAct.aggregate({
sum: {
const { _sum: { msats } } = await models.itemAct.aggregate({
_sum: {
msats: true
},
where: {

View File

@ -145,7 +145,7 @@ export default {
}
}
let history = await models.$queryRaw(`
let history = await models.$queryRawUnsafe(`
${queries.join(' UNION ALL ')}
ORDER BY "createdAt" DESC
OFFSET $3
@ -285,7 +285,7 @@ export default {
if (fact.type !== 'spent' && fact.type !== 'stacked') {
return null
}
const [item] = await models.$queryRaw(`
const [item] = await models.$queryRawUnsafe(`
${SELECT}
FROM "Item"
WHERE id = $1`, Number(fact.factId))

View File

@ -33,7 +33,7 @@ const createUserFilter = (tag) => {
}
const createItemUrl = async ({ id }) => {
const [rootItem] = await models.$queryRaw(
const [rootItem] = await models.$queryRawUnsafe(
'SELECT subpath(path, -LEAST(nlevel(path), $1), 1)::text AS id FROM "Item" WHERE id = $2',
COMMENT_DEPTH_LIMIT + 1, Number(id)
)

64
package-lock.json generated
View File

@ -14,7 +14,7 @@
"@graphql-tools/schema": "^10.0.0",
"@noble/curves": "^1.1.0",
"@opensearch-project/opensearch": "^2.3.1",
"@prisma/client": "^2.30.3",
"@prisma/client": "^3.15.2",
"@synonymdev/slashtags-auth": "^1.0.0-alpha.5",
"@synonymdev/slashtags-sdk": "^1.0.0-alpha.36",
"acorn": "^8.10.0",
@ -53,7 +53,7 @@
"page-metadata-parser": "^1.1.4",
"pageres": "^7.1.0",
"pg-boss": "^9.0.3",
"prisma": "^2.30.3",
"prisma": "^3.15.2",
"qrcode.react": "^3.1.0",
"react": "^18.2.0",
"react-avatar-editor": "^13.0.0",
@ -2982,15 +2982,15 @@
}
},
"node_modules/@prisma/client": {
"version": "2.30.3",
"resolved": "https://registry.npmjs.org/@prisma/client/-/client-2.30.3.tgz",
"integrity": "sha512-Ey2miZ+Hne12We3rA8XrlPoAF0iuKEhw5IK2nropaelSt0Ju3b2qSz9Qt50a/1Mx3+7yRSu/iSXt8y9TUMl/Yw==",
"version": "3.15.2",
"resolved": "https://registry.npmjs.org/@prisma/client/-/client-3.15.2.tgz",
"integrity": "sha512-ErqtwhX12ubPhU4d++30uFY/rPcyvjk+mdifaZO5SeM21zS3t4jQrscy8+6IyB0GIYshl5ldTq6JSBo1d63i8w==",
"hasInstallScript": true,
"dependencies": {
"@prisma/engines-version": "2.30.1-2.b8c35d44de987a9691890b3ddf3e2e7effb9bf20"
"@prisma/engines-version": "3.15.1-1.461d6a05159055555eb7dfb337c9fb271cbd4d7e"
},
"engines": {
"node": ">=12.2"
"node": ">=12.6"
},
"peerDependencies": {
"prisma": "*"
@ -3002,15 +3002,15 @@
}
},
"node_modules/@prisma/engines": {
"version": "2.30.1-2.b8c35d44de987a9691890b3ddf3e2e7effb9bf20",
"resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-2.30.1-2.b8c35d44de987a9691890b3ddf3e2e7effb9bf20.tgz",
"integrity": "sha512-WPnA/IUrxDihrRhdP6+8KAVSwsc0zsh8ioPYsLJjOhzVhwpRbuFH2tJDRIAbc+qFh+BbTIZbeyBYt8fpNXaYQQ==",
"version": "3.15.1-1.461d6a05159055555eb7dfb337c9fb271cbd4d7e",
"resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-3.15.1-1.461d6a05159055555eb7dfb337c9fb271cbd4d7e.tgz",
"integrity": "sha512-NHlojO1DFTsSi3FtEleL9QWXeSF/UjhCW0fgpi7bumnNZ4wj/eQ+BJJ5n2pgoOliTOGv9nX2qXvmHap7rJMNmg==",
"hasInstallScript": true
},
"node_modules/@prisma/engines-version": {
"version": "2.30.1-2.b8c35d44de987a9691890b3ddf3e2e7effb9bf20",
"resolved": "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-2.30.1-2.b8c35d44de987a9691890b3ddf3e2e7effb9bf20.tgz",
"integrity": "sha512-/iDRgaoSQC77WN2oDsOM8dn61fykm6tnZUAClY+6p+XJbOEgZ9gy4CKuKTBgrjSGDVjtQ/S2KGcYd3Ring8xaw=="
"version": "3.15.1-1.461d6a05159055555eb7dfb337c9fb271cbd4d7e",
"resolved": "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-3.15.1-1.461d6a05159055555eb7dfb337c9fb271cbd4d7e.tgz",
"integrity": "sha512-e3k2Vd606efd1ZYy2NQKkT4C/pn31nehyLhVug6To/q8JT8FpiMrDy7zmm3KLF0L98NOQQcutaVtAPhzKhzn9w=="
},
"node_modules/@protobufjs/aspromise": {
"version": "1.1.2",
@ -15025,19 +15025,19 @@
"integrity": "sha512-WuxUnVtlWL1OfZFQFuqvnvs6MiAGk9UNsBostyBOB0Is9wb5uRESevA6rnl/rkksXaGX3GzZhPup5d6Vp1nFew=="
},
"node_modules/prisma": {
"version": "2.30.3",
"resolved": "https://registry.npmjs.org/prisma/-/prisma-2.30.3.tgz",
"integrity": "sha512-48qYba2BIyUmXuosBZs0g3kYGrxKvo4VkSHYOuLlDdDirmKyvoY2hCYMUYHSx3f++8ovfgs+MX5KmNlP+iAZrQ==",
"version": "3.15.2",
"resolved": "https://registry.npmjs.org/prisma/-/prisma-3.15.2.tgz",
"integrity": "sha512-nMNSMZvtwrvoEQ/mui8L/aiCLZRCj5t6L3yujKpcDhIPk7garp8tL4nMx2+oYsN0FWBacevJhazfXAbV1kfBzA==",
"hasInstallScript": true,
"dependencies": {
"@prisma/engines": "2.30.1-2.b8c35d44de987a9691890b3ddf3e2e7effb9bf20"
"@prisma/engines": "3.15.1-1.461d6a05159055555eb7dfb337c9fb271cbd4d7e"
},
"bin": {
"prisma": "build/index.js",
"prisma2": "build/index.js"
},
"engines": {
"node": ">=12.2"
"node": ">=12.6"
}
},
"node_modules/prismjs": {
@ -22131,22 +22131,22 @@
"integrity": "sha512-P1st0aksCrn9sGZhp8GMYwBnQsbvAWsZAX44oXNNvLHGqAOcoVxmjZiohstwQ7SqKnbR47akdNi+uleWD8+g6A=="
},
"@prisma/client": {
"version": "2.30.3",
"resolved": "https://registry.npmjs.org/@prisma/client/-/client-2.30.3.tgz",
"integrity": "sha512-Ey2miZ+Hne12We3rA8XrlPoAF0iuKEhw5IK2nropaelSt0Ju3b2qSz9Qt50a/1Mx3+7yRSu/iSXt8y9TUMl/Yw==",
"version": "3.15.2",
"resolved": "https://registry.npmjs.org/@prisma/client/-/client-3.15.2.tgz",
"integrity": "sha512-ErqtwhX12ubPhU4d++30uFY/rPcyvjk+mdifaZO5SeM21zS3t4jQrscy8+6IyB0GIYshl5ldTq6JSBo1d63i8w==",
"requires": {
"@prisma/engines-version": "2.30.1-2.b8c35d44de987a9691890b3ddf3e2e7effb9bf20"
"@prisma/engines-version": "3.15.1-1.461d6a05159055555eb7dfb337c9fb271cbd4d7e"
}
},
"@prisma/engines": {
"version": "2.30.1-2.b8c35d44de987a9691890b3ddf3e2e7effb9bf20",
"resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-2.30.1-2.b8c35d44de987a9691890b3ddf3e2e7effb9bf20.tgz",
"integrity": "sha512-WPnA/IUrxDihrRhdP6+8KAVSwsc0zsh8ioPYsLJjOhzVhwpRbuFH2tJDRIAbc+qFh+BbTIZbeyBYt8fpNXaYQQ=="
"version": "3.15.1-1.461d6a05159055555eb7dfb337c9fb271cbd4d7e",
"resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-3.15.1-1.461d6a05159055555eb7dfb337c9fb271cbd4d7e.tgz",
"integrity": "sha512-NHlojO1DFTsSi3FtEleL9QWXeSF/UjhCW0fgpi7bumnNZ4wj/eQ+BJJ5n2pgoOliTOGv9nX2qXvmHap7rJMNmg=="
},
"@prisma/engines-version": {
"version": "2.30.1-2.b8c35d44de987a9691890b3ddf3e2e7effb9bf20",
"resolved": "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-2.30.1-2.b8c35d44de987a9691890b3ddf3e2e7effb9bf20.tgz",
"integrity": "sha512-/iDRgaoSQC77WN2oDsOM8dn61fykm6tnZUAClY+6p+XJbOEgZ9gy4CKuKTBgrjSGDVjtQ/S2KGcYd3Ring8xaw=="
"version": "3.15.1-1.461d6a05159055555eb7dfb337c9fb271cbd4d7e",
"resolved": "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-3.15.1-1.461d6a05159055555eb7dfb337c9fb271cbd4d7e.tgz",
"integrity": "sha512-e3k2Vd606efd1ZYy2NQKkT4C/pn31nehyLhVug6To/q8JT8FpiMrDy7zmm3KLF0L98NOQQcutaVtAPhzKhzn9w=="
},
"@protobufjs/aspromise": {
"version": "1.1.2",
@ -30717,11 +30717,11 @@
"integrity": "sha512-WuxUnVtlWL1OfZFQFuqvnvs6MiAGk9UNsBostyBOB0Is9wb5uRESevA6rnl/rkksXaGX3GzZhPup5d6Vp1nFew=="
},
"prisma": {
"version": "2.30.3",
"resolved": "https://registry.npmjs.org/prisma/-/prisma-2.30.3.tgz",
"integrity": "sha512-48qYba2BIyUmXuosBZs0g3kYGrxKvo4VkSHYOuLlDdDirmKyvoY2hCYMUYHSx3f++8ovfgs+MX5KmNlP+iAZrQ==",
"version": "3.15.2",
"resolved": "https://registry.npmjs.org/prisma/-/prisma-3.15.2.tgz",
"integrity": "sha512-nMNSMZvtwrvoEQ/mui8L/aiCLZRCj5t6L3yujKpcDhIPk7garp8tL4nMx2+oYsN0FWBacevJhazfXAbV1kfBzA==",
"requires": {
"@prisma/engines": "2.30.1-2.b8c35d44de987a9691890b3ddf3e2e7effb9bf20"
"@prisma/engines": "3.15.1-1.461d6a05159055555eb7dfb337c9fb271cbd4d7e"
}
},
"prismjs": {

View File

@ -15,7 +15,7 @@
"@graphql-tools/schema": "^10.0.0",
"@noble/curves": "^1.1.0",
"@opensearch-project/opensearch": "^2.3.1",
"@prisma/client": "^2.30.3",
"@prisma/client": "^3.15.2",
"@synonymdev/slashtags-auth": "^1.0.0-alpha.5",
"@synonymdev/slashtags-sdk": "^1.0.0-alpha.36",
"acorn": "^8.10.0",
@ -54,7 +54,7 @@
"page-metadata-parser": "^1.1.4",
"pageres": "^7.1.0",
"pg-boss": "^9.0.3",
"prisma": "^2.30.3",
"prisma": "^3.15.2",
"qrcode.react": "^3.1.0",
"react": "^18.2.0",
"react-avatar-editor": "^13.0.0",

View File

@ -5,7 +5,7 @@ export default async (_, res) => {
// this should probably be made more generic
// eg if the title changes this will break
// ... but this will need to change when we have more subs anyway
const [{ id }] = await models.$queryRaw(`
const [{ id }] = await models.$queryRawUnsafe(`
SELECT id
FROM "Item"
WHERE "pinId" IS NOT NULL

View File

@ -33,7 +33,7 @@ export async function getServerSideProps ({ req, res, query: { id, error = null
// attempt to send gift
// catch any errors and just ignore them for now
await serialize(models,
models.$queryRaw('SELECT invite_drain($1, $2)', session.user.id, id))
models.$queryRawUnsafe('SELECT invite_drain($1, $2)', session.user.id, id))
} catch (e) {
console.log(e)
}

File diff suppressed because it is too large Load Diff

View File

@ -42,7 +42,7 @@ function earn ({ models }) {
}
// get earners { userId, id, type, rank, proportion }
const earners = await models.$queryRaw(`
const earners = await models.$queryRawUnsafe(`
WITH item_ratios AS (
SELECT *,
CASE WHEN "parentId" IS NULL THEN 'POST' ELSE 'COMMENT' END as type,

View File

@ -7,7 +7,7 @@ function computeStreaks ({ models }) {
// get all eligible users in the last day
// if the user doesn't have an active streak, add one
// if they have an active streak but didn't maintain it, end it
await models.$executeRaw(
await models.$executeRawUnsafe(
`WITH day_streaks (id) AS (
SELECT "userId"
FROM

View File

@ -165,7 +165,7 @@ async function storeTrust (models, nodeTrust) {
// update the trust of each user in graph
await models.$transaction([
models.$executeRaw`UPDATE users SET trust = 0`,
models.$executeRaw(
models.$executeRawUnsafe(
`UPDATE users
SET trust = g.trust
FROM (values ${values}) g(id, trust)

View File

@ -6,7 +6,7 @@ function views ({ models }) {
for (const view of ['reg_growth_days', 'spender_growth_days', 'item_growth_days',
'spending_growth_days', 'stackers_growth_days', 'stacking_growth_days',
'user_stats_days']) {
await models.$queryRaw(`REFRESH MATERIALIZED VIEW CONCURRENTLY ${view}`)
await models.$queryRawUnsafe(`REFRESH MATERIALIZED VIEW CONCURRENTLY ${view}`)
}
console.log('done refreshing stats views')
@ -19,7 +19,7 @@ function rankViews ({ models }) {
console.log('refreshing rank views')
for (const view of ['sat_rank_wwm_view', 'sat_rank_tender_view']) {
await models.$queryRaw(`REFRESH MATERIALIZED VIEW CONCURRENTLY ${view}`)
await models.$queryRawUnsafe(`REFRESH MATERIALIZED VIEW CONCURRENTLY ${view}`)
}
console.log('done refreshing rank views')