iTwin / itwinjs-core

Monorepo for iTwin.js Library
https://www.itwinjs.org
MIT License
606 stars 210 forks source link

Unable to edit the contents of a newly-created WorkspaceDb #6811

Closed pmconne closed 1 month ago

pmconne commented 3 months ago
          @kabentley `WorkspaceEditor.createDb` appears to be unusable. It will upload a new, empty db, and then throw an error trying to retrieve it for editing.
Error: abies:1.0.0 has been published and is not editable. Make a new version first.
      at EditorContainerImpl.getEditableDb (/home/paul/c/j2/s/itwinjs/core/backend/src/internal/workspace/WorkspaceImpl.ts:553:13)
      at EditorContainerImpl.getWorkspaceDb (/home/paul/c/j2/s/itwinjs/core/backend/src/internal/workspace/WorkspaceImpl.ts:548:17)
      at EditorContainerImpl.createDb (/home/paul/c/j2/s/itwinjs/core/backend/src/internal/workspace/WorkspaceImpl.ts:591:17)
      at Context.<anonymous> (src/backend/WorkspaceExamples.test.ts:327:7)

_Originally posted by @pmconne in https://github.com/iTwin/itwinjs-core/pull/6646#discussion_r1630231737_

pmconne commented 3 months ago

EditableWorkspaceContainer.createDb uploads a new empty db to the cloud, then tries to getEditableDb, which throws because the db is "published", telling you you must create a new version to edit it.

Similar problem with createNewWorkspaceContainer, which uploads a new, empty default WorkspaceDb that can only be edited by creating a new version of it.

williamkbentley commented 2 months ago

I would like to propose new functionality where prerelease versions of WorkspaceDbs can be edited, even after being published (skipping the "copied" check as @kabentley described). Justification being prerelease versions are:

This could also solve this Issue if new Dbs were created with 0 as the major version. Users would then need to publish the 1.x version when they've added their desired resources. I dont really have strong justification for this other than it solves the "create then immediately version" issue and its strange to have a flag that can totally circumvent the entire versioning and immutability features of workspaces.

I can raise a PR for these changes