47 lines
2.0 KiB
SQL
47 lines
2.0 KiB
SQL
-- =====================================================================
|
|
-- GameDev Tracker — Migration v11 « Documentation »
|
|
-- À coller dans : Supabase > SQL Editor > New query > Run
|
|
-- Idempotent : sans danger si déjà appliquée.
|
|
--
|
|
-- Ajoute les fiches de documentation : GDD, conventions de code, notes
|
|
-- de réunion, procédures… Créées dans l'app ou importées depuis un
|
|
-- fichier Markdown / Word.
|
|
-- =====================================================================
|
|
|
|
create table if not exists public.documents (
|
|
id uuid primary key default gen_random_uuid(),
|
|
project_id uuid not null references public.projects(id) on delete cascade,
|
|
title text not null,
|
|
-- Contenu en Markdown : c'est le format pivot. Un .docx importé est
|
|
-- converti en Markdown à l'import, ce qui garde les fiches lisibles,
|
|
-- cherchables et modifiables dans l'application.
|
|
content text not null default '',
|
|
tags text[] not null default '{}',
|
|
-- Fichier d'origine, quand la fiche vient d'un import (informatif).
|
|
source_name text,
|
|
created_by uuid references public.profiles(id) on delete set null,
|
|
updated_by uuid references public.profiles(id) on delete set null,
|
|
created_at timestamptz not null default now(),
|
|
updated_at timestamptz not null default now()
|
|
);
|
|
|
|
create index if not exists idx_documents_project on public.documents(project_id, updated_at desc);
|
|
|
|
drop trigger if exists trg_documents_touch on public.documents;
|
|
create trigger trg_documents_touch before update on public.documents
|
|
for each row execute function public.touch_updated_at();
|
|
|
|
alter table public.documents enable row level security;
|
|
|
|
drop policy if exists documents_all on public.documents;
|
|
|
|
-- Équipe de confiance : tout membre connecté lit et écrit la documentation.
|
|
create policy documents_all on public.documents
|
|
for all to authenticated using (true) with check (true);
|
|
|
|
do $$ begin
|
|
alter publication supabase_realtime add table public.documents;
|
|
exception when duplicate_object then null; end $$;
|
|
|
|
notify pgrst, 'reload schema';
|