openreader/drizzle/sqlite/0004_admin_panel.sql
Richard R 876ca7d774 feat(admin,config,ui,db): introduce runtime-editable site config and admin-managed TTS providers
Add database-backed runtime configuration for feature flags and TTS provider credentials, editable via a new admin UI panel. Replace static NEXT_PUBLIC_* and TTS provider env vars with admin-managed settings stored in the database and injected at SSR for client access. Implement admin-only panels for managing shared TTS provider credentials (with encrypted API keys) and live site feature flags. Add schema migrations, API routes, React contexts, and hooks for SSR-injected runtime config and live updates. Update client and server logic to resolve configuration from the database at runtime, enforcing admin restrictions and supporting migration from legacy env-based config.

BREAKING CHANGE: Feature flags and TTS provider credentials are now managed at runtime via the admin UI. Environment variables are only used for initial seeding and are ignored after first boot. Existing deployments must migrate configuration to the admin panel.
2026-05-12 22:39:24 -06:00

25 lines
No EOL
978 B
SQL

CREATE TABLE `admin_providers` (
`id` text PRIMARY KEY NOT NULL,
`slug` text NOT NULL,
`display_name` text NOT NULL,
`provider_type` text NOT NULL,
`base_url` text,
`api_key_ciphertext` text NOT NULL,
`api_key_iv` text NOT NULL,
`api_key_last4` text,
`default_model` text,
`default_instructions` text,
`enabled` integer DEFAULT 1 NOT NULL,
`created_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)) NOT NULL,
`updated_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)) NOT NULL
);
--> statement-breakpoint
CREATE UNIQUE INDEX `admin_providers_slug_unique` ON `admin_providers` (`slug`);--> statement-breakpoint
CREATE TABLE `admin_settings` (
`key` text PRIMARY KEY NOT NULL,
`value_json` text NOT NULL,
`source` text DEFAULT 'admin' NOT NULL,
`updated_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)) NOT NULL
);
--> statement-breakpoint
ALTER TABLE `user` ADD `is_admin` integer DEFAULT false NOT NULL;