# Upgrades and your customisations

> How app upgrades keep your changes, how to review the values that clash, and how an app author limits what installers may change.

Source: https://docs.ligament.ai/guides/building-apps/upgrades/

When you change a page that an installed app ships, Ligament keeps your change separate from the app’s version of the page. When you upgrade the app, it combines the new version with your change instead of replacing it. When you both changed the same value, yours is kept and flagged for you to review.

## Two layers

Every page an installed app ships has a `base` layer, the app’s version, which you can’t edit. The first time you change it, your version is saved as a `custom` layer on top, and that’s what runs. The page builder then shows the page as **Customised · shipped by office\_moves 1.0.0**, and the plan describes your edits as a *Customisation of the shipped office\_moves version*.

To go back to the app’s version, apply the shipped document again, or send the item with `"delete": true`. The plan calls that a reset: *reset to the shipped office\_moves version*.

## Upgrade an app

Open the **App Store** and select **Updates available**. Each app with a newer version has an **Update to v1.1.0** button. It opens a summary of the upgrade: the version change, the author’s release notes, every change the new version makes, and whether it changes fields that hold data. Select **Update** to upgrade.

If an upgrade would remove or reshape fields that hold data, the summary lists what’s at risk and asks you to confirm. Over the API, `POST /api/apps/upgrade` with `{ "appKey": "office_moves", "preview": true }` returns the same assessment without changing anything; an upgrade at risk answers `409` until you send `"confirm": true`. Upgrading needs a workspace admin, or a key with the `apps:install` scope.

### What the summary lists

The summary lists every change the new version makes, grouped by what it changes: the app’s settings and store listing, navigation, dependencies, entities, fields, form and panel options, form layouts, states, transitions, business rules, ACLs, SLAs, seed records, hierarchies, effective dating, workflows, scripts, agents, connectors, widgets, saved views, reports, dashboards, pages, fields the app adds to other apps’ entities, and its access model (one line per permission set, role and restriction). A change that fits none of these is listed under **Other**, so nothing a version changes is left out.

When the upgrade touches something you can edit in your workspace, the line says what happens to your copy:

| Label | Meaning |
| --- | --- |
| **Added** | The workspace doesn’t have it yet; the upgrade creates it (for example the default form layout of an entity that had none). |
| **Takes new** | You never changed your copy, so it follows the app. |
| **Kept yours** | You changed your copy, so the upgrade leaves it as it is. |
| **Merged with yours** | A page you customised is re-based, as described below. |

In the API response, each line is an item of `assessment.diff.changes`, with `category`, `target`, `op` (`add`, `remove` or `change`), the changed `paths`, a `summary`, and `customised` and `resolution` when your copy is involved.

### Form layouts, views, reports and dashboards

An upgrade never overwrites an entity’s default form layout that you edited. The summary lists it as **Kept yours**, with a **Take new** checkbox: tick it to replace your layout with the new version’s. Over the API, send the entity keys in `takeLayouts`, for example `{ "appKey": "csm", "takeLayouts": ["success_signal"] }`. Where the record page shows Activity and Attachments is kept either way, and on a kept layout the app’s default placement still updates.

The same goes for the shared saved views, reports and dashboards an app ships: one you edited is kept, and one you never changed takes the new version.

A kept layout can miss a field the new version made required, or one an earlier layout left out. The create form never blocks on that: every required field that the layout leaves out (and that has no default and isn’t filled in automatically) appears in a **Required** section at the top of the form. Admins see a link to the form layout there, so they can place the field properly. If a save still fails on a field the form doesn’t show, the message names the field and says how to add it to the layout.

App authors: publishing refuses a manifest whose `layout` leaves out a required field, or whose `formOptions.hiddenFields` hides one, unless the field is filled in automatically (an auto-number, a calculated field, or a before-create rule that sets it). The error names the entity and the field.

### Connectors

A connector an app ships keeps the connection settings you gave it: its base URL, allowed hosts and authentication (which secret, which header). The upgrade takes the new version’s value only for a setting you left as the previous version shipped it; its operations always follow the new version. If the upgrade can’t tell what the previous version shipped, your settings are kept.

### Access

An app that ships its access model in its manifest upgrades it the same way: your changes to its permission sets, roles and restrictions are kept, and a change in the new version that would give anyone more access isn’t applied until you approve it. The summary lists those under **These changes widen access**; tick the ones to approve, and the others stay as they are and are offered again next time. Over the API, an upgrade with an undecided widening change answers `409` (`access_widening`); send `approveAccess`, `keepAccess` or `holdAccess`. See [Access in the manifest](https://docs.ligament.ai/guides/building-apps/access-in-the-manifest/index.md#upgrade).

### Seed records

The default records an app ships with an entity (its `seed`) are created once. An upgrade creates only the rows the workspace doesn’t have yet, matched by the entity’s `seedKey` field, or else by the row’s `key`, `code` or `name`. A seed row with none of these is created on the first install only. An upgrade never changes or deletes a record created from a seed row.

## What happens to your changes

For every page the new version ships, Ligament compares three documents: the old shipped page, your customised page and the new shipped page.

| Situation | Result |
| --- | --- |
| You never changed the page | The new shipped page goes live. |
| You and the app changed different things | Your page is re-based: it gets the app’s changes and keeps yours. |
| You and the app changed the same value | Your value is kept, and the clash is listed for review in Build › Changes. |
| The combined page no longer validates | Your page stays exactly as it was, and that is listed for review too. |
| The new version no longer ships the page | A page you customised stays, as the workspace’s own page. A page you never changed is removed. |

An example: Northwind customised the Office moves home page, changing the heading from “Desk moves” to “Desk moves at Northwind HQ”. Version 1.1.0 of the app changed the same heading to “Desk moves and floor changes” and showed 20 upcoming moves instead of 10. After the upgrade, the page shows 20 moves and keeps Northwind’s heading, and the heading is listed as a conflict. The page’s history records the upgrade as *office\_moves 1.1.0 re-based (1 conflict kept your value)*.

## Review the conflicts

**Build › Changes** lists **Upgrade conflicts** above the changesets: one line per page, with the number of values to review. Select a page to open its review:

\[Screenshot: Upgrade conflicts for the Office moves page: the path blocks\[id=intro\].props.text with the old shipped value Desk moves, your kept value Desk moves at Northwind HQ and the new shipped value Desk moves and floor changes\]

For each value you see the old shipped value, your value (kept) and the new shipped value.

-   Every value starts on **Keep my value**. Select **Keep my values** to mark the list reviewed: nothing on the page changes.
-   Switch a value to **Take the shipped value**, and the button becomes **Take 1 shipped value and mark reviewed**. That applies a new version of your customisation with the shipped value; values you left on Keep my value stay as they are.

Either way, the page leaves the Upgrade conflicts list. Make all your choices for a page before you save: saving clears that page’s whole list.

From the API, `GET /api/spec/<address>` returns the open conflicts of a customised artefact in `conflicts`, and `GET /api/spec/conflicts` lists every artefact with conflicts.

## How much installers may change

An app’s author decides how much the workspaces that install it may change, with the app’s edit policy. For an app you build in Build › Apps, it’s **How much installers can customize it** on the app’s Overview; in an [app manifest](https://docs.ligament.ai/developers/app-spec/index.md) it’s `editPolicy`. It applies to the app’s pages, entities, fields and workflows.

| Policy | Installers can |
| --- | --- |
| `full` (default) | Change anything: add fields, edit labels, customise pages, override workflows |
| `additive` | Add their own fields, entities and page blocks, but not change or remove what the app ships |
| `locked` | Change nothing the app ships |

Under `additive`, a page change that keeps everything the app ships and adds to it plans fine. A change to something shipped is refused in the plan:

```text
spec.additive: the "office_moves" app is additive-only: you can add to office_moves/page/office_moves_home but not change or remove what it ships
```

The comparison is with the shipped page, so a page you customised before the author switched to `additive` has to be reset to the shipped version before you can add to it. Under `locked` the plan answers `spec.locked`. The policy is read from the version you have installed, so it changes when you upgrade.

Fields follow the same rule. Under `additive`, renaming a field the app ships (or changing whether it’s required) is refused with `403` and the code `app_edit_policy`; adding your own field works. Under `locked`, every field change is refused, including removing a field you added:

```json
{
  "error": "This is part of the \"office_moves\" app, which is additive-only (you can add your own fields, but not modify what the app ships).",
  "code": "app_edit_policy",
  "message": "This is part of the \"office_moves\" app, which is additive-only (you can add your own fields, but not modify what the app ships).",
  "fix": "Add your own field (or entity) instead of changing the one the app ships, or ask the app's author for a version that changes it.",
  "policy": "additive",
  "app": "office_moves",
  "doc_url": "https://docs.ligament.ai/guides/building-apps/upgrades/#how-much-installers-may-change"
}
```

Overriding a workflow the app ships answers the same way under `additive` and `locked`.
