Tarik Brat
07/13/2021, 11:38 AMArun Kumar
07/13/2021, 11:52 AMprisma migrate div
Context: Timed out trying to acquire a postgres advisory lock (SELECT pg_advisory_lock(72707369)). Elapsed: 10000ms. See
<https://pris.ly/d/migrate-advisory-locking> for details.
Henri Kuper
07/13/2021, 2:03 PMyarn prisma generate
I get the following error:
Prisma schema loaded from prisma/schema.prisma
npm ERR! code E401
npm ERR! Unable to authenticate, need: Basic realm="GitHub Package Registry"
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/henri/.npm/_logs/2021-07-13T13_55_51_322Z-debug.log
Error: Command failed with exit code 1: npm install -D prisma@2.27.0
I does not seem like a pure prisma issue, but maybe anyone has an idea what this could be caused by?
If needed I can add the debug.log messagesAmit
07/13/2021, 2:07 PMnApi
:
Error: invalid type: boolean `true`, expected a string
at LibraryEngine.loadEngine (node_modules/@prisma/client/runtime/index.js:23613:27)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at LibraryEngine.instantiateLibrary (node_modules/@prisma/client/runtime/index.js:23557:7)
Anyone got any idea why? When not using nApi
it works fine.Ian
07/13/2021, 3:41 PMenum PostType {
default
photo
video
}
// --------------------------------------------------------------
// THIS IS STRUCTURED VIA MULTI TABLE INHERITANCE
// POST as SUPERTYPE which means table of common fields
// PHOTO and VIDEO as SUBTYPE which means table for specific fields
//
// PROS -> Easy to add subtype
//. -> No need for polymorphic association (Just put the relation on the base class)
//. -> Can atleast achieve "IMPOSSIBLE STATE SHOULD BE IMPOSSIBLE" (Depends)
// -> Clear structure (No bloated table for unrelated fields)
// CONS -> JOINS???
//. -> WHAT ELSE???
// --------------------------------------------------------------
// SUPERTYPE
model Post {
user User @relation(fields:[userId], reference: [id])
userId String
id String @id @default(cuid())
text String
type PostType
}
// SUBTYPE
model Photo {
post Post @relation(fields:[id], reference: [id])
id String @id @default(cuid())
url String
width Int
height Int
}
// SUBTYPE
model Video {
post Post @relation(fields:[id], reference: [id])
id String @id @default(cuid())
url String
aspectRatio Float
}
// ---------------------------------------
// SINGLE TABLE INHERITANCE
// PROS -> Single Table (No joins needed)
//. -> WHAT ELSE???
// CONS -> Nullable fields for uncommon column
// -> Adding subtype requires altering the whole table
//. -> Bloated
// ---------------------------------------
model Post {
user User @relation(fields:[userId], reference: [id])
userId String
id String @id @default(cuid())
text String
type PostType
url String
width Int? // Nullable here
height Int? // Nullable here
aspectRatio Float? // Nullable here
}
WHAT WOULD BE YOUR GO TO CHOICE??
A. Multi-Table Inheritance (MTI)
B. Single-Table Inheritance (STI)
Ian
07/13/2021, 3:48 PMMarc
07/13/2021, 4:08 PMError:
Invalid `prisma.model.deleteMany()` invocation:
Error occurred during query execution:
ConnectorError(ConnectorError { user_facing_error: None, kind: RawError { code: "unknown", message: "Command failed (IllegalOperation): This MongoDB deployment does not support retryable writes. Please add retryWrites=false to your connection string.)" } })
my prisma file
datasource db {
provider = "mongodb"
url = "<mongodb://localhost/prisma?retryWrites=false>"
}
generator client {
provider = "prisma-client-js"
previewFeatures = ["mongoDb"]
}
model Model {
id String @id @default(dbgenerated()) @map("_id") @db.ObjectId
username String
ready Boolean
tags String[]
priority Int
}
Gelo
07/13/2021, 5:22 PMGelo
07/13/2021, 5:27 PMGelo
07/13/2021, 5:28 PMAman Tiwari
07/13/2021, 5:37 PMWilliam Chantry
07/13/2021, 10:39 PMpb_puck_id
and `pb_recorded_timestamp``
It seemingly created the index we expected (pb_puck_id_pb_recorded_timestamp_idx)
hoever, on each new migration, prisma attempts to drop the index. I’m pretty stumped, any ideas?
Bonus: We made the table a timescaledb hypertable, which might be the issueIan
07/14/2021, 6:35 AMNima
07/14/2021, 8:19 AMTomáš Kallup
07/14/2021, 8:28 AMid
field (the DB schema is out of my controll, so I can't change the way it works) and I don't know how to represent it in the schema.
Essentialy what I need, is to tell prisma it should use something like JOIN lbans_history lh ON lh.id = (SELECT MAX(lh.id) WHERE lh.uuid = lb.uuid ORDER BY date DESC)
when requesting a relation using include: { history: true }
, but I'm not sure if this is even possible.stephan levi
07/14/2021, 8:38 AMMoritz
07/14/2021, 11:16 AMmanuel
07/14/2021, 11:55 AMmanuel
07/14/2021, 11:55 AMmanuel
07/14/2021, 11:55 AMRoman Schejbal
07/14/2021, 11:58 AMmanuel
07/14/2021, 12:00 PMRoman Schejbal
07/14/2021, 12:01 PMuser
07/14/2021, 1:20 PMMehmet
07/14/2021, 1:36 PMVladi Stevanovic
Luis Kuper
07/14/2021, 1:42 PMmodel Entry {
id String @id
category String
}
Having the Entry model filled with data:
id: '0', category: 'A'
id: '1', category: 'A'
id: '2', category: 'B'
id: '3', category: 'C'
id: '4', category: 'B'
executing the query for I would like to recieve all queries, where the value of category hasn't been fetched before into the resulting data:
id: '0', category: 'A'
id: '2', category: 'B'
id: '3', category: 'C'
Any ideas?Mischa
07/14/2021, 2:21 PMuser
07/14/2021, 3:46 PMKent C. Dodds
07/14/2021, 3:58 PM<audio />
src. I'm not sure whether there's another way to do that without creating an actual file.
The files are about 3 minutes long or so and I'll probably not store more than 100-200 at any given time, and they won't be written/read very often.
Anyway, I need to persist this to my Postgres db. I understand that base64 is a pretty poor way to store this data because it can be rather large. People have suggested I use a binary type and store it like that.
My question is, how do I serialize a base64
string as binary to store it in the db, and then deserialize it when it needs to be read.
Second related question, does anyone know whether there's another way I can do this to avoid base64 while still allowing me to use what's been recorded directly in an <audio />
Note a hard requirement is to not actually create files. That's just not going to happen here.
Hopefully that makes sense. Thanks for the help!