Traky Richard
03/07/2022, 9:47 AM20220304181545_add_client_validation_entity
failed to apply cleanly to the shadow database.
40Error:
41Database error
42Error querying the database: db error: ERROR: column “isValidate” of relation “Group” already exists
43 0: sql_migration_connector:flavourpostgres:sql_schema_from_migration_historyTraky Richard
03/07/2022, 9:47 AMJustin Ellingwood
03/07/2022, 1:51 PMBernat Jufré
03/07/2022, 2:23 PMconst model = db[entityType]
and return [model.count(), model.findMany()]
but the TS compiler is complaining because of the different Delegates
typesVitor Guidorizzzi
03/07/2022, 2:30 PMBernat Jufré
03/07/2022, 3:16 PMtype EntityKeys = "user" | "project" | "projectType";
type PrismaDelegates = Pick<typeof db, EntityKeys>;
type Entity = {
[Key in EntityKeys]: PrismaDelegates[Key];
}[EntityKeys];
const SLUG_TO_ENTITY = {
users: "user",
projects: "project",
"project-types": "projectType"
};
// `db` is a reference to an instance of the PrismaClient
const model: Entity = db[SLUG_TO_ENTITY[entity as keyof typeof SLUG_TO_ENTITY] as EntityKeys];
Then intellisense shows correctly that model
has count
and findMany
but because their signatures are not compatible with each other I get a typing error. Any ideas?Julien Goux
03/07/2022, 3:19 PMAlexSPx
03/07/2022, 5:04 PMAlexSPx
03/07/2022, 5:05 PMAlexSPx
03/07/2022, 5:05 PMMoe Green
03/07/2022, 5:58 PMmodel Article {
id Int @id @default(autoincrement())
slug String @db.VarChar(255)
title String @db.VarChar(255)
description String? @db.VarChar(255)
body String? @db.VarChar(255)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
tagList String[]
favoritesCount Int @default(0)
@@map("articles")
}
... and then make migration with result:
CREATE TABLE "articles" (
"id" SERIAL NOT NULL,
"slug" VARCHAR(255) NOT NULL,
"title" VARCHAR(255) NOT NULL,
"description" VARCHAR(255),
"body" VARCHAR(255),
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
"tagList" TEXT[],
"favoritesCount" INTEGER NOT NULL DEFAULT 0,
CONSTRAINT "articles_pkey" PRIMARY KEY ("id")
);
... but I have a question about this field - "updatedAt" TIMESTAMP(3) NOT NULL,
because I expected that this field should be like this - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP
why did it happen? I do not understand something?Meyer BTS
03/07/2022, 11:11 PMChris Tsongas
03/08/2022, 12:21 AMcreatedAt DateTime @default(now())
updatedAt DateTime @updatedAt
Prisma seems to set an updatedAt
value a fraction of a second after the createdAt
value when a record is created, even if the record wasn't updated. I don't remember that being the case when using a previous query builder (Knex.js). Anyone else notice this?Silen Naihin
03/08/2022, 4:52 AMManthan Mallikarjun
03/08/2022, 5:31 AMposts
) with a column called type
and if type
is set to "public"
you join the PublicPosts
table and if it's set to "private"
, it joins another table. I think django has this kind of support. Does Prisma support something like this?Manthan Mallikarjun
03/08/2022, 7:43 AMAdam Tretera
03/08/2022, 9:23 AMreq.body
is empty ? after POST call
Is there a best practice for express api project structure ? cannot find any diffrent then all routes in index.tsAndrew Valleteau
03/08/2022, 9:45 AM// IN POSTGRESQL
type permission_type (entity_id uuid, access text);
update_permissions(target_id uuid, new_permissions permission_type[])
// In Typescript
const entityId = 'abc-def-hij'
const newPerms = [{id: 'abc-def-hig', access: 'write'}];
await prisma.$executeRaw(`SELECT update_permission(${entityId}, array[${Prisma.join(newPerms.map((p) => `(${p.id}, ${p.access})`)}]::permission_type[]))`);
Would that be correct ?aaron.cai
03/08/2022, 2:25 PMJuan Orellana
03/08/2022, 5:59 PMAlex Vilchis
03/08/2022, 8:45 PMmigrate dev
? I have aprox 120 migrations and creating a new one takes soooo long. Is there any recommended flow to clean the migration history and start fresh without causing problems in production? 🤔jackgray
03/08/2022, 10:13 PMSajal Gupta
03/09/2022, 4:20 AMmotiondev
03/09/2022, 10:03 AMmodel Denomination {
id BigInt @unique @default(autoincrement()) @db.BigInt
symbol String @unique
active Boolean
createdAt DateTime @default(now()) @map("created_at") @db.Timestamp(5)
updatedAt DateTime @default(now()) @map("updated_at") @db.Timestamp(5)
@@map("denomination")
}
Running prisma migrate, generates the following sql scrcipt
-- CreateTable
CREATE TABLE "denomination" (
"id" BIGSERIAL NOT NULL, -- Here I want BIGINT insted of BIGSERIAL
"symbol" TEXT NOT NULL,
"active" BOOLEAN NOT NULL,
"created_at" TIMESTAMP(5) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(5) NOT NULL DEFAULT CURRENT_TIMESTAMP
);
Thanks in advance!Nditah Samweld
03/09/2022, 11:29 AMBailey McKay
03/09/2022, 6:41 PMOctal pixel
03/09/2022, 9:05 PMJuan Carlos Blanco Delgado
03/10/2022, 12:50 AMError validating composite type "System": SystemVersion refers to a model, making this a relation field. Relation fields inside composite types are not supported.
Gelo
03/10/2022, 5:07 AMsagar lama
03/10/2022, 8:48 AMimport { INestApplication, Injectable, OnModuleInit } from '@nestjs/common';
import { PrismaClient } from '@~internal/partner-database/client';
@Injectable()
export class PrismaService extends PrismaClient implements OnModuleInit {
async onModuleInit() {
await this.$connect();
}
async enableShutdownHooks(app: INestApplication) {
this.$on('beforeExit', async () => {
await app.close();
});
}
}