-- Enable public collections in Directus by adding them to directus_collections

INSERT INTO directus_collections (collection, icon, note, display_template, hidden, singleton, translations, archive_field, archive_app_filter, archive_value, unarchive_value, sort_field, accountability)
VALUES 
    ('profiles', 'account_circle', 'User Profiles', '{{handle}}', false, false, NULL, NULL, true, NULL, NULL, 'created_at', 'all'),
    ('posts', 'post_add', 'User Posts', '{{body}}', false, false, NULL, 'status', true, 'archived', 'active', 'created_at', 'all'),
    ('categories', 'category', 'Content Categories', '{{name}}', false, false, NULL, NULL, true, NULL, NULL, 'name', 'all'),
    ('comments', 'comment', 'Post Comments', '{{body}}', false, false, NULL, 'status', true, 'archived', 'active', 'created_at', 'all'),
    ('trust_state', 'verified', 'User Trust Scores', '{{harmony_score}}', false, false, NULL, NULL, true, NULL, NULL, NULL, 'all'),
    ('post_metrics', 'analytics', 'Post Analytics', '{{like_count}} likes', false, false, NULL, NULL, true, NULL, NULL, NULL, 'all'),
    ('users', 'lock', 'Auth Users', '{{email}}', false, false, NULL, NULL, true, NULL, NULL, 'created_at', 'all')
ON CONFLICT (collection) DO UPDATE 
SET icon = EXCLUDED.icon, note = EXCLUDED.note, display_template = EXCLUDED.display_template;

-- Optional: Configure Display Fields (This is usually roughly done by Directus introspection but explicit fields help)
-- We won't inject into directus_fields blindly as that is complex, but the collections are the main step.
