Kairu
Kairu
DTDrizzle Team
Created by Kairu on 10/25/2024 in #help
Nextjs pages router: You may need an appropriate loader to handle this file type
for anyone else running into this: needed to add transpilePackages: ["@repo/schema"] to my next config.
3 replies
DTDrizzle Team
Created by Vinny on 3/10/2024 in #help
Error Too many connections with Drizzle + MySQL2
haven’t encountered any errors so im probably fine for now
13 replies
DTDrizzle Team
Created by Vinny on 3/10/2024 in #help
Error Too many connections with Drizzle + MySQL2
0/disabled I believe
13 replies
DTDrizzle Team
Created by Vinny on 3/10/2024 in #help
Error Too many connections with Drizzle + MySQL2
i should probably check what mine is set to, presumably the default
13 replies
DTDrizzle Team
Created by Shezan on 3/8/2024 in #help
Best/recommended column type for Id - Drizzle Neon
neon supports extensions https://neon.tech/docs/extensions/pg-extensions you could use pgx_ulid for ULIDs? they're like 01ARZ3NDEKTSV4RRFFQ69G5FAV i'm using citext for something and adding the create extension statement to a migration and creating a custom column is very easy
2 replies
DTDrizzle Team
Created by Vinny on 3/10/2024 in #help
Error Too many connections with Drizzle + MySQL2
afaik it wont work on serverless which is why serverless drivers and the drizzle http proxy exists, but i dont get enough traffic per second to exhaust connections
13 replies
DTDrizzle Team
Created by Vinny on 3/10/2024 in #help
Error Too many connections with Drizzle + MySQL2
this is my way for avoiding connection exhaustion in HMR
type PostgresDB = ReturnType<typeof postgres> | undefined;
let postgresDb: PostgresDB = undefined;

if (!postgresDb) {
postgresDb = postgres(databaseUrl);
}

export const db = drizzle(postgresDb, { schema });
type PostgresDB = ReturnType<typeof postgres> | undefined;
let postgresDb: PostgresDB = undefined;

if (!postgresDb) {
postgresDb = postgres(databaseUrl);
}

export const db = drizzle(postgresDb, { schema });
13 replies
DTDrizzle Team
Created by Kairu on 3/7/2024 in #help
Executing database migrations on Vercel
alright this seems to work really nicely with vercel preview branching using neon and drizzle seems to try overwriting the meta info upon migration?
{
severity_local: 'NOTICE',
severity: 'NOTICE',
code: '42P06',
message: 'schema "drizzle" already exists, skipping',
file: 'schemacmds.c',
line: '132',
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: '132',
routine: 'CreateSchemaCommand'
}
{
severity_local: 'NOTICE',
severity: 'NOTICE',
code: '42P07',
message: 'relation "__drizzle_migrations" already exists, skipping',
file: 'parse_utilcmd.c',
line: '207',
routine: 'transformCreateStmt'
}
2 replies
DTDrizzle Team
Created by Kairu on 1/16/2024 in #help
Drizzle and multi-tenancy
thanks for the reply, sorry for the wall of text lol
8 replies
DTDrizzle Team
Created by Kairu on 1/16/2024 in #help
Drizzle and multi-tenancy
I feel like I will be easier/faster to have a separate drizzle instance per database
agreed. i did just remember i've done a sort of cached connection in my pg side project that could work here, just instead of returning a single instance it has a map of connections and returns the applicable one passed into it, or something like that
type PostgresDB = ReturnType<typeof postgres> | undefined;
let postgresDb: PostgresDB = undefined;
const databaseUrl = `...`;

// prevents HMR from exhausing connections
if (process.env.NODE_ENV !== "production") {
if (!postgresDb) {
postgresDb = postgres(databaseUrl);
}
} else {
postgresDb = postgres(databaseUrl);
}
export const db = drizzle(postgresDb, { schema });
type PostgresDB = ReturnType<typeof postgres> | undefined;
let postgresDb: PostgresDB = undefined;
const databaseUrl = `...`;

// prevents HMR from exhausing connections
if (process.env.NODE_ENV !== "production") {
if (!postgresDb) {
postgresDb = postgres(databaseUrl);
}
} else {
postgresDb = postgres(databaseUrl);
}
export const db = drizzle(postgresDb, { schema });
8 replies
DTDrizzle Team
Created by Kairu on 1/16/2024 in #help
Drizzle and multi-tenancy
After that, changing databases within backend server environment will come to be a question of, does your driver support it?
in theory, starting with sqlite and switching to mysql or pg is only gaining features. imo the driver type isn't the complicated part here, it's the whole hosting of the database server and creating new databases programmatically in different regions that makes it complicated. using turso allows one auth key to connect to X number of database URLs, compared to spinning up mysql/pg servers myself and building a service to coordinate all of these, potentially requiring another API layer to interact with those databases, is just far more complex
8 replies
DTDrizzle Team
Created by Kairu on 1/16/2024 in #help
Drizzle and multi-tenancy
Will it run in a dedicated server
they seem set on using serverless, so the app would be deployed on vercel
do you need to optimize for cold starts
performance is not a big concern here, so i don't believe so
how often a new tenant will be onboarded
current estimation is a few dozen for 2024, scaling to low hundreds per year
what type of resources will you be working with
dynamic form templates, filled in forms, calculations based on those forms
what type of requests will be the most commons
on the system side: just loading what organizations and sub-organizations a user is linked to on the tenant side: the resources mentioned above, nothing super complicated that sql can't breeze through i got confirmation that tenants need to be able to pick their region for legal reasons, so the options for db here is basically - use Turso, the list of locations they offer have been acceptable - spin up new database servers manually and build a service to coordinate tenant onboarding between all these different servers cloudflare d1 looks like a solid turso alternative but not being able to explicitly choose a region makes it difficult to justify when the region selection is a legal requirement
8 replies
DTDrizzle Team
Created by Mr.Propre on 11/30/2023 in #help
relation select query with where condition
the where key is only available on many relations
20 replies
DTDrizzle Team
Created by Mr.Propre on 11/30/2023 in #help
relation select query with where condition
in your case it should work fine as its filtering the relation. for me, i'm trying to filter the parent based on the relation content, which doesn't seem possible
20 replies
DTDrizzle Team
Created by Mr.Propre on 11/30/2023 in #help
relation select query with where condition
for my current use case i've gotten around it with a join as i don't need to aggregate like here https://orm.drizzle.team/docs/joins#aggregating-results but in the future i'd really like to avoid this aggregating, and just use the query builder
20 replies
DTDrizzle Team
Created by Mr.Propre on 11/30/2023 in #help
relation select query with where condition
there's another thread about it here https://discord.com/channels/1043890932593987624/1176166096777248829/1176166096777248829 the documentation suggests this is possible here https://orm.drizzle.team/docs/rqb#where--filters but for some reason the types don't let you run a where on a relation using the query builder.
20 replies
DTDrizzle Team
Created by parmetra on 11/20/2023 in #help
Using 'where' inside 'with'
sure i could just filter the results after the fact but it seems wasteful when the db should be able to do this itself
10 replies
DTDrizzle Team
Created by parmetra on 11/20/2023 in #help
Using 'where' inside 'with'
for me i need a where on both tables so inverting the query won't work
const data = await db.query.transfers.findMany({
where: or(eq(transfers.to, addr), eq(transfers.from, addr)),
with: {
entity: {
where: eq(entities.type, "special"),
},
},
});
const data = await db.query.transfers.findMany({
where: or(eq(transfers.to, addr), eq(transfers.from, addr)),
with: {
entity: {
where: eq(entities.type, "special"),
},
},
});
10 replies