Hey there, is there a way to let supertokens use i...
# support-questions
s
Hey there, is there a way to let supertokens use int / bigint instead of uuid as the primary key for the email_passwords table (and probably all other)? Like
user_id
would be 1 instead of "uq814uq-81412...."
r
Hey! You can’t change the userId type. But what you can do is to map the userId we give with her a custom userId in your own db.
Checkout the migration guide, and in there, there will be a user ID mapping section.
s
Mhmm okay thanks. I saw it in the docs
Well does not exactly cover what i need
I would require to have a another type being created by SuperTokens
But it's okay i will find another way to handle it 👍
r
What’s the reason for having it as an int?
s
Just a requirement for the project
r
Hmm. With the user I’d mapping feature, it would be like the user ids issued by supertokens are ints. But up to you 🙂
s
The thing is i am using another ORM to link to this unmanaged table. I can't simply say the type is int when it is uuid or i'll get runtime problems
r
You can store a mapping of int to UUID in your db, and then override the functions we have to fetch int given the uuid, and return that. That way, to your app, the user ids will be ints
s
That would be another table then having this mapping?
r
Yes.
We are also going to release this feature in 2-3 weeks time where we store the mapping as well
s
The thing is i just need to represent what is given by email_passwords table towards my ORM system. So when i reference user.id it is the UUID und recognizes the correct type. So I define it like that:
Copy code
go
func (User) Fields() []ent.Field {
    return []ent.Field{
        field.String("id").
            Unique().
            GoType(uuid.New()).
            Immutable().
            StorageKey("user_id"),
        field.String("email").Unique().Immutable(),
        field.String("password_hash").Unique().Sensitive().Immutable(),
        field.Int("time_joined").Immutable(),
    }
}
r
Oh right. I see.
s
And defining the table:
Copy code
go
func (User) Annotations() []schema.Annotation {
    return []schema.Annotation{
        entsql.Annotation{Table: "emailpassword_users"},
    }
}
It will be a bit tricky to link the mapping table but also the original one
r
So ur mapping to the orm from the db directly?
s
yes
It is to maintain autocomplete and reference
r
Ah I see. Then I’m afraid there isn’t a straightforward way
s
the ORM does not do anything though for this table
r
Hmm ok
s
No worries, it's not a big issue 🙂