insert into app_private.environment_safety (id, environment, allow_destructive_tests)
values (true, 'local', true)
on conflict (id)
do update set environment = excluded.environment,
              allow_destructive_tests = excluded.allow_destructive_tests,
              updated_at = now();

insert into public.tenants (id, slug, name, status, mode)
values (
  '00000000-0000-0000-0000-000000000001',
  'master',
  '升本刷题通主租户',
  'active',
  'platform_owned'
)
on conflict (id) do nothing;

insert into public.tenant_domains (tenant_id, host, domain_type, status, is_primary)
values (
  '00000000-0000-0000-0000-000000000001',
  'localhost',
  'system',
  'active',
  true
)
on conflict (host) do nothing;

insert into public.tenant_branding (tenant_id, brand_name, short_name, slogan)
values (
  '00000000-0000-0000-0000-000000000001',
  '升本刷题通',
  '刷题通',
  '多租户专升本题库 SaaS'
)
on conflict (tenant_id) do nothing;

insert into public.tenant_settings (tenant_id, feature_flags, admin_feature_flags, public_config)
values (
  '00000000-0000-0000-0000-000000000001',
  '{"enableStore":true,"enableLeaderboard":false,"enableVocabulary":true,"enableHandbook":true,"enableScoreline":true}'::jsonb,
  '{"enableTenantManagement":true,"enableQuestionCRUD":true,"enableRevenueLedger":true,"enableMarketing":true}'::jsonb,
  '{"examDate":"","appUrl":"http://127.0.0.1:5173"}'::jsonb
)
on conflict (tenant_id) do nothing;

insert into public.tenant_auth_providers (tenant_id, provider, status, display_name, config_public)
values (
  '00000000-0000-0000-0000-000000000001',
  'mock',
  'testing',
  '本地模拟短信',
  '{"channel":"local-dev"}'::jsonb
)
on conflict (tenant_id, provider) do nothing;
