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
This is passed
11 Replies
Interesting, not sure if that'll have any impact...
Can you try creating the table like this:
I just wonder if creating a brand new object per table, would create an unique name
Pinging @Andrew Sherman for his insight
so the problem is that the name is the same across different tables?
Oh, or that you don't have unique and still see the unique name?
Who call build on the
ColumnBuilder
classes? Is it drizzle-kit or the drizzle object when you pass in the schema?
And what is uniqueName used for anyway?drizzle-kit just calls
getTableConfig()
https://orm.drizzle.team/docs/goodies#get-table-information and gets all the info about table
uniqueName is used by drizzle-kit to drop unique by it's name, and to create with a specific name(user can specify a custom unique constraint name)Goodies – DrizzleORM
Drizzle ORM | %s
so uniqueName is not used in drizzle-orm at all
it's just a metadata for
getTableConfig()
and for anyone using it
either it's drizzle-kit or some other library that depends on drizzle-orm schema metadata
it's generated here by default, didn't see any problems on generating it for a column. But now I think I can generate it only when .unique() functions is useddoesn't seem to change the result
You would need to create an unique name yourself if that's an issue.
Just to be sure, uniqueName is about name of a unique constraint that may be generated for this column
My bad to generate it always, even if unique constraint us not set up
It won’t cause any issue now
Just internal metadata
I guess we will need to improve it a bit
Does this get fed to the migrations? That’s the only place I could see it cause issues perhaps if you create constraints and it’s with the wrong unique name that gets pushed to the db
Yeah but you have the option to put whatever name you want in the object you pass to
.unique()
Ah - makes sense. Got it