Repository navigation
Todo
Labels
enhancementNew feature or request
Description
Is your feature request related to a problem? Please describe.
- Importing into an instance that already has an older version of the application must not surprise anyone.
Why this is needed
- An administrator who installs a newer version of an application on an instance that has an older one must see what will change before it changes. Without a dry run an import changes tables and pages that people work in.
- buildiq parity: buildiq has versions with a diff before promotion (missing in Tables, section 5 of the feature comparison), and its generated app imports its definition on repair (section 6). Our generated app imports through the Tables API in the same way.
- It depends on the manifest export (Export an application as a manifest on api/2 #3450) and grows from the scheme
preview-changesroute and Match imported pages on application slug and page slug together #3346. Packaging (Generate an installable app from an application #3461, Install a generated app on a clean instance #3462) and the import of another builder's manifest (Import an application from another builder's manifest #3459) use this import.
Describe the solution you'd like
- An
api/2route that imports a manifest, and a dry run that lists what an import would create, change or leave alone, like the schemepreview-changesroute.
Diagram
sequenceDiagram
actor M as Manager
participant API as New manifest import route
participant IS as New manifest import service
participant DB as Database
M->>API: POST the manifest as a dry run
API->>IS: match by slug, columns and views by technical name
IS->>DB: read the current application
IS-->>API: per item create, change or keep
API-->>M: preview
M->>API: POST the manifest to import
API->>IS: the same plan
IS->>DB: begin a transaction
IS->>DB: create missing, update changed, delete only with the option
IS->>DB: commit, or roll back on failure
API-->>M: result
Acceptance Criteria
- The dry run lists per table, column, page and menu item: create, change or keep.
- The import creates what is missing and updates what changed, matched by slug (columns and views by their existing technical name).
- Nothing is deleted without an explicit option.
- A failed import leaves nothing half done.
- Unit tests, and an import of the example from Export an application as a manifest on api/2 #3450.
- The import into an existing application: the route declares its permission with
#[RequirePermission](manage on the application) using a fixed node type (context), and the service checks the same right before it writes (as agreed on UUIDs for rows #3093 and in the review of feat(contexts): give applications a menu with its own API #3135). A test runs every write as a reader and expects 403, or 404 where the reader may not know the object exists. Importing as a new application needs no rights beyond an account. - A delete with the explicit option removes what depends on the deleted item (widgets, menu items, links of Link a row to objects in other apps: mails, Deck cards, files, rows of other tables #3468) in the same transaction as the rest of the import.
Out of scope
- Rows as data (Rows as optional data in a manifest #3452), the ZIP (Export and import an application as a ZIP with its data #3458) and manifests from another builder (Import an application from another builder's manifest #3459).
- Deleting by default: only with the explicit option.
- Proposed slicing, one PR each in landing order: the dry run, then the import.
Describe alternatives you've considered
Questions for maintainers
- A column in the manifest with the same technical name but another type than on the instance: change the type, or refuse and report it in the dry run? We would go with refusing, because a type change can lose data in the cells.
- The dry run: a flag on the import route, or its own route like the scheme's
preview-changes? We would go with its own route, to match the scheme routes that exist. - Who may import into an existing application: its owner only, or anyone with manage rights on it? We would go with manage rights, the same right that edits its pages today.
Additional context
Linking to other objects
- The issue creates or changes an application with its tables, columns, pages and menu items.
- Today: the scheme import maps old node ids to new ones (
nodeRelMapinContextService::importWidgets), and Relations: filter, sort, inverse lookups, inline resolve, import and export #3347 covers remapping relations on import. Links of Link a row to objects in other apps: mails, Deck cards, files, rows of other tables #3468 are stored by row and table id. - What this issue must do: on an update, match by slug and keep the existing ids, so relations and links that point at existing rows and tables keep working. When the import deletes a table or column (only with the explicit option), the dry run lists the relations and links that would break, and the delete cleans up links as Link a row to objects in other apps: mails, Deck cards, files, rows of other tables #3468 describes. The dry run also lists relation columns whose target table is missing from the manifest and the instance.
Relevant files:
Related issues
- fix(contexts): answer an unknown and an unmanageable uuid alike on scheme import #3202
- Match imported pages on application slug and page slug together #3346
- Relations: filter, sort, inverse lookups, inline resolve, import and export #3347
- links between rows and other apps (Link a row to objects in other apps: mails, Deck cards, files, rows of other tables #3468)
Drafted with AI assistance from the project plan; @rjzondervan reviews it. Part of #3419.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or request
Activity