-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feat: add support for PostgreSQL table inheritance in schema export #493
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
base: main
Are you sure you want to change the base?
feat: add support for PostgreSQL table inheritance in schema export #493
Conversation
Someone is attempting to deploy a commit to the dottle's projects Team on Vercel. A member of the Team first needs to authorize it. |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
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 for taking the time to work on this
<div className="min-w-20 flex-1/3"> | ||
<div | ||
className="min-w-20 flex-1/3" | ||
style={inherited ? { opacity: 0.6 } : {}} |
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.
style={inherited ? { opacity: 0.6 } : {}} |
<Input | ||
value={data.name} | ||
id={`scroll_table_${tid}_input_${index}`} | ||
validateStatus={data.name.trim() === "" ? "error" : "default"} | ||
validateStatus={ | ||
data.name.trim() === "" && !inherited ? "error" : "default" |
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.
names still shouldnt be empty and overriding an inherited fields should result in an error
data.name.trim() === "" && !inherited ? "error" : "default" | |
data.name.trim() === "" || inherited ? "error" : "default" |
@@ -49,7 +54,12 @@ export default function TableField({ data, tid, index }) { | |||
]); | |||
setRedoStack([]); | |||
}} | |||
readOnly={inherited} | |||
style={inherited ? { backgroundColor: "#f5f5f5" } : {}} |
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.
/> | ||
{inherited && ( | ||
<span style={{ fontSize: 12, color: "#888" }}>Inherited</span> |
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.
when an inherited field gets overridden an error should be reported, instead of showing this here please add an issue in issues.js
|
||
return ( | ||
<div> | ||
{database === DB.POSTGRES && ( |
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.
move this below the tablefield list above comments
the table info should start with the most characteristic attributes such as name and columns
.map((t) => ({ label: t.name, value: t.name }))} | ||
onChange={(value) => updateTable(data.id, { inherits: value })} | ||
placeholder="Select parent tables" | ||
style={{ width: "100%" }} |
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.
tailwind please
@@ -56,6 +56,10 @@ export const tableSchema = { | |||
}, | |||
color: { type: "string", pattern: "^#[0-9a-fA-F]{6}$" }, | |||
}, | |||
inherits: { | |||
type: "array", | |||
items: { type: ["string", "integer"] }, |
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.
how can it be an integer?
items: { type: ["string", "integer"] }, | |
items: { type: ["string"] }, |
|
||
return ( | ||
<div> | ||
{database === DB.POSTGRES && ( | ||
<div className="mb-2"> | ||
<div className="text-md font-semibold break-keep">Inherits:</div> |
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.
use translation please
<div className="text-md font-semibold break-keep">Inherits:</div> | |
<div className="text-md font-semibold break-keep">{t('inherits')}:</div> |
) | ||
.join("\n"); | ||
|
||
return `CREATE TABLE "${table.name}" (\n${fieldDefinitions}${primaryKeyClause}${inheritsClause};\n${commentStatements}\n${indexStatements}`; |
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.
Summary
This PR adds full support for PostgreSQL table inheritance in the schema export generator (#472).
What's Included
INHERITS
clause inCREATE TABLE
statements.PRIMARY KEY
,UNIQUE
,NOT NULL
DEFAULT
,CHECK
, andARRAY
modifiers.Implementation Notes
table.inherits
array to determine parent table(s).inheritedFieldNames
from parent tables to avoid duplication.PRIMARY KEY
generation to apply only to non-inherited fields in child tables.🖥️ Screen Recording
