Sebastian
Sebastian
Explore posts from servers
TTCTheo's Typesafe Cult
Created by Sebastian on 1/4/2024 in #questions
Prisma turborepo deployment not initialized error
Wow, for anybody else who can't read like me, the solution is in the error message. Find out why and learn how to fix this: https://pris.ly/d/schema-not-found-nextjs apparently it's a known issue and it's even a workaround plugin from prisma for monorepos.
13 replies
TTCTheo's Typesafe Cult
Created by Sebastian on 1/4/2024 in #questions
Prisma turborepo deployment not initialized error
yeah, that's how I defined the database package in my monorepo
13 replies
TTCTheo's Typesafe Cult
Created by Sebastian on 1/4/2024 in #questions
Prisma turborepo deployment not initialized error
They displayed this as an example for how to setup turborepo with prisma https://turbo.build/repo/docs/handbook/tools/prisma
13 replies
TTCTheo's Typesafe Cult
Created by Sebastian on 1/4/2024 in #questions
Prisma turborepo deployment not initialized error
So @prisma/client is only installed in @kleerk/database, and it has an index.ts which does
export * from "@prisma/client"
export * from "@prisma/client"
The basic example on turborepo prisma docs. Then the initialization is done in the other packages which want to use PrismaClient. At build time, it depends on a "db:generate" which generates the client and types for prisma
13 replies
TTCTheo's Typesafe Cult
Created by Sebastian on 1/4/2024 in #questions
Prisma turborepo deployment not initialized error
This is the error displayed in vercel logs. This is the initialization in the apps/web The error comes after trying to import prisma in a /pages folder in order to use it in getServerSideProps for doing a check. However, the blocker is the displayed error.
import { PrismaClient } from "@kleerk/database";

declare global {
var prisma: PrismaClient | undefined;
}

export const prisma = global.prisma || new PrismaClient();

if (process.env.NODE_ENV !== "production") global.prisma = prisma;
import { PrismaClient } from "@kleerk/database";

declare global {
var prisma: PrismaClient | undefined;
}

export const prisma = global.prisma || new PrismaClient();

if (process.env.NODE_ENV !== "production") global.prisma = prisma;
13 replies
TTCTheo's Typesafe Cult
Created by Sebastian on 1/4/2024 in #questions
Prisma turborepo deployment not initialized error
PrismaClientInitializationError: Your schema.prisma could not be found, and we detected that you are using Next.js.
Find out why and learn how to fix this: https://pris.ly/d/schema-not-found-nextjs
at new pr (/var/task/apps/web/.next/server/chunks/2300.js:112:10787)
at Na (/var/task/apps/web/.next/server/chunks/2300.js:115:1589)
at new t (/var/task/apps/web/.next/server/chunks/2300.js:128:4651)
at 19097 (/var/task/apps/web/.next/server/chunks/9097.js:1:206)
at __webpack_require__ (/var/task/apps/web/.next/server/webpack-api-runtime.js:1:146)
at 38703 (/var/task/apps/web/.next/server/pages/api/auth/[...nextauth].js:1:1496)
at __webpack_require__ (/var/task/apps/web/.next/server/webpack-api-runtime.js:1:146)
at __webpack_exec__ (/var/task/apps/web/.next/server/pages/api/auth/[...nextauth].js:1:1813)
at /var/task/apps/web/.next/server/pages/api/auth/[...nextauth].js:1:1846
at __webpack_require__.X (/var/task/apps/web/.next/server/webpack-api-runtime.js:1:1610) {
clientVersion: '5.3.1',
errorCode: undefined
}
PrismaClientInitializationError: Your schema.prisma could not be found, and we detected that you are using Next.js.
Find out why and learn how to fix this: https://pris.ly/d/schema-not-found-nextjs
at new pr (/var/task/apps/web/.next/server/chunks/2300.js:112:10787)
at Na (/var/task/apps/web/.next/server/chunks/2300.js:115:1589)
at new t (/var/task/apps/web/.next/server/chunks/2300.js:128:4651)
at 19097 (/var/task/apps/web/.next/server/chunks/9097.js:1:206)
at __webpack_require__ (/var/task/apps/web/.next/server/webpack-api-runtime.js:1:146)
at 38703 (/var/task/apps/web/.next/server/pages/api/auth/[...nextauth].js:1:1496)
at __webpack_require__ (/var/task/apps/web/.next/server/webpack-api-runtime.js:1:146)
at __webpack_exec__ (/var/task/apps/web/.next/server/pages/api/auth/[...nextauth].js:1:1813)
at /var/task/apps/web/.next/server/pages/api/auth/[...nextauth].js:1:1846
at __webpack_require__.X (/var/task/apps/web/.next/server/webpack-api-runtime.js:1:1610) {
clientVersion: '5.3.1',
errorCode: undefined
}
13 replies
TTCTheo's Typesafe Cult
Created by Sebastian on 1/4/2024 in #questions
Prisma turborepo deployment not initialized error
I have a package in /packages named database, which exports * from '@prisma/client' I have setup the package.json right, I can work with the database package locally and while developing, I checked that the client is generated after removing node_modules, bun.lockb and simulate the build process.
13 replies
DTDrizzle Team
Created by Sebastian on 7/9/2023 in #help
Cannot drop index 'idx': needed in a foreign key constraint
This was the SQL code that was throwing the error: DROP INDEX user_id_idx ON user_profile;--> statement-breakpoint ALTER TABLE user_profile ADD PRIMARY KEY (user_id);--> statement-breakpoint ALTER TABLE user_profile DROP COLUMN id;--> statement-breakpoint Changing the order of the statements makes the script run successfully ALTER TABLE user_profile DROP COLUMN id;--> statement-breakpoint ALTER TABLE user_profile ADD PRIMARY KEY (user_id);--> statement-breakpoint DROP INDEX user_id_idx ON user_profile;--> statement-breakpoint
2 replies
TTCTheo's Typesafe Cult
Created by Debaucus on 6/16/2023 in #questions
With Planetscale (or others), what's the correct way to retroactively edit a prod database?
when adding new columns, if you want the column to be not null, you can use the default directive and on a later migration you can remove it if it annoys you with anything, though I wouldn't see the point.
5 replies
TTCTheo's Typesafe Cult
Created by .traevelliath on 6/22/2023 in #questions
Prisma 2-3 levels deep queries
Make sure your schema is correctly defined. You can either use self relations or a separate table to manage the friends. If the schema is correctly defined, you should be able to perform the nested includes to get friends of friends
17 replies
TTCTheo's Typesafe Cult
Created by VIIKKK on 6/1/2023 in #questions
Question about next auth.
sure, feel free to pm me
15 replies
TTCTheo's Typesafe Cult
Created by VIIKKK on 6/1/2023 in #questions
Question about next auth.
what seems to not work
15 replies
TTCTheo's Typesafe Cult
Created by VIIKKK on 6/1/2023 in #questions
Question about next auth.
you can also reffer to the official documentation for more details: https://trpc.io/docs/server/server-side-calls
15 replies
TTCTheo's Typesafe Cult
Created by VIIKKK on 6/1/2023 in #questions
Question about next auth.
CredentialsProvider({
name: 'Credentials',
credentials: {
username: { label: "email", type: "text", placeholder: "jsmith" },
password: { label: "password", type: "text", }
},
async authorize(credentials, req) {
const res = await fetch("test/login", {
method: 'POST',
body: JSON.stringify(credentials),
headers: { "Content-Type": "application/json" }
});

const response = await res.json();

if (res.ok && response.token) {
// If the API call was successful and the token exists
const user = {
id: response.token, // Provide a unique identifier for the user // Extract relevant user data from the API response
email: credentials.username, // Use the provided email as the user's email
password: credentials.password // Add any other relevant user data from the API response
};
// initialize the new tRPC router only if the other steps where successfull
const trpcRouter = appRouter.createCaller({});
const check = await trpcRouter.CompanyEmployeeRouter.Authorize(user);

console.log(check);

}
CredentialsProvider({
name: 'Credentials',
credentials: {
username: { label: "email", type: "text", placeholder: "jsmith" },
password: { label: "password", type: "text", }
},
async authorize(credentials, req) {
const res = await fetch("test/login", {
method: 'POST',
body: JSON.stringify(credentials),
headers: { "Content-Type": "application/json" }
});

const response = await res.json();

if (res.ok && response.token) {
// If the API call was successful and the token exists
const user = {
id: response.token, // Provide a unique identifier for the user // Extract relevant user data from the API response
email: credentials.username, // Use the provided email as the user's email
password: credentials.password // Add any other relevant user data from the API response
};
// initialize the new tRPC router only if the other steps where successfull
const trpcRouter = appRouter.createCaller({});
const check = await trpcRouter.CompanyEmployeeRouter.Authorize(user);

console.log(check);

}
15 replies