pgEnum in multiple tables

How should I use the same enum in multiple tables? For example I have this enum in:
const ROLES = ['owner', 'admin', 'editor', 'viewer'] as const
const roleEnum = pgEnum('role', ROLES)
// in table I use it like this:
role: roleEnum('role')
const ROLES = ['owner', 'admin', 'editor', 'viewer'] as const
const roleEnum = pgEnum('role', ROLES)
// in table I use it like this:
role: roleEnum('role')
If I want to use the same role enum in another table should I use the same pgEnum `const roleEnum = pgEnum('role', ROLES) i.e. import it? Or create the same pgEnum again?
1 Reply
Angelelz
Angelelz15mo ago
I believe either way will work
Want results from more Discord servers?
Add your server