Blyp Docs

Prisma

Use this path when your project stores Blyp logs through Prisma and your datasource provider is either Postgres or MySQL.

Prerequisites

The current supported Prisma providers are:

Naming contract

The adapter factory defaults to model: "blypLog", so your Prisma client must expose that delegate.

Generated BlypLog model for Postgres

model BlypLog {
  id        String   @id @db.Uuid
  timestamp DateTime @db.Timestamptz(6)
  level     String   @db.VarChar(32)
  message   String   @db.Text
  caller    String?  @db.Text
  type      String?  @db.VarChar(64)
  groupId   String?  @map("group_id") @db.VarChar(191)
  method    String?  @db.VarChar(16)
  path      String?  @db.Text
  status    Int?
  duration  Float?   @db.DoublePrecision
  hasError  Boolean  @map("has_error")
  data      Json?    @db.JsonB
  bindings  Json?    @db.JsonB
  error     Json?    @db.JsonB
  events    Json?    @db.JsonB
  record    Json     @db.JsonB
  createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6)

  @@index([timestamp], map: "blyp_logs_timestamp_idx")
  @@index([level, timestamp], map: "blyp_logs_level_timestamp_idx")
  @@index([type, timestamp], map: "blyp_logs_type_timestamp_idx")
  @@index([groupId, timestamp], map: "blyp_logs_group_id_timestamp_idx")
  @@map("blyp_logs")
}

Generated BlypLog model for MySQL

model BlypLog {
  id        String   @id @db.Char(36)
  timestamp DateTime @db.DateTime(6)
  level     String   @db.VarChar(32)
  message   String   @db.Text
  caller    String?  @db.Text
  type      String?  @db.VarChar(64)
  groupId   String?  @map("group_id") @db.VarChar(191)
  method    String?  @db.VarChar(16)
  path      String?  @db.Text
  status    Int?
  duration  Float?   @db.Double
  hasError  Boolean  @map("has_error")
  data      Json?
  bindings  Json?
  error     Json?
  events    Json?
  record    Json
  createdAt DateTime @default(now()) @map("created_at") @db.DateTime(6)

  @@index([timestamp], map: "blyp_logs_timestamp_idx")
  @@index([level, timestamp], map: "blyp_logs_level_timestamp_idx")
  @@index([type, timestamp], map: "blyp_logs_type_timestamp_idx")
  @@index([groupId, timestamp], map: "blyp_logs_group_id_timestamp_idx")
  @@map("blyp_logs")
}

For the field-by-field purpose of each column, see Schema Contract.

blyp.config.ts example

import { PrismaClient } from "@prisma/client";
import { createPrismaDatabaseAdapter } from "@blyp/core/database";

const prisma = new PrismaClient();

export default {
  destination: "database",
  database: {
    dialect: "postgres",
    adapter: createPrismaDatabaseAdapter({
      client: prisma,
      model: "blypLog",
    }),
  },
};

Migration flow

blyp db:init
blyp db:migrate
blyp db:generate

db:generate is required for Prisma projects because Prisma client generation is separate from migration application.

What blyp db:init validates

Before it writes or appends the Blyp model, the CLI checks:

If a BlypLog model already exists, the CLI validates that it still matches the Blyp schema contract before continuing.

Failure cases

Likely Prisma-specific failures include: