ididit
ididit
Explore posts from servers
PPrisma
Created by ididit on 3/27/2025 in #help-and-questions
Is it possible to run migrations manually on the database server via raw SQL and not use Prisma?
Hi because I'm a bit stuck with migrations stalling and hanging due to Unsupported index of BM25, I am considering just running migrations on the database server manually via raw sql generated from prisma's migration files. i know its not the best thing to do but i gotta do what works. what are some of the implications of doing this?
3 replies
PPrisma
Created by ididit on 3/24/2025 in #help-and-questions
Migration just stalls and hangs.
sometimes, when i perform prisma migrate to either create a new migration or run migration, it just hangs. what are some of the reasons for that happening? we haven't gone production yet but this is super scary. it happens to me from a fresh database after like 2 or 3 days later. we do have a custom BM25 index. its scary because the only way to get migration to work again is if i do a complete drop database and start over.
8 replies
PPrisma
Created by ididit on 2/4/2025 in #help-and-questions
creating a BM25 index
I have created a BM25 index by creating a migration file to create it and also added the schema to ignore the index.
model Post {
id Int @id @default(autoincrement())
name String?
/// @ignored
/// @schema-ignored-index(post_bm25_idx)
@@index(fields: [id, name], map: "post_bm25_idx")
}
model Post {
id Int @id @default(autoincrement())
name String?
/// @ignored
/// @schema-ignored-index(post_bm25_idx)
@@index(fields: [id, name], map: "post_bm25_idx")
}
and here is the custom migration file i created to run:
-- CreateIndex
-- prisma-ignore-index
CREATE INDEX post_bm25_idx ON "Post"
USING bm25 (id, name)
WITH (
key_field='id',
text_fields='{
"name": {"fast": true}
}'
);
-- CreateIndex
-- prisma-ignore-index
CREATE INDEX post_bm25_idx ON "Post"
USING bm25 (id, name)
WITH (
key_field='id',
text_fields='{
"name": {"fast": true}
}'
);
but the next time i run a migration or try to create a new one, it hangs with a message like:
prisma:schemaEngine:stderr {"timestamp":"2025-02-04T01:31:58.231558Z","level":"WARN","fields":{"message":"Unknown index algorithm on post_bm25_idx: bm25"},"target":"sql_schema_describer::postgres","span":{"namespaces":"None","name":"describe_schema"},"spans":[{"name":"DevDiagnostic"},{"namespaces":"None","name":"describe_schema"}]} +0ms
prisma:schemaEngine:stderr {"timestamp":"2025-02-04T01:31:58.231558Z","level":"WARN","fields":{"message":"Unknown index algorithm on post_bm25_idx: bm25"},"target":"sql_schema_describer::postgres","span":{"namespaces":"None","name":"describe_schema"},"spans":[{"name":"DevDiagnostic"},{"namespaces":"None","name":"describe_schema"}]} +0ms
this is blocking me from running or creating new migration file and the database is in a limbo. please help!
8 replies
TtRPC
Created by ididit on 9/1/2024 in #❓-help
how can i create a router off of a JSON?
is it possible to create a route dynamically off of a JSON? lets say i have:
appRouter = this.trpc.router({
findUser: this.trpc.procedure
.input(z.object({ name: z.string().optional() }))
.query(({ input }) => {
return this.userService.findUser({ name: input.name });
}),
findUsers: this.trpc.procedure
.query(({ input }) => {
return this.userService.findUsers();
}),
});
appRouter = this.trpc.router({
findUser: this.trpc.procedure
.input(z.object({ name: z.string().optional() }))
.query(({ input }) => {
return this.userService.findUser({ name: input.name });
}),
findUsers: this.trpc.procedure
.query(({ input }) => {
return this.userService.findUsers();
}),
});
but i want this created dynamically from a JSON that looks something like this:
const routes = [
{
name: 'fetchUsers',
input: { name: z.string() },
type: 'query',
},
{
name: 'createUser',
input: { name: z.string() },
type: 'mutation',
},
];
... convert routes to procedures ...
this.appRouter = this.router(procedures);
const routes = [
{
name: 'fetchUsers',
input: { name: z.string() },
type: 'query',
},
{
name: 'createUser',
input: { name: z.string() },
type: 'mutation',
},
];
... convert routes to procedures ...
this.appRouter = this.router(procedures);
afterwards i applied the routes to the middleware and it works on backend:
public async applyMiddleware(app: any) {
app.use(
'/trpc',
trpcExpress.createExpressMiddleware({
router: this.appRouter,
}),
);
}
public async applyMiddleware(app: any) {
app.use(
'/trpc',
trpcExpress.createExpressMiddleware({
router: this.appRouter,
}),
);
}
but from the client-side, i lost all type inference to these routes. anyone ever get this to work?
2 replies