Composes Scribase's own shipped APIs (the `scribase` SDK's imports/migrations/ database/environments resources, plus the GoTrue admin API every self-hosted Supabase migration tool already uses) rather than reinventing a dump format: - supabase: wraps the real POST /v1/imports one-call migration (Postgres, auth.users with hashes, storage). - neon: pg_dump schema+data as plain SQL, submitted through POST .../migrations (environments.connection() is internal-network-only — verified live — so this is the only path that actually reaches a Scribase env from outside); auto-generates owner-based RLS so the real migration lint's BLOCK on RLS-less public tables is satisfied without ever opening a table to every user; branches land in branch_<name> schemas. - clerk: exports users via the real Backend API, creates them via the destination's GoTrue admin API with a one-time password + reset flag (Clerk never exposes a portable hash on any plan). - resend: exports sending domains + broadcasts (as templates) to a portable JSON bundle; honest about Scribase having no write endpoint for either yet. Verified live end-to-end against a real local Supabase-shaped Postgres (Docker, GoTrue-shaped auth.users with a real bcrypt hash) and a real Scribase project (ereboslab/scribase-migrate-verify-internal): schema+RLS applied with 0 lint blocks, data row counts matched via a real HTTP query (2/2 profiles, 3/3 notes), and a real password-grant login returned a real access_token for the migrated user. Full artifacts in test-fixtures/verification-run/. docs/migrate-page.md is a ready-to-paste scribase.com/migrate page.
100 lines
2.4 KiB
SQL
100 lines
2.4 KiB
SQL
--
|
|
-- PostgreSQL database dump
|
|
--
|
|
|
|
-- Dumped from database version 16.16
|
|
-- Dumped by pg_dump version 16.16 (Homebrew)
|
|
|
|
--
|
|
-- Name: public; Type: SCHEMA; Schema: -; Owner: -
|
|
--
|
|
|
|
--
|
|
-- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: -
|
|
--
|
|
|
|
--
|
|
-- Name: notes; Type: TABLE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TABLE public.notes (
|
|
id integer NOT NULL,
|
|
profile_id uuid,
|
|
body text NOT NULL
|
|
);
|
|
|
|
--
|
|
-- Name: notes_id_seq; Type: SEQUENCE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE SEQUENCE public.notes_id_seq
|
|
AS integer
|
|
START WITH 1
|
|
INCREMENT BY 1
|
|
NO MINVALUE
|
|
NO MAXVALUE
|
|
CACHE 1;
|
|
|
|
--
|
|
-- Name: notes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER SEQUENCE public.notes_id_seq OWNED BY public.notes.id;
|
|
|
|
--
|
|
-- Name: profiles; Type: TABLE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TABLE public.profiles (
|
|
id uuid NOT NULL,
|
|
display_name text NOT NULL,
|
|
plan text DEFAULT 'free'::text,
|
|
created_at timestamp with time zone DEFAULT now()
|
|
);
|
|
|
|
--
|
|
-- Name: notes id; Type: DEFAULT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.notes ALTER COLUMN id SET DEFAULT nextval('public.notes_id_seq'::regclass);
|
|
|
|
--
|
|
-- Name: notes notes_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.notes
|
|
ADD CONSTRAINT notes_pkey PRIMARY KEY (id);
|
|
|
|
--
|
|
-- Name: profiles profiles_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.profiles
|
|
ADD CONSTRAINT profiles_pkey PRIMARY KEY (id);
|
|
|
|
--
|
|
-- Name: notes notes_profile_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.notes
|
|
ADD CONSTRAINT notes_profile_id_fkey FOREIGN KEY (profile_id) REFERENCES public.profiles(id);
|
|
|
|
--
|
|
-- Name: profiles profiles_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.profiles
|
|
ADD CONSTRAINT profiles_id_fkey FOREIGN KEY (id) REFERENCES auth.users(id);
|
|
|
|
--
|
|
-- PostgreSQL database dump complete
|
|
--
|
|
|
|
alter table public.notes enable row level security;
|
|
create policy "notes_owner_via_profiles" on public.notes for all using (
|
|
exists (select 1 from public.profiles t where t.id = public.notes.profile_id and t.id = auth.uid())
|
|
) with check (
|
|
exists (select 1 from public.profiles t where t.id = public.notes.profile_id and t.id = auth.uid())
|
|
);
|
|
alter table public.profiles enable row level security;
|
|
create policy "profiles_owner" on public.profiles for all using (id = auth.uid()) with check (id = auth.uid()); |