Sources, publishers, hidden/merged columns, manual_fields triggers, catalog_games view and column grants on games (KAT-05, PR 2a). Fixtures for the tests are generated from supabase/catalog/testdata. Refs #2 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
40 lines
1.8 KiB
PL/PgSQL
40 lines
1.8 KiB
PL/PgSQL
-- Struktur-Regeln für alle Tabellen im Schema public.
|
|
begin;
|
|
select plan(5);
|
|
|
|
select is((select count(*) from pg_tables where schemaname = 'public'), 20::bigint,
|
|
'R1 hat genau 20 Tabellen (17 + catalog_sources, publishers, game_publishers)');
|
|
|
|
select is_empty($$
|
|
select c.relname from pg_class c join pg_namespace n on n.oid = c.relnamespace
|
|
where n.nspname = 'public' and c.relkind = 'r' and not c.relrowsecurity$$,
|
|
'Jede Tabelle hat Row Level Security');
|
|
|
|
select is_empty($$
|
|
select t.table_name from information_schema.tables t
|
|
where t.table_schema = 'public' and t.table_type = 'BASE TABLE'
|
|
and (select count(*) from information_schema.columns c
|
|
where c.table_schema = 'public' and c.table_name = t.table_name
|
|
and ((c.column_name = 'id' and c.data_type = 'uuid')
|
|
or (c.column_name in ('created_at', 'updated_at')
|
|
and c.data_type = 'timestamp with time zone'
|
|
and c.is_nullable = 'NO'))) <> 3$$,
|
|
'Jede Tabelle hat id (uuid), created_at und updated_at');
|
|
|
|
select is_empty($$
|
|
select t.table_name from information_schema.tables t
|
|
where t.table_schema = 'public' and t.table_type = 'BASE TABLE'
|
|
and not exists (select 1 from information_schema.table_constraints k
|
|
where k.table_schema = 'public' and k.table_name = t.table_name
|
|
and k.constraint_type = 'PRIMARY KEY')$$,
|
|
'Jede Tabelle hat einen Primärschlüssel');
|
|
|
|
select is_empty($$
|
|
select c.relname from pg_class c join pg_namespace n on n.oid = c.relnamespace
|
|
where n.nspname = 'public' and c.relkind = 'r'
|
|
and not exists (select 1 from pg_trigger g
|
|
where g.tgrelid = c.oid and g.tgname = 'set_updated_at')$$,
|
|
'Jede Tabelle setzt updated_at per Trigger');
|
|
|
|
select * from finish();
|
|
rollback;
|