A Microcosm of the Macrocosm
BABetter Auth
•Created by A Microcosm of the Macrocosm on 4/13/2025 in #help
Custom Tables | SQL Schema
I don't even get to generate the schema having the additional field typed like that
["AP", "HF"]
. I get the error I mentioned above.
However, now that I think about it...
TypeScript itself doesn't error out on that [on type: ["AP", "HF"]
]. So, if I just don't run the better-auth cli to generate the schema, then there we go, problem solved, hah. No BA CLI schema generation,no error😂 .14 replies
BABetter Auth
•Created by A Microcosm of the Macrocosm on 4/13/2025 in #help
Custom Tables | SQL Schema
I'd be okay with the type hinting, at least, since these are the two values I'd expect and enforce.
For the actual types, I'd infer them from the edited table schemas. The thing is I can't even type the additional field with
["AP", "HF"]
.
Maybe I'll have to just type it with string and then edit the generated schema - create the pgEnum and properly type the table field.
I just don't know if better-auth is going to be okay with that14 replies
BABetter Auth
•Created by A Microcosm of the Macrocosm on 4/13/2025 in #help
Custom Tables | SQL Schema
By using
type: "string[]"
, I don't get the error and the generated schema has user_type: text('user_type').array()
, but that isn't what I wanted. I wanted it to be mapped to an enum with the coupla values possible.14 replies
BABetter Auth
•Created by A Microcosm of the Macrocosm on 4/13/2025 in #help
Custom Tables | SQL Schema
Error:
14 replies
BABetter Auth
•Created by A Microcosm of the Macrocosm on 4/13/2025 in #help
Custom Tables | SQL Schema
@bekacru
Sorry for the ping, but...
... using a string literal array [as you suggested] for a type [so it can be mapped to a pg enum], I get an error when I try to generate the schema via the BA CLI
My
auth
object looks like
14 replies
BABetter Auth
•Created by A Microcosm of the Macrocosm on 4/13/2025 in #help
Custom Tables | SQL Schema
Fascinating.
THANK YOU VERY MUCH.
I'll work on my Nuxt Project setup then.
If you need any help, please let us know how we can help you out.
Thank you.
14 replies
BABetter Auth
•Created by A Microcosm of the Macrocosm on 4/13/2025 in #help
Custom Tables | SQL Schema
Thank you very much.
Lemme see if I got this straight:
1. for the custom tables, I can create them on the database and that's all. I don't need to tell
better-auth
about them via a custom plugin, stating the extra tables, etc., right?
2. regarding the user
table, it will have an additional field (user_type
), I'll add that to the user's additionalFields
when setting up the auth
instance. For the type of this user_type
I didn't get to set string[]
or Array<LiteralString>
.
Could you help me out saying what exactly I need to type the user_type
with?
3. Okay. For the id
s, I'll just have them as uuid
, to be default generated with get_random_uuid()
, and disable better-auth's default id generation when setting up the auth
object.14 replies