Andrey Los
Andrey Los
DTDrizzle Team
Created by Andrey Los on 8/24/2023 in #help
It is possible to stop notice logs from appearing?
Worked like a charm, but wondering why original wrapper doesn't somehow redirects that to the logger.
11 replies
DTDrizzle Team
Created by Andrey Los on 8/24/2023 in #help
It is possible to stop notice logs from appearing?
Hence:
const migrationConnection = postgres(config.DB_URL, { max: 1, onnotice: () => {} })
const migrationConnection = postgres(config.DB_URL, { max: 1, onnotice: () => {} })
11 replies
DTDrizzle Team
Created by Andrey Los on 8/24/2023 in #help
It is possible to stop notice logs from appearing?
But I think it figured how it can be disabled.
const sql = postgres('postgres://username:password@host:port/database', {
// ...
onnotice : fn, // Defaults to console.log
// ...
})
const sql = postgres('postgres://username:password@host:port/database', {
// ...
onnotice : fn, // Defaults to console.log
// ...
})
11 replies
DTDrizzle Team
Created by Andrey Los on 8/24/2023 in #help
It is possible to stop notice logs from appearing?
In the docs of Drizzle, there is definitely no way to disable them.
11 replies
DTDrizzle Team
Created by Andrey Los on 8/24/2023 in #help
It is possible to stop notice logs from appearing?
I wish I could disable these somehow.
11 replies
DTDrizzle Team
Created by Andrey Los on 8/24/2023 in #help
It is possible to stop notice logs from appearing?
If I do, let say
await db.execute(sql`TRUNCATE TABLE organizations CASCADE;`)
await db.execute(sql`TRUNCATE TABLE organizations CASCADE;`)
I also get this logged
{
severity_local: 'NOTICE',
severity: 'NOTICE',
code: '00000',
message: 'truncate cascades to table "usersToOrganizations"',
file: 'tablecmds.c',
line: '1726',
routine: 'ExecuteTruncateGuts'
}
{
severity_local: 'NOTICE',
severity: 'NOTICE',
code: '00000',
message: 'truncate cascades to table "invites"',
file: 'tablecmds.c',
line: '1726',
routine: 'ExecuteTruncateGuts'
}
{
severity_local: 'NOTICE',
severity: 'NOTICE',
code: '00000',
message: 'truncate cascades to table "roles"',
file: 'tablecmds.c',
line: '1726',
routine: 'ExecuteTruncateGuts'
}
{
severity_local: 'NOTICE',
severity: 'NOTICE',
code: '00000',
message: 'truncate cascades to table "usersToOrganizations"',
file: 'tablecmds.c',
line: '1726',
routine: 'ExecuteTruncateGuts'
}
{
severity_local: 'NOTICE',
severity: 'NOTICE',
code: '00000',
message: 'truncate cascades to table "invites"',
file: 'tablecmds.c',
line: '1726',
routine: 'ExecuteTruncateGuts'
}
{
severity_local: 'NOTICE',
severity: 'NOTICE',
code: '00000',
message: 'truncate cascades to table "roles"',
file: 'tablecmds.c',
line: '1726',
routine: 'ExecuteTruncateGuts'
}
11 replies
DTDrizzle Team
Created by Andrey Los on 8/24/2023 in #help
It is possible to stop notice logs from appearing?
For reference here is the script that triggers it.
import { drizzle } from "drizzle-orm/postgres-js"
import { migrate } from "drizzle-orm/postgres-js/migrator"
import * as console from "node:console"
import postgres from "postgres"
import * as z from "zod"

import { env } from "../src/read-env"

const config = z
.object({
NODE_ENV: z.enum(["development", "test", "production"]),
DB_URL: z.string(),
})
.parse(env)

const migrationConnection = postgres(config.DB_URL, { max: 1 })
const connection = drizzle(migrationConnection)

console.info("Attempting a DB migration")

void migrate(connection, {
migrationsFolder: "./node_modules/@namespace/database-schema/drizzle",
})
.then(() => {
console.info("Migration complete")
})
.catch((error) => {
console.error("Migration failed", error)
process.exit(1)
})
.finally(async () => {
await migrationConnection.end()
console.info("Connection closed")
process.exit(0)
})
import { drizzle } from "drizzle-orm/postgres-js"
import { migrate } from "drizzle-orm/postgres-js/migrator"
import * as console from "node:console"
import postgres from "postgres"
import * as z from "zod"

import { env } from "../src/read-env"

const config = z
.object({
NODE_ENV: z.enum(["development", "test", "production"]),
DB_URL: z.string(),
})
.parse(env)

const migrationConnection = postgres(config.DB_URL, { max: 1 })
const connection = drizzle(migrationConnection)

console.info("Attempting a DB migration")

void migrate(connection, {
migrationsFolder: "./node_modules/@namespace/database-schema/drizzle",
})
.then(() => {
console.info("Migration complete")
})
.catch((error) => {
console.error("Migration failed", error)
process.exit(1)
})
.finally(async () => {
await migrationConnection.end()
console.info("Connection closed")
process.exit(0)
})
11 replies
DTDrizzle Team
Created by Andrey Los on 8/24/2023 in #help
It is possible to stop notice logs from appearing?
These kinds:
{
severity_local: 'NOTICE',
severity: 'NOTICE',
code: '42P06',
message: 'schema "drizzle" already exists, skipping',
file: 'schemacmds.c',
line: '131',
routine: 'CreateSchemaCommand'
}
{
severity_local: 'NOTICE',
severity: 'NOTICE',
code: '42P07',
message: 'relation "__drizzle_migrations" already exists, skipping',
file: 'parse_utilcmd.c',
line: '207',
routine: 'transformCreateStmt'
}
{
severity_local: 'NOTICE',
severity: 'NOTICE',
code: '42P06',
message: 'schema "drizzle" already exists, skipping',
file: 'schemacmds.c',
line: '131',
routine: 'CreateSchemaCommand'
}
{
severity_local: 'NOTICE',
severity: 'NOTICE',
code: '42P07',
message: 'relation "__drizzle_migrations" already exists, skipping',
file: 'parse_utilcmd.c',
line: '207',
routine: 'transformCreateStmt'
}
11 replies
DTDrizzle Team
Created by Andrey Los on 8/8/2023 in #help
There is not enough information to infer relation. What am I doing wrong?
If you have 5k MAU then it's a good problem to have 🙂 Beacuse it's free for that amount. If you have 100k etc so it costs a lot, then, well, again, you can always self-host making it cheaper 🙂
11 replies
DTDrizzle Team
Created by Andrey Los on 8/8/2023 in #help
There is not enough information to infer relation. What am I doing wrong?
Nope 🙂 I'm using supertokens.com for auth BTW. So far pretty solid.
11 replies
DTDrizzle Team
Created by Andrey Los on 8/8/2023 in #help
There is not enough information to infer relation. What am I doing wrong?
It's a bit ugly 🙂 Would be awesome if it would be possible to have these many-to-many resolves more "magically" 🙂 I end up doing the changes that you mentioned and having a query like that.
await db.query.usersToOrganizations.findFirst({
where: eq(usersToOrganizations.userId, user.id),
})
await db.query.usersToOrganizations.findFirst({
where: eq(usersToOrganizations.userId, user.id),
})
11 replies
DTDrizzle Team
Created by Andrey Los on 8/8/2023 in #help
There is not enough information to infer relation. What am I doing wrong?
Also, unsure about is goodie 🙂 https://orm.drizzle.team/docs/goodies#compare-objects-types-instanceof-alternative Can you show better example?
11 replies