Moving in and out
Import SQL or CSV
Make a new project from a PostgreSQL dump, a SQL file you wrote, another PostgreSQL database, or a CSV file. Start at Move in in your company's sidebar. The general steps and safety rules are on Move a project in.
A dump or a SQL file
Upload the output of pg_dump in plain format, or any SQL file that makes tables and fills them:
pg_dump "$SOURCE_DATABASE" --no-owner --no-privileges --schema=public -f dump.sql
Or give the database's connection string and Rezin Core reads it for you, in a read-only session over an encrypted connection.
Say which schemas hold your tables (public unless you say otherwise). Everything in them is moved into the new project's own schema; names written public.orders are rewritten.
What is let through
| Statement | |
|---|---|
CREATE TABLE, ALTER TABLE | Tables, columns, constraints, defaults, identity columns, row-level security switches |
CREATE INDEX, CREATE SEQUENCE, ALTER SEQUENCE, SELECT setval(...) | |
CREATE TYPE, CREATE DOMAIN, CREATE VIEW | |
CREATE FUNCTION, CREATE PROCEDURE | In SQL or PL/pgSQL, and not security definer |
CREATE TRIGGER | |
COPY ... FROM stdin, INSERT INTO | Rows written in the file itself |
COMMENT ON | |
CREATE POLICY | Read, and held for you to put in force |
What is skipped, and what is refused
Skipped quietly, with a count: SET lines, GRANT and REVOKE, ownership changes, CREATE SCHEMA, CREATE EXTENSION (named for you), and anything in a schema you did not list.
Refused, and listed with the statement: CREATE ROLE and anything about roles, ALTER SYSTEM, COPY to or from a file or a program, foreign servers and tables, event triggers, DO blocks, DROP, UPDATE, DELETE, TRUNCATE, CALL, security definer functions, functions in other languages, and any statement that names a server file function or reaches for Rezin Core's own tables.
A statement that was let through but fails in the database (a type that does not exist, a value that does not fit) is reported with the database's own message. The rest of the import carries on.
Access rules
CREATE POLICY statements are read and shown, with roles that do not exist here replaced by your application's role. They are not put in force by the import: every table starts closed, and you put each rule in force after reading it.
A CSV file
One file becomes one table. The first row is the column names.
The dry run proposes a name and a type for each column from the values it sees (text, whole number, number, true/false, date, timestamp, UUID). You can rename columns, change types, and leave columns out before anything is written. The table gets an id column of its own.
An empty cell becomes null. A file can be up to 96 MB; for more, load it as SQL.
rezin import csv --company <company id> --name "Members" --csv members.csv --table members
Afterwards
The new project is an ordinary project. Its tables are closed until you write access rules: see Securing tables.