TGTGamer
TGTGamer
Explore posts from servers
DTDrizzle Team
Created by TGTGamer on 4/7/2025 in #help
pgTable - extra config (primaryKey) issues
abstraction.ts
import { encircleId } from '@encircle-marketing/crm.utilities.helpers.custom-db-type-encircle-id'
import { idSchema, typeid } from '@encircle-marketing/crm.utilities.helpers.custom-db-type-typeid'
import { BuildExtraConfigColumns, SQL, sql } from 'drizzle-orm'
import {
customType,
index,
PgColumnBuilderBase,
pgEnum,
pgTable as drizzlePgTable,
PgTableExtraConfigValue,
timestamp,
uniqueIndex
} from 'drizzle-orm/pg-core'
import { getPgColumnBuilders } from 'drizzle-orm/pg-core/columns/all'
export function pgTable<
TTableName extends string,
TColumnsKey extends string,
TColumnsMap extends Record<TColumnsKey, PgColumnBuilderBase>
> (
name: TTableName,
columns: ( columnTypes: AllBuilders ) => TColumnsMap,
extraConfig?: ( self: BuildExtraConfigColumns<TTableName, TColumnsMap, 'pg'> ) => PgTableExtraConfigValue[]
) {
const result = drizzlePgTable(
name,
( db ) => columns( {
...db,
encircleId,
typeid
} ),
( table ) => {
const extra = extraConfig
? extraConfig( table )
: []

return [
...extra
]
}
)
return result
}
import { encircleId } from '@encircle-marketing/crm.utilities.helpers.custom-db-type-encircle-id'
import { idSchema, typeid } from '@encircle-marketing/crm.utilities.helpers.custom-db-type-typeid'
import { BuildExtraConfigColumns, SQL, sql } from 'drizzle-orm'
import {
customType,
index,
PgColumnBuilderBase,
pgEnum,
pgTable as drizzlePgTable,
PgTableExtraConfigValue,
timestamp,
uniqueIndex
} from 'drizzle-orm/pg-core'
import { getPgColumnBuilders } from 'drizzle-orm/pg-core/columns/all'
export function pgTable<
TTableName extends string,
TColumnsKey extends string,
TColumnsMap extends Record<TColumnsKey, PgColumnBuilderBase>
> (
name: TTableName,
columns: ( columnTypes: AllBuilders ) => TColumnsMap,
extraConfig?: ( self: BuildExtraConfigColumns<TTableName, TColumnsMap, 'pg'> ) => PgTableExtraConfigValue[]
) {
const result = drizzlePgTable(
name,
( db ) => columns( {
...db,
encircleId,
typeid
} ),
( table ) => {
const extra = extraConfig
? extraConfig( table )
: []

return [
...extra
]
}
)
return result
}
table.ts
import { pgTable } from '@encircle-marketing/crm.entities.abstraction'
import { record, recordTableName } from '@encircle-marketing/crm.entities.db.drizzle.schema.record'
import { primaryKey } from 'drizzle-orm/pg-core'

export const recordsToRecords = pgTable(
recordsToRecordsTableName,
( db ) => ( {
sourceId: db.typeid( 'source_id', { type: recordTableName } )
.notNull()
.references( () => record.id ),
competitorId: db.typeid( 'matched_id', { type: recordTableName } )
.notNull()
.references( () => record.id )
} ),
( table ) => [
primaryKey( { columns: [ table.sourceId, table.competitorId ] } )
]
)
import { pgTable } from '@encircle-marketing/crm.entities.abstraction'
import { record, recordTableName } from '@encircle-marketing/crm.entities.db.drizzle.schema.record'
import { primaryKey } from 'drizzle-orm/pg-core'

export const recordsToRecords = pgTable(
recordsToRecordsTableName,
( db ) => ( {
sourceId: db.typeid( 'source_id', { type: recordTableName } )
.notNull()
.references( () => record.id ),
competitorId: db.typeid( 'matched_id', { type: recordTableName } )
.notNull()
.references( () => record.id )
} ),
( table ) => [
primaryKey( { columns: [ table.sourceId, table.competitorId ] } )
]
)
3 replies
DTDrizzle Team
Created by TGTGamer on 4/7/2025 in #help
pgTable - extra config (primaryKey) issues
TS2769: No overload matches this call.

Overload 1 of 2, '(config: { name?: string; columns: [AnyPgColumn<{ tableName: string; }>, ...AnyPgColumn<{ tableName: string; }>[]]; }): PrimaryKeyBuilder', gave the following error. Type 'ExtraConfigColumn<ColumnBaseConfig<ColumnDataType, string>>' is not assignable to type 'AnyPgColumn<{ tableName: string; }>' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the targets properties. The types of 'table._.config.columns' are incompatible between these types.

Type 'Record<string, import(".../drizzle-orm/pg-core/columns/common", { with: { "resoluti
on-mode": "import" } }).PgColumn<import("...' is not assignable to type 'Record<string, import(".../drizzle-orm/pg-core/columns/common").PgColumn<import("...'.
'string' index signatures are incompatible.
Type 'import(".../drizzle-orm/pg-core/columns/common", { with: { "resolution-mode": "
import" } }).PgColumn<import("...' is not assignable to type 'import(".../drizzle-orm/pg-core/columns/common").PgColumn<import("...' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
Property 'config' is protected but type 'Column<T, TRuntimeConfig, TTypeConfig>' is not a class derived from 'Column<T, TRuntimeConfig, TTypeConfig>'.


Overload 2 of 2, '(...columns: AnyPgColumn<{ tableName: string; }>[]): PrimaryKeyBuilder', gave the following error. Object literal may only specify known properties, and 'columns' does not exist in type 'PgColumn<Required<Update<ColumnBaseConfig<ColumnDataType, string>, { tableName: string; }>>, {}, {}>'.

29 primaryKey( { columns: [ table.sourceId, table.competitorId ] } )
TS2769: No overload matches this call.

Overload 1 of 2, '(config: { name?: string; columns: [AnyPgColumn<{ tableName: string; }>, ...AnyPgColumn<{ tableName: string; }>[]]; }): PrimaryKeyBuilder', gave the following error. Type 'ExtraConfigColumn<ColumnBaseConfig<ColumnDataType, string>>' is not assignable to type 'AnyPgColumn<{ tableName: string; }>' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the targets properties. The types of 'table._.config.columns' are incompatible between these types.

Type 'Record<string, import(".../drizzle-orm/pg-core/columns/common", { with: { "resoluti
on-mode": "import" } }).PgColumn<import("...' is not assignable to type 'Record<string, import(".../drizzle-orm/pg-core/columns/common").PgColumn<import("...'.
'string' index signatures are incompatible.
Type 'import(".../drizzle-orm/pg-core/columns/common", { with: { "resolution-mode": "
import" } }).PgColumn<import("...' is not assignable to type 'import(".../drizzle-orm/pg-core/columns/common").PgColumn<import("...' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
Property 'config' is protected but type 'Column<T, TRuntimeConfig, TTypeConfig>' is not a class derived from 'Column<T, TRuntimeConfig, TTypeConfig>'.


Overload 2 of 2, '(...columns: AnyPgColumn<{ tableName: string; }>[]): PrimaryKeyBuilder', gave the following error. Object literal may only specify known properties, and 'columns' does not exist in type 'PgColumn<Required<Update<ColumnBaseConfig<ColumnDataType, string>, { tableName: string; }>>, {}, {}>'.

29 primaryKey( { columns: [ table.sourceId, table.competitorId ] } )
3 replies
DTDrizzle Team
Created by TGTGamer on 2/25/2025 in #help
Running db.execute on the read replica?
3 replies
DTDrizzle Team
Created by TGTGamer on 2/25/2025 in #help
Running db.execute on the read replica?
The code (note using TS Effect but the drizzle side of things should be roughly the same)
3 replies
DTDrizzle Team
Created by A_Dev on 10/22/2024 in #help
Pgschema
Simply make sure the drizzle definitions have the table included. You can either use the cli to generate these from your database or define the schema using the schema options: https://orm.drizzle.team/docs/schemas
2 replies
DTDrizzle Team
Created by Kelvin on 9/7/2024 in #help
Creating migrations while using ES Modules fails with error `Cannot find module '<filename>.js`
Not sure if you fixed, but double check your moduleResolution as that was what got me with this issue. Solved by using NodeNext or Node instead of ESNext, ES2021 etc...
3 replies
SIASapphire - Imagine a Framework
Created by TGTGamer on 12/10/2023 in #sapphire-support
Bit.dev API Plugin not working
Ta thank you 🙂
26 replies
SIASapphire - Imagine a Framework
Created by TGTGamer on 12/10/2023 in #sapphire-support
Bit.dev API Plugin not working
No worries. Worth a shot. I think it must be bit.dev causing an issue somewhere as the server.server.listening is returning true and it's showing a result when I check the server.server.routes so the routes are registering. Is there any way to check what port sapphire is trying to use?
26 replies
SIASapphire - Imagine a Framework
Created by TGTGamer on 12/10/2023 in #sapphire-support
Bit.dev API Plugin not working
compiled to a dist and run from within the node_modules folder as a packaged app
26 replies
SIASapphire - Imagine a Framework
Created by TGTGamer on 12/10/2023 in #sapphire-support
Bit.dev API Plugin not working
Yeah commands and listeners work fine
26 replies
SIASapphire - Imagine a Framework
Created by TGTGamer on 12/10/2023 in #sapphire-support
Bit.dev API Plugin not working
Express works fine for me - so I'm really confused and wondering why express would work fine and sapphire would cause me issues
26 replies
SIASapphire - Imagine a Framework
Created by TGTGamer on 12/10/2023 in #sapphire-support
Bit.dev API Plugin not working
Yeah, that's why I was hoping for someone with a brain to help me because mines apparently not functioning hahahaha
26 replies
SIASapphire - Imagine a Framework
Created by TGTGamer on 12/10/2023 in #sapphire-support
Bit.dev API Plugin not working
Any suggestions, Is there an easy way to check the ports and such it's listening on?
26 replies
SIASapphire - Imagine a Framework
Created by TGTGamer on 12/10/2023 in #sapphire-support
Bit.dev API Plugin not working
Yeah going to v0/ didn't work for me
26 replies
SIASapphire - Imagine a Framework
Created by TGTGamer on 12/10/2023 in #sapphire-support
Bit.dev API Plugin not working
Bit.Dev utilises TSC. It's component first build pipelines, so it is designed to handle components. Think of Lerna and your mono-repo tools and add a load of extra utilities on top 🙂
26 replies
SIASapphire - Imagine a Framework
Created by TGTGamer on 12/10/2023 in #sapphire-support
Bit.dev API Plugin not working
Will double check that isn't my problem 🙂
26 replies
SIASapphire - Imagine a Framework
Created by TGTGamer on 12/10/2023 in #sapphire-support
Bit.dev API Plugin not working
Runnning on Local Machine, Bit.Dev is just a build pipeline tool
26 replies