SQL zum Ausführen:
create table public.entries (
id uuid primary key default gen_random_uuid(),
user_id uuid not null references auth.users(id) on delete cascade,
type text not null check (type in ('inbox','todo','idea','note')),
title text default '',
content text default '',
tags text[] default '{}',
due_date date,
priority smallint default 2,
done boolean default false,
archived boolean default false,
note_date date,
created_at timestamptz default now(),
updated_at timestamptz default now()
);
alter table public.entries enable row level security;
create policy "own_entries" on public.entries
for all to authenticated
using (auth.uid() = user_id)
with check (auth.uid() = user_id);
create index entries_user_idx
on public.entries(user_id, type, archived);
create or replace function set_updated_at()
returns trigger as $$
begin new.updated_at = now(); return new; end;
$$ language plpgsql;
create trigger entries_updated_at
before update on public.entries
for each row execute procedure set_updated_at();