# Upgrading

## From 2.x

Version 3 is a new application with a new database. Your content and `.pages.yml` stay in GitHub. The only data to move is collaborators.

### 1. Deploy 3.x next to 2.x

Deploy 3.x as a new instance with a fresh database, following the guide for your platform. Keep 2.x running so you can roll back.

### 2. Move collaborators

You'll need `psql` and a read-only backup of the 2.x PostgreSQL database. In your 3.x project, point the script at the backup and the new database, then run it:

```bash
export COLLABORATORS_SOURCE_URL="postgres://..."
export DATABASE_URL="libsql://..."
export DATABASE_AUTH_TOKEN="..."
npm run migrate:2x
```

On Cloudflare, generate SQL and apply it to D1 instead:

```bash
npm run migrate:2x -- --output=collaborators.sql
npx wrangler d1 execute DATABASE --remote --file=collaborators.sql
```

People sign in again on 3.x. Their verified email links them to the imported assignments, including assignments without a linked 2.x account. Existing sessions and invitation links work only on 2.x. The script stops on branch restrictions, missing repository IDs, conflicting assignments and bound accounts whose email differs from the assignment. Confirm the intended scope and recipient before resolving a flagged row. Use a fresh destination for the final import. Repeating an import updates matching assignments and leaves earlier grants in place, including grants revoked since the first export.

### 3. Update configuration

- Open **Configuration** in each project and fix any validation errors.
- Move translations to root `i18n` and field-level `localized`. See [Localization](/docs/configuration/localization/).
- Replace Lucide icon names with [Hugeicons](https://hugeicons.com) names.
- Port custom fields to plugins. See [porting a version 2 field](/docs/extending/field-api/#porting-a-version-2-field).
- Record the existing provider URLs for rollback. At the switch, check the paths even if you keep the same domain. On the existing GitHub App, use the 3.x origin with `/api/auth/callback/github` for sign-in, `/` for post-install setup and `/api/webhook/github` for webhooks. If you offer Google sign-in, register `/api/auth/callback/google` on the same origin.

### 4. Switch over

Sign in, save an edit, check a collaborator's access and push a change to GitHub to confirm webhooks arrive. Before switching traffic, freeze 2.x changes to assignments, including webhook and sign-in updates. Import the final snapshot into the fresh destination and compare the assignments with the frozen source. Keep the old instance fenced during the handoff.
