Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: schema #229

Merged
merged 6 commits into from
Jun 26, 2024
Merged

fix: schema #229

merged 6 commits into from
Jun 26, 2024

Conversation

seaerchin
Copy link
Contributor

Problem

Original schema specifies cuid, which is problematic on 2 fronts

  • first, cuid is a randomly generated id which is difficult for our users to remember
  • next, cuid is not generated in db (prisma uses js to autogen). this leads to typing on kysely output being String instead of GeneratedAlways<String>.

Solution

  • change to auto-incrementing ids
    • note that now, the output of kysely types is GeneratedAlways
  • update migration

@seaerchin seaerchin requested a review from a team as a code owner June 25, 2024 08:33
Copy link

vercel bot commented Jun 25, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
isomer-studio ❌ Failed (Inspect) Jun 26, 2024 5:06am

Comment on lines +1 to +6
import { type IsomerSiteProps } from '@opengovsg/isomer-components'

export type Navbar = { items: IsomerSiteProps['navBarItems'] }

export interface FooterItem {
title: string
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is cherry-picked, downstream will refer correctly to IsomerSiteProps

Copy link
Contributor

@dcshzj dcshzj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No blocking comments

apps/studio/prisma/schema.prisma Outdated Show resolved Hide resolved

export type Navbar = { items: IsomerSiteProps['navBarItems'] }

export interface FooterItem {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I suspect most of the types that we need on the CMS should be able to be derived from the exported props one way or another, so we might not need to re-define them here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exported for ease of use cos it's very tedious to type Isomer...['...'] every time ._.

apps/studio/prisma/seed.ts Show resolved Hide resolved
remove /
add type
@seaerchin seaerchin merged commit 41c44a4 into main Jun 26, 2024
6 of 9 checks passed
@seaerchin seaerchin deleted the fix/schema branch June 26, 2024 05:06
role: RoleType
}
export type Resource = {
id: string
id: GeneratedAlways<number>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this change affect the current tRPC schema, specifically the types?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, they've been updated here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants