Skip to content

Table scheme import - #2888

Draft
luka-nextcloud wants to merge 8 commits into
mainfrom
table-scheme-import
Draft

Table scheme import#2888
luka-nextcloud wants to merge 8 commits into
mainfrom
table-scheme-import

Conversation

@luka-nextcloud

Copy link
Copy Markdown
Contributor

🖼️ Screenshots

🏚️ Before 🏡 After
B A

🏁 Checklist

  • ⛑️ Tests (unit and/or integration) are included or not needed
  • 🔙 Backport requests are created or not needed: /backport to stableX.X
  • 📅 Milestone is set
  • 🌸 PR title is meaningful (if it should be in the changelog: is it meaningful to users?)

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI

@blizzz blizzz linked an issue Aug 14, 2026 that may be closed by this pull request
8 tasks
luka-nextcloud and others added 6 commits August 17, 2026 09:15
Signed-off-by: Luka Trovic <luka@nextcloud.com>
Signed-off-by: Luka Trovic <luka@nextcloud.com>
Signed-off-by: Luka Trovic <luka@nextcloud.com>
Signed-off-by: Luka Trovic <luka@nextcloud.com>
Signed-off-by: Luka Trovic <luka@nextcloud.com>
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Signed-off-by: Luka Trovic <luka@nextcloud.com>
Signed-off-by: Luka Trovic <luka@nextcloud.com>

@blizzz blizzz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Early comments, some can be left for later.

UI wise it looks really nice already!

Image
  • I would not display the UUID as title in the check box. It looks technical and table managers will have not deeper knowledge about it. Would completely keeps this identifier internal and instead use the New Title.

  • In my quick test I also see that Views would be dropped instead of being kept

  • Maybe need to double check the sort order as well when nothing is defined

This is very promising already! :)

$qb->setParameter('uuid', Uuid::v7()->toRfc4122());
$qb->executeStatement();
}
$this->connection->commit();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In Version2020Date20260513185340 I commit and start a new transaction every 250 writes for performance reasons. Could be an improvement here as well, beneficiary on updates on instances with many tables. But will work, can be addressed later.

* 404: Not found
*/
#[NoAdminRequired]
#[RequirePermission(Application::PERMISSION_MANAGE, null, 'context', 'contextId')]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nitpick, also can be done in a follow up, just for readability it think this is nicer:

Suggested change
#[RequirePermission(Application::PERMISSION_MANAGE, null, 'context', 'contextId')]
#[RequirePermission(permission: Application::PERMISSION_MANAGE, typeParam: 'context', idParam: 'contextId')]

applies to the other similar lines as well.

(yes it was used somewhere like this here before, that can also be improved)

Again, not a blocker, by-catch, good enough with follow-up.

*/
#[NoAdminRequired]
#[RequirePermission(Application::PERMISSION_MANAGE, null, 'context', 'contextId')]
public function importScheme(int $contextId, ?string $name, ?string $iconName, ?string $description, ?array $nodes, ?array $tables): DataResponse {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Node sure I understand correctly the role of $nodes vs $tables. Maybe have an idea with the TODO against the nodes.

foreach ($columns as $column) {
if (isset($column['uuid'])) {
try {
$existColumn = $this->mapper->findByUuid($column['uuid']);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is fetching by UUID important here? My notion is, as with the StructureService, to create a diff between the incoming and existing column and then add, modify (or keep), and remove. This requires checking what is there, then we do need to fetch by UUID (which done one-by-one as also rather expensive, and we have intentionally no index there).

use OCA\Tables\Errors\NotFoundError;
use OCA\Tables\Errors\PermissionError;

class StructureService {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I know it comes from me, just to note down one thought that circles my mind is whether to add Stateful to the class name for safer usage 🤔 Again, nothing that cannot be improved upon later on.

$columns = $this->columnService->findAllByTable($id, null, $table);
$this->enhanceTable($table, $userId);
return new TableScheme($table->getTitle(), $table->getEmoji(), $columns, $table->getViews() ?: [], $table->getDescription() ?: '', $this->appManager->getAppVersion('tables'), $table->getColumnOrderSettingsArray(), $table->getSortArray());
$this->enhanceTable($table, $userId ?? $this->userId);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

i suppose there is a reason for this line change? ^

private function handleViewPersistDbException(\OCP\DB\Exception $e, string $context): never {
if ($e->getReason() === \OCP\DB\Exception::REASON_UNIQUE_CONSTRAINT_VIOLATION) {
throw new BadRequestError('Technical name must be unique in the table.');
throw new BadRequestError('Technical name must be unique in the table. ' . $e->getMessage());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

intentional line change?

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.

Structure update

2 participants