-- Migration 095: Scheduled Messages permissions

INSERT INTO feature_groups (id, label, sort_order)
VALUES ('scheduled_messages', 'Geplante Nachrichten', 12)
ON CONFLICT (id) DO NOTHING;

INSERT INTO permissions (id, feature_group_id, label, description, sort_order) VALUES
  ('scheduled_messages:view',      'scheduled_messages', 'Ansehen',    'Geplante Nachrichten ansehen', 1),
  ('scheduled_messages:edit',      'scheduled_messages', 'Verwalten',  'Automationen verwalten',       2),
  ('scheduled_messages:subscribe', 'scheduled_messages', 'Abonnieren', 'Nachrichten abonnieren',       3)
ON CONFLICT (id) DO NOTHING;

-- Only dashboard_admin gets defaults; other groups assigned manually on live system
INSERT INTO group_permissions (authentik_group, permission_id) VALUES
  ('dashboard_admin', 'scheduled_messages:view'),
  ('dashboard_admin', 'scheduled_messages:edit'),
  ('dashboard_admin', 'scheduled_messages:subscribe')
ON CONFLICT DO NOTHING;
