-
Notifications
You must be signed in to change notification settings - Fork 122
✨ feat: enhance schema to adopt constraints
data
#1168
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
Conversation
🦋 Changeset detectedLatest commit: 76f9454 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@tnyo43 is attempting to deploy a commit to the ROUTE06 Core Team on Vercel. A member of the Team first needs to authorize it. |
@@ -95,6 +95,7 @@ async function parsePrismaSchema(schemaString: string): Promise<ProcessResult> { | |||
columns, | |||
comment: model.documentation ?? null, | |||
indices: {}, | |||
constraints: {}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR won't update the other format parsers other than tbls because I think it will make this change too large.
const cardinalitySchema = v.picklist(['ONE_TO_ONE', 'ONE_TO_MANY']) | ||
export type Cardinality = v.InferOutput<typeof cardinalitySchema> | ||
|
||
const foreignKeyConstraintSchema = v.picklist([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One of the new constraint schemas will be named as foreignKeyConstraintSchema
, so it will rename this schema as foreignKeyConstraintReferenceOptionSchema
(it's a little bit hard to find the diffs because this PR will change the order of declarations 😓 )
I refer to the MySQL document to to name the schema as ReferenceOption
. https://dev.mysql.com/doc/refman/8.4/en/create-table-foreign-keys.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍🏻
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
This comment was marked as resolved.
This comment was marked as resolved.
the current `foreignKeyConstraintSchema` does not represents foreign key constraint itself but its reference option. I refer to the MySQL document to to name the schema as `ReferenceOption` ref: https://dev.mysql.com/doc/refman/8.4/en/create-table-foreign-keys.html
8acfdbe
to
f67e2df
Compare
frontend/packages/db-structure/src/schema/overrideDbStructure.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!! almost good, please check comments!
const cardinalitySchema = v.picklist(['ONE_TO_ONE', 'ONE_TO_MANY']) | ||
export type Cardinality = v.InferOutput<typeof cardinalitySchema> | ||
|
||
const foreignKeyConstraintSchema = v.picklist([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍🏻
frontend/packages/db-structure/src/schema/overrideDbStructure.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍🏻👍🏻
Issue
constraints
data, such as primary key, unique, foreign key and check constraitns.Why is this change needed?
The current db-structure schema drops the
constraints
data of tbls schema. Especially, check constraints of the schema can't be expressed with the current schema.This PR will enhance the schema to adopt
constraints
data and prepare for implementing the UI using it.What would you like reviewers to focus on?
tbls
format parser with constraintsTesting Verification
What was done
🤖 Generated by PR Agent at 8acfdbe
PRIMARY KEY
,FOREIGN KEY
,UNIQUE
, andCHECK
constraints.PRIMARY KEY
,FOREIGN KEY
,UNIQUE
, andCHECK
constraints.Detailed Changes
8 files
Add constraints handling to Prisma schema parser
Add constraints handling to Schema.rb parser
Add constraints handling to PostgreSQL schema converter
Add constraints handling to tbls schema parser
Define schema for constraints and integrate into table schema
Update table factory to include constraints
Export constraints-related types and schemas
Add support for overriding constraints in database structure
2 files
Add tests for constraints in tbls schema parser
Add tests for overriding constraints in database structure
1 files
Add changeset for constraints enhancement
Additional Notes