Lokale PostgreSQL-Kopie: Auth/Storage-Stubs, Dumps und Sync-Skript
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
-- =============================================================
|
||||
-- Stubs für die LOKALE PostgreSQL-Kopie (ohne Supabase-Stack).
|
||||
-- Stellt die minimalen Supabase-Objekte bereit, die das public-
|
||||
-- Schema referenziert (auth.users, auth.uid(), Rollen, storage).
|
||||
-- Reihenfolge: 00_stubs.sql -> Schema-Dump -> Daten-Dump
|
||||
-- =============================================================
|
||||
|
||||
-- Rollen, die in den RLS-Policies referenziert werden
|
||||
do $$
|
||||
begin
|
||||
if not exists (select from pg_roles where rolname = 'anon') then
|
||||
create role anon nologin;
|
||||
end if;
|
||||
if not exists (select from pg_roles where rolname = 'authenticated') then
|
||||
create role authenticated nologin;
|
||||
end if;
|
||||
if not exists (select from pg_roles where rolname = 'service_role') then
|
||||
create role service_role nologin bypassrls;
|
||||
end if;
|
||||
end
|
||||
$$;
|
||||
|
||||
-- ---------- auth-Schema (Minimal-Stub) ----------
|
||||
create schema if not exists auth;
|
||||
|
||||
create table if not exists auth.users (
|
||||
id uuid primary key,
|
||||
email text,
|
||||
raw_user_meta_data jsonb not null default '{}'::jsonb,
|
||||
created_at timestamptz not null default now()
|
||||
);
|
||||
|
||||
-- Entspricht supabase auth.uid(); liefert lokal null,
|
||||
-- sofern kein JWT-Claim gesetzt ist.
|
||||
create or replace function auth.uid()
|
||||
returns uuid
|
||||
language sql
|
||||
stable
|
||||
as $$
|
||||
select nullif(current_setting('request.jwt.claim.sub', true), '')::uuid
|
||||
$$;
|
||||
|
||||
-- ---------- storage-Schema (Minimal-Stub) ----------
|
||||
create schema if not exists storage;
|
||||
|
||||
create table if not exists storage.buckets (
|
||||
id text primary key,
|
||||
name text not null,
|
||||
public boolean not null default false
|
||||
);
|
||||
|
||||
create table if not exists storage.objects (
|
||||
id uuid primary key default gen_random_uuid(),
|
||||
bucket_id text references storage.buckets (id),
|
||||
name text,
|
||||
owner uuid,
|
||||
created_at timestamptz not null default now()
|
||||
);
|
||||
Reference in New Issue
Block a user