# Moving from Supabase or Vercel

> Move your Supabase or Vercel project to Hosting by Infaris in one command, with a plan first, nothing overwritten and a report afterwards.

Source: https://docs.infaris.com/en/pulseguard/hosting-overstappen

`infaris-guard hosting migrate` moves a Supabase or Vercel project to Hosting by Infaris. Check the location of each target service; edge sites and external providers may process outside the EU. The source is only read: the CLI changes nothing at Supabase or Vercel, so you cancel there only once everything works.

It always works like this:

1. **The plan first.** `--plan` shows exactly what will happen. Nothing changes yet, not on our side either.
2. **Then run it with `--yes`.** Nothing that already exists at Infaris is overwritten; a name that is taken stops that step with a clear message.
3. **Resume.** If a run is interrupted, run the same command again. Progress lives in `.infaris/migrate-<source>-<project>.json` (no secrets) and the CLI continues at the step where it stopped.
4. **The report.** Afterwards you get `.infaris/migrate-<source>-<project>.md` with what moved, what did not and why, and `.infaris/migrate-<source>-<project>.env.diff` with the variables your app must change.

Guard shows the progress under **Hosting > Move a site > Moving from Supabase or Vercel**, also while the command is running.

## What you need

- The CLI, signed in: `bun add -g @infaris/guard-cli` and `infaris-guard login`.
- For Supabase, and for Postgres/Neon on Vercel: the **PostgreSQL 17 client** (`pg_dump` and `psql`), for example `apt install postgresql-client-17` or `brew install postgresql@17`. If it is not on your `PATH`, set `INFARIS_PG_BIN` to its bin directory.

## Secrets

Tokens and passwords never go in as a flag value (that ends up in your shell history and the process list). The CLI reads them from:

- the environment: `SUPABASE_DB_URL`, `SUPABASE_ACCESS_TOKEN`, `SUPABASE_SERVICE_ROLE_KEY`, `VERCEL_TOKEN`;
- a file: `--secrets-file .env.migrate` (dotenv format);
- or stdin for one of them: `--db-url -`, `--access-token -`, `--service-role-key -` or `--vercel-token -`.

Secrets never reach a log, the report, the progress file or Guard. The temporary database dump is only on disk encrypted (AES-256-GCM, the key only in memory) and is deleted right after the upload, also on an error or Ctrl-C. We restore it in the EU.

## Supabase

```bash
export SUPABASE_DB_URL='postgresql://postgres.<ref>:<password>@aws-0-eu-central-1.pooler.supabase.com:5432/postgres'
export SUPABASE_ACCESS_TOKEN=sbp_...   # optional: functions, region, files
infaris-guard hosting migrate supabase <project-ref> --plan
infaris-guard hosting migrate supabase <project-ref> --yes
```

The database url is in Supabase under **Project Settings > Database > Connection string** (session pooler). Make the access token under **Account > Access Tokens**.

| Part | What happens |
| --- | --- |
| Database | A managed Postgres 17 database (EU). Schema, data, functions, triggers, views and RLS policies move with `pg_dump`/`pg_restore`. The CLI checks the versions: `pg_dump` must be 17. |
| Extensions | `uuid-ossp`, `pgcrypto`, `pg_trgm`, `vector`, `postgis` and the rest of our list move into `public`; references to `extensions.` are adjusted to it. `pg_graphql`, `pg_net`, `pgsodium`, `vault` and `pgjwt` do not: the report says what to use instead. |
| Grants | Grants are not copied: nothing is reachable through the Data API until you expose it yourself with `hosting db api expose`. RLS stays on. |
| Auth | An Infaris Auth project with the same users and **the same ids**, so `auth.uid()` in your policies and your foreign keys keep matching. The project is linked to the database. Infaris Auth signs in with a one-time code by email: passwords and social logins do not move (the hashes stay at Supabase); users sign in with a code to the same address. Exact redirect urls move, wildcards do not. |
| Storage | Every bucket with its rules: `auth.uid()` in the first folder becomes `owner`, signed-in becomes `authenticated`, otherwise servers only. A public bucket stays private unless you pass `--keep-public`. Files are copied with the service role key (from `SUPABASE_SERVICE_ROLE_KEY` or through the access token). |
| Edge Functions | From `supabase/functions/<name>` (with `_shared`) to our Functions (Deno), private and accepting tokens of the new auth project. Give another directory with `--functions-dir`. Secrets do not move: the report names them. |
| pg_cron | Jobs that call an Edge Function become an Infaris cron on that function. Jobs that run SQL cannot move (there is no pg_cron); the report says how to do it instead. |
| Realtime | Tables of the `supabase_realtime` publication are published, with private channels. A table without RLS is not. |

What cannot work on our side goes in the report: for example a foreign key to `auth.users` (users live in Infaris Auth, not in your database), a policy for a Supabase role or a trigger on `auth.users`.

## Vercel

```bash
export VERCEL_TOKEN=...   # vercel.com/account/tokens
cd my-project              # with vercel.json
infaris-guard hosting migrate vercel <project> --team <teamId> --plan
infaris-guard hosting migrate vercel <project> --team <teamId> --yes
```

| Part | What happens |
| --- | --- |
| Site | With `--site <id>` the CLI uses that site; otherwise it runs `hosting up` in this directory. Vercel's framework and build settings are in the report, so you can compare them. |
| Variables | Per environment to production and preview; encrypted ones stay secret. Development variables only go in the `.env` diff. Vercel never returns sensitive variables: set those yourself with `hosting env set`. |
| Domains | Every domain is added to the site and the report gives the DNS records. If you first have to prove a domain is yours, its TXT record is listed too. |
| Redirects and headers | From `vercel.json` to the site's rules (`:path*` becomes `*` and `:splat`). Regex patterns, `has`/`missing` and rewrites go in the report. |
| Cron | `crons` from `vercel.json` become Infaris crons on the same paths. |
| KV / Upstash | A managed Valkey store, linked to the site, with every key and its TTL. `@vercel/kv` and `@upstash/redis` keep working. |
| Blob | A bucket (private, unless `--keep-public`) with every file. |
| Postgres / Neon | The same database step as for Supabase, linked to the site as `DATABASE_URL`. |

## Options

| Flag | Meaning |
| --- | --- |
| `--plan` | Only show the plan; nothing changes. |
| `--yes` | Run without asking. |
| `--skip auth,storage` | Skip steps. |
| `--keep-public` | Keep public buckets and functions public (otherwise private). |
| `--name <name>` | Name of the new database (Supabase). |
| `--env-file <path>` | The `.env` file to compare the diff with (default `.env.local` or `.env`). |
| `--json` | One JSON document as output, for scripts and agents. |

`infaris-guard hosting migrate status` lists your moves with the progress per step.

Read the separate [Supabase](hosting-migrate-supabase) and [Vercel](hosting-migrate-vercel) guides, including cutover checks.
