Column Unique name appears to be incorrect when spreading common fields to multiple tables

Came across this issue. Not sure if it's a big deal but i am spreading a common set of timestamp fields around to most of my tables and it looks like the unique name is incorrect. It looks like all my tables have this 'organizations_created_at_unique' naming convention on them with the unique field

[ 'created_at', 'PgTimestamp', 'organizations_created_at_unique' ],
  [ 'updated_at', 'PgTimestamp', 'organizations_updated_at_unique' ],
  [ 'deleted_at', 'PgTimestamp', 'organizations_deleted_at_unique' ]


import { contacts } from '@/db/schema'

const { columns } =
    await getTableConfig(contacts)

console.log(columns.map(c => [c.name, c.columnType, c.uniqueName]))


This is passed
// Pass this to all necessary tables
export const createdAndUpdatedAtFields = {
    createdAt: timestamp('created_at').defaultNow().notNull(), // autogenerate when record created
    updatedAt: timestamp('updated_at'), // manually update
    deletedAt: timestamp('deleted_at'), // for soft deletes
}


export const contacts = pgTable('contacts', {
    contactId: uuid('contact_id')
        .default(sql`uuid_generate_v7()`)
        .primaryKey(),
    firstName: varchar('first_name', { length: 100 }),
    lastName: varchar('last_name', { length: 100 }),
    ...createdAndUpdatedAtFields,
})
image.png
Was this page helpful?