# Migrate from Supabase: schema, data, auth users and storage

> Step-by-step: move a Supabase project to Scribase with one importer run, keep every password, copy storage, verify row counts, swap the supabase-js URL and key.

Source: https://scribase.com/migrate/supabase

One importer run copies the schema, grants, auth users with their bcrypt hashes, data, RLS policies and storage objects, then proves the copy with row counts and checksums. Your app changes two environment variables.

## Before you start

- From your Supabase dashboard: the project ref, the database connection string (Connect panel, session mode), and the service_role key if you want storage files copied.
- A paused free project refuses connections. Restore it in the Supabase dashboard first.
- A Scribase account with one project. The console creates the production environment for you.
- Optional: an API key (Account, API keys) if you prefer to script the import with the SDK instead of using the console wizard.

## Option 1: the console (no terminal)

Open the Move page in the console and paste the connection string. The move starts on paste and shows tables, rows, users and policies as they land. Tick "Also copy storage files" and add the service_role key to bring buckets and objects too. The source project is only read.

## Option 2: script it with the SDK

1. **Dry run** — Reads the source only. Returns what will move (tables, rows, users, objects, bytes) and anything a human should look at first, such as a policy that admits every row.

```ts
await scribase.imports.dryRun({
  sourceProjectRef: '<ref>',
  sourceConnectionString: process.env.SOURCE_DB_URL!,
  sourceServiceKey: process.env.SOURCE_SERVICE_KEY!,
  destination: { organizationId: 'acme', projectId: 'app', environmentId: 'production' },
});
```

2. **Run the import** — Extensions, schema, grants, auth users (same ids, bcrypt hashes, identities, TOTP factors), data in resumable pages, foreign keys and triggers, RLS policies, then storage. Each step is replay-safe: a failed run resumes from its last checkpoint. Edge functions have their own step in the console wizard (upload the supabase/functions folder, or a zip of it) — the SDK call above does not move them.

```ts
await scribase.imports.create({
  sourceProjectRef: '<ref>',
  sourceConnectionString: process.env.SOURCE_DB_URL!,
  sourceServiceKey: process.env.SOURCE_SERVICE_KEY!,
  destination: { organizationId: 'acme', projectId: 'app', environmentId: 'production' },
});
```

3. **Read the verification report** — Per table: source rows, Scribase rows and a checksum of every row on both sides. Also policy parity, auth user and identity counts, object counts and an optional sign-in with an account you control. The verdict is VERIFIED only when everything matches.

4. **Swap the URL and key in your app** — Copy the project URL and anon key from the console (Project settings, API) into your app. Existing sessions sign in once more; passwords do not change.

```ts
const client = createClient(process.env.SCRIBASE_URL!, process.env.SCRIBASE_ANON_KEY!);
```

## Option 3: plain pg_dump, as migrations

If you only need the public schema and its data (no auth users, no storage), you can dump it yourself and apply it as migrations. The migration endpoint lints first, so run without --apply to read the plan.

The linter blocks five patterns that leak data: a public table without RLS and at least one policy, a policy whose predicate is literally true, a write policy without WITH CHECK, a grant to PUBLIC, and a SECURITY DEFINER function. Fix those in the dump (or use the importer above) before you apply.

```sh
mkdir -p supabase/migrations
pg_dump "$SCRIBASE_SOURCE_CONNECTION_STRING" --schema=public --schema-only \
  --no-owner --no-privileges > supabase/migrations/0001_schema.sql
pg_dump "$SCRIBASE_SOURCE_CONNECTION_STRING" --schema=public --data-only \
  --inserts --rows-per-insert=500 > supabase/migrations/0002_data.sql

npx scribase migrate --dry-run   # lint and plan, in this folder
npx scribase migrate             # run
```

## What you redo by hand

- Signing keys are never copied: Scribase issues new anon and service_role keys so the old and new projects never trust each other.
- Edge function source is not readable from a hosted project. Upload your supabase/functions folder (or a zip of it) in the console wizard's own functions step, which deploys every function it finds.
- User-defined secrets are listed by name; set their values again.
- OAuth provider settings: add the new callback URL in Google, GitHub or Apple, then paste the client id and secret in the console.

## FAQ

**Do users have to reset their passwords?**

No. auth.users moves with the same ids and the bcrypt encrypted_password hashes byte for byte, along with identities and TOTP factors.

**How long does a migration take?**

It depends on rows and storage bytes. The dry run prints both before anything is copied, and the import can be resumed, so a dropped connection costs one page rather than the whole run.

**Can I run it twice?**

Yes. Writes are upserts keyed on the original ids, so a second run converges instead of duplicating rows.

**Does my Supabase project change?**

No. The importer only reads from the source. Keep it running until you have switched your app and checked the report.

## Related

- [Supabase alternative](https://scribase.com/supabase-alternative)
- [Move to another Supabase project](https://scribase.com/supabase-migrate-to-another-project)
- [Migrate from Neon](https://scribase.com/migrate/neon)
- [Scribase vs Supabase vs Neon](https://scribase.com/scribase-vs-supabase-vs-neon)
- [Postgres extensions available](https://scribase.com/extensions)
- [All migrations](https://scribase.com/migrate)
- [Pricing](https://scribase.com/pricing)