# Move a project in

Bring a project over from another platform into a new Rezin Core project. You see exactly what will happen before anything is written, the project you are moving from is only ever read, and what you bring is not visible to Rezin Core staff.

In the console: **Move in**, in your company's sidebar. Only an owner of the company can do this, because it makes a new project.

| From | What comes over | Guide |
|---|---|---|
| Supabase | Tables, data, indexes, views, database functions, triggers, access rules (translated), accounts with their passwords, files | [Move in from Supabase](https://rezincore.com/docs/moving/from-supabase.md) |
| Firebase | Accounts, Firestore documents as tables you review first, files | [Move in from Firebase](https://rezincore.com/docs/moving/from-firebase.md) |
| Any PostgreSQL, or a SQL file | Tables and what belongs to them, data | [Import SQL or CSV](https://rezincore.com/docs/moving/sql-and-csv.md) |
| A CSV file | One table | [Import SQL or CSV](https://rezincore.com/docs/moving/sql-and-csv.md#a-csv-file) |
| A Rezin Core export | Everything in it, as it was | [Export your project](https://rezincore.com/docs/moving/export.md#put-an-export-back) |

## The steps

1. **Start.** Choose where the project comes from and name the new project.
2. **Say what to bring.** Upload a file, or for a database give its connection string.
3. **Check.** A dry run reads what you supplied and writes nothing. It shows the tables and rows, the accounts, the files, every access rule beside its translation, everything that will be left out and why, and every statement that was refused and why.
4. **Go ahead.** Type the new project's name. The project is made and filled in the background; its two keys are shown once.
5. **Review the access rules.** Every imported table starts closed. Read each translated rule and put it in force.
6. **Switch over.** A checklist of what is left to do in your application, and a way to bring the data over once more just before you switch.

## How an import is kept safe

- **A new project, always.** An import never goes into a project that already exists.
- **Nothing is written before the dry run.** The import cannot be started until you have been shown what it will do.
- **Statements are read one at a time.** A dump is never handed to the database whole. Each statement is named for what it is, and only the kinds that make tables and fill them are let through. Creating roles, changing server settings, reading or writing files, running programs, foreign data, `DO` blocks, `security definer` functions, functions in languages other than SQL and PL/pgSQL, and anything aimed outside your own tables are refused, and listed for you.
- **They run as the new project's own confined database role.** That role can reach the new project's section of the database and nothing else, so even a statement that was let through cannot touch another project. A statement the database itself refuses is reported with its reason.
- **Tables start closed.** Row-level security is on for every imported table, with no rule and nothing granted to your application, until you put rules in force.
- **The source is only read.** A database you connect is read in a read-only session, over an encrypted connection, at a public address. Private and local addresses are refused.
- **What you type is not kept.** Connection strings, service keys, passphrases and hash parameters are held in memory for the import and never written to the database, the record or a log. If the server restarts mid-import you are asked for them again.
- **It can be run again.** An import that is interrupted carries on from where it stopped and does nothing twice.
- **Uploads are removed.** Closing the import removes what you uploaded.

## What is left out

An import brings your application's own tables, accounts and files. It leaves out the other platform's own machinery: its internal schemas, its roles and their grants, its extensions and its settings. The dry run lists what was left out by kind with a count, so nothing disappears silently.

## Limits

How much can be brought in depends on the company's plan: 200 MB of uploaded or read data on Free, 2 GB on paid plans. One stored file can be up to 25 MB. An email address can belong to one account on Rezin Core, so an account whose address is already in use here is skipped and listed.

## After the import: switching over

The finished import shows a checklist built from what it found:

- **Put your access rules in force.** Until a table has a rule in force it is closed to your application.
- **Point your application at the new project.** Swap the API address and the two keys. [From their client calls to ours](https://rezincore.com/docs/moving/client-calls.md) maps the common calls.
- **Set your site's address** and the addresses sign-in may send people back to.
- **Re-enter sign-in providers.** Enter each provider's client ID and secret for this project and add its return address at the provider. People who signed in with Google or GitHub are recognised by the same provider account.
- **Recreate webhooks** and **switch live updates back on** for the tables that had them.
- **Bring the data over again.** Just before you switch, replace the imported tables' rows with what the source has now, so nothing written in between is left behind. Rows written to those tables in the new project since the import are replaced; do this before your application starts writing here.

Then switch, and stop writing to the old project.

## From the command line

```
rezin import supabase --company <company id> --name "Orchard" --dump dump.sql
rezin import supabase --company <company id> --name "Orchard" --connection
rezin import sql      --company <company id> --name "Orchard" --dump schema.sql --schemas public
rezin import csv      --company <company id> --name "Members" --csv members.csv --table members
rezin import firebase --company <company id> --name "Shops" --users users.json --hash-parameters params.json --firestore data.json
rezin import rezin    --company <company id> --name "Restored" --archive export.tar.gz.enc --passphrase-file pass.txt
```

Each prints the dry run and stops. Add `--yes` to go ahead. Then:

```
rezin import status <import id> --company <company id>
rezin import apply-rules <import id> --company <company id>
```

This needs a read-write token for the whole company that was given **Your account and companies**, **Database** and **Files**, held by an owner.
