-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Add delete name column from standard object tables #7470
Add delete name column from standard object tables #7470
Conversation
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.
PR Summary
This pull request introduces a new command to delete the 'name' column from standard object tables in existing workspaces as part of the upgrade process to version 0.31.
- Added
DeleteNameColumnStandardObjectTablesCommand
inpackages/twenty-server/src/database/commands/upgrade-version/0-31/0-31-delete-name-column-standard-object-tables.command.ts
- Integrated new command into
UpgradeTo0_31Command
execution flow inpackages/twenty-server/src/database/commands/upgrade-version/0-31/0-31-upgrade-version.command.ts
- Updated
UpgradeTo0_31CommandModule
to include the new command inpackages/twenty-server/src/database/commands/upgrade-version/0-31/0-31-upgrade-version.module.ts
- Command checks for existing 'name' column and field metadata before deletion, with dry run option and error handling
3 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings
const nameColumnExists = await queryRunner?.hasColumn( | ||
standardObject.nameSingular, | ||
'name', | ||
); |
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.
logic: Ensure queryRunner is not null before using optional chaining
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 !
continue; | ||
} | ||
|
||
if (!nameColumnExists) { |
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.
is there a usecase in which we expect to have the fieldMetadata but not the column? or would that just not be our problem here
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.
Good point however that shouldn't be possible or at least that should be part of the sync-metadata health-check (which is broken though...)
Following this twentyhq#7428 we now need to fix existing workspaces thanks to this migration command. This command will fetch all standard objects and their fields then filter out tables that don't have that column OR objects that have an existing fieldMetadata "name" of type TEXT and delete the rest.
Following this #7428 we now need to fix existing workspaces thanks to this migration command.
This command will fetch all standard objects and their fields then filter out tables that don't have that column OR objects that have an existing fieldMetadata "name" of type TEXT and delete the rest.