Use uuid
datatype for Drizzle/Postgres user_id
#79
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🎉 First of all, thanks for trying to bring Ruby on Rails DX to the JavaScript ecosystem!
Why
Currently, for some reason
Auth.js
prescribestext
for the user id, while they are using them asuuid
. This is a bit of a problem from a DB standpoint.What
This change is scoped only on the
Postgres
/Drizzle
parts, since that's what I am familiar with. The best would be to change every DB datatype to UUIDs or big integers (Auth.js
doesn't like that, unfortunately) for the user id.Drizzle will transparently convert the values to string, so no change is required on the other sides.
Other DB recommenedations out of scope
Timestamps for all models
It is best to have
created_at
/updated_at
for all models, since they are pretty hard to add after the fact. Users can later remove them.created_at
can be always auto-generated at insert (at least for Postgres).Consolidate naming scheme
Auth.js
people has weird naming schemes:Auth.js
tables use the singular form, likeuser
,account
, etc. in the database. The code still references them in the plural form. A good framework has to be consistent. This behaviour is overrideable, but not easy.snake_case
andcamelBack
in the DB depending on whether the column is anoauth
data orAuth.js
's own. Users don't care, they need cleanliness. This is also not trivial to fix.Use bigger ids
bigserial
would be better to use in the long-run for database primary keys, engines can cope with them and aren't that big of deal for storage. A must have for large tables.Linked accounts
It would be great to explicitly include information about the linked account.
user.name
can actually mean multiple things depending which provider did the user use first. Usually, it's the full name, but it can also mean the login name. It would be far better to save thegithub_login_name
, etc. explicitly, so it can be used later for integrations.Alternatively, this could be saved into a different table, too.
Template-based generation
As I created the PR, I have noticed that the file generation is basically done as string concatenation. Although, this is trivial, it is error prone. It would be far easier to create templates, in a templating language, where the substitutions can occur.
Idempotent generation
Based on the previous point, right now running the generation will append a new configuration to the generated files.
Rails
actually will ask the user what to do in a situation like this.Reduce options
Just looking through the code, it was hard to follow which thing generated what. There are already too many options. It would be far better to start with a smaller subset of technologies first. Make those few well-tested and feature complete (like
tRPC
+Drizzle
+Postgres
). And only then include more things. The ecosystem needs a lot of consolidation already.Sorry, for making this too long, just some toughts. 😄 I hope, this project will succeed! 🥇