mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-09-30 06:16:37 +08:00
dbaa3bf140
docs(changelog): 修正表述笔误
refactor(cordis): 磁盘缓存改用上上游能力并清理本地副本
按上游/下游归属规约:类型断言守卫已回流 Wavelet(f3d85d5,附回归用例),
本仓库删除 OpenFlare/plugins/server/pkg/cache 整包并改 import 到
Wavelet/pkg/cache/disk,同步后与上游零漂移。
验证:go build 通过;go test ./... exit 0(137 包 ok);256 条路由对拍与
232 条 swagger 操作均零差异;make build-all 四进制;前端零改动。
docs(cordis): 记录 T1 清理结果与五个复用阻塞点
refactor(cordis): server 复用上游 pkg 能力并删除等价本地副本
按上游/下游归属规约清理重复实现,删除 7 个与上游等价的本地包并改 import:
shared/response→pkg/response、pkg/{logger,mail,trace,httppool,cache/ram}→
上游同名包、infra/persistence/batchwriter→pkg/batchwriter。逐项核过差异:
httppool 逐字节相同;logger 的 Config 字段完全一致;response 的 7 个 Abort*
一致;cache/ram 换过去顺带把裸 go 变回带 panic 恢复的 util.Go。
两处非等价差异按语义处理:
- batchwriter.Stats 与 status DTO 原为类型别名,改为消费侧逐字段转换,
避免 model 反向依赖基础设施类型;
- 上游 pkg/idgen 要求显式 Init(本地副本为懒加载自动初始化),本次保留本地
副本,待与 infra 初始化一并迁移(已登记在清理计划)。
验证:go build 通过;go test ./... exit 0(138 包 ok);256 条路由对拍零差异;
make swagger 232 条操作零增减,且归一化后与旧文档深度相等——差异仅为
response.Any / logger.LogEntry 两个定义名随包路径改名,接口形状未变。
chore(cordis): 回流内核与 pkg/util 通用能力并清理 vendoring 污染
按新增的上游/下游归属规约:HandleRaw/BasePath 与版本比较、网络、格式化助手
属通用能力,已提交到 Wavelet 分支 feat/cordis-router-raw-routes,本仓库改为
纯同步获取(pkg/util 已零漂移),补丁登记保留至上游合并。
同时修掉我此前 git add -A 造成的污染:首次 vendoring 把上游工作区里被
gitignore 的运行期产物一起提交进来(upload 的 diskcache 缓存块 650 个与
driver_http/dist 前端构建物 380 个,共 12872 行/1030 文件)。sync-upstream.sh
现显式排除 uploads/dist/data/*.db,.gitignore 补上对应兜底规则。
AGENTS.md 增加上游/下游改动归属规约,并把仍指向前 Cordis 布局的硬性约束
(internal/router + Serve、internal/repository/logstore、internal/platform/bootstrap、
internal/cmd)改到当前插件路径。
验证:go build 通过;go test ./... exit 0(144 包 ok);make swagger 232 条
操作与基线逐条一致;make build-all 四进制;gofmt 干净。
feat(cordis): server 插件化并改由内核挂载控制面路由
新增 plugins/server/plugin.go:Apply 以 ctx.Router().Group(app.api_prefix)
声明根级与 /v1 全部路由;33 个注册函数由 *gin.RouterGroup 改为
core.RouterExtension,RegisterCollection 改用内核新增的 HandleRaw 保留
尾部斜杠变体,AdminMiddlewares 返回 []any(Go 不允许把 []T 展开为 ...any)。
删除 router.Serve 与 registerRoutes,装配根改为 core.App +
driver_http.New(WithEngine(router.BuildEngine())),监听、信号与优雅退出归内核;
前端 SPA 的 NoRoute 兜底因内核暂无贡献点而保留在引擎层。
路由保真证据:plugin_parity_test 对拍 baseline/routes-engine.txt 的 256 条
(方法 路径) 零差异;go test ./... exit 0(144 包 ok,含真实 handler 的
openflare/integration 用例走同一条挂载路径);make swagger 232 条操作与基线
逐条一致;golangci-lint 0 issues;make build-all 四进制;embed_frontend
标签编译通过;前端零改动。
已知待补:带 Redis 的实机 HTTP 冒烟(本机 6379 未启动,session store 与
改造前一样在建店阶段即 fatal),以及 bootstrap 的任务/设置/迁移注册迁入 Apply。
feat(core): RouterExtension 增加 HandleRaw 与 BasePath 以保真尾部斜杠路由
server 插件化的前置:Handle 经 cleanPath 会剥掉尾部斜杠,无法表达
/resource 与 /resource/ 两条不同路由,而 OpenFlare 有 20 个历史 list
端点两者都注册且部署关闭了 RedirectTrailingSlash,缺失即 404。新增
HandleRaw 与 BasePath(作用域包装器同样登记反注册),补 extpoints 用例;
并把 router.Serve 拆出 BuildEngine 以便交给 driver_http.WithEngine 复用,
新增路由表导出 harness,固化 256 条 (方法 路径) 基线供插件化对拍。
上游补丁登记于 backend/OpenFlare/upstream-patches.md,同步脚本改为按目录
前缀输出差异并在同步后提醒确认补丁是否仍在。
验证:go build 通过;go test ./... exit 0(143 包 ok);gofmt 干净。
docs(cordis): 记录 server 插件接入内核的可行路径与内核能力缺口
feat(cordis): agent/relay/flared 落地为内核驱动插件
三个边缘守护进程各新增 plugin.go,实现 core.Plugin + core.Driver
(自定义 DriverType 与同名 profile),装配与生命周期从 main 迁入
Apply/Start/Stop:Apply 负责 JSON 配置加载、运行环境与用户确保、
openresty/frps/frpc 管理器与各服务装配;Start 以 util.Go 拉起阻塞式
runner 与 GeoIP 周期更新;Stop 收敛主循环结果并在超时时报错而非静默。
入口改为 core.NewApp(core.WithProfile(...)) + Prepare/Run,保持
-config 旗标、默认路径、退出码与启动/停止日志不变。
验证:go build 通过;go test ./... exit 0(143 包 ok,含 3 个插件身份
与配置失败路径测试);make build-all 四进制产出;三进制实跑缺失配置
均 exit 1 且错误链保留 load {agent,relay,flared} config 原因;gofmt 干净。
refactor(cordis): 按功能职责拆分为 4 个插件与 share 共享层
backend/OpenFlare 不再平铺遗留分层,改为 plugins/{server,agent,relay,flared}
加 share/:控制面业务(openflare/admin/oauth/user/upload/cap/config/health 与
repository/model/infra/router 等支撑层)归 server;三个边缘守护进程各自成插件;
被两个以上插件消费的 protocol/geoip/wsclient/render/pagesarchive/edge 归 share。
同时把 pkg/util 与 buildinfo 合并回上游 pkg(上游已覆盖全部符号,仅 8 个函数与
2 个类型为 OpenFlare 独有,已一并迁入),装配根统一到 backend/cmd(含三个 daemon
入口),Dockerfile 与 release 工作流的构建路径和 -X 注入路径同步更新。
验证:go build 通过;go test ./... exit 0(141 包 ok);make swagger exit 0 且
232 条 API 操作与基线逐条一致;make build-all 产出 4 进制;-X 注入经二进制
strings 实测生效;日志后端直连门禁改写为按 server 插件业务域扫描并在扫描数为 0
时报错(防门禁静默失效);前端零改动。
feat(cordis): 落地 backend/share 共享层与上游同步脚本
跨插件共享资源(控制消息协议、GeoIP+iputil、边缘守护进程日志)从下游包
移入 backend/share,并声明其只能依赖 core/pkg 与标准/第三方库,禁止反向
引用下游业务与具体插件实现;新增 scripts/sync-upstream.sh 只覆盖
backend/{core,pkg,plugins},同步后 --check 报告零差异,证明与上游逐字一致。
go build 通过,go test ./... exit 0(142 包 ok),前端零改动。
refactor(cordis): 采用与 Wavelet 同构的单模块布局并引入上游内核
按上游结构落位:backend/{core,pkg,plugins} 为 Wavelet 上游拷贝,OpenFlare
全部业务收拢到上游 downstream 所对应的位置 backend/OpenFlare/,模块名保持
Wavelet 以保证上游 import 路径逐字一致、同步零改写;三个 daemon 入口移至
backend/OpenFlare/cmd,backend/cmd 与 main.go 作为控制面装配根。
行为不变:go build 通过,142 个测试包全绿(含上游插件测试),232 条 API
操作与改造前逐条一致,四进制产物正常,前端零改动。swagger 暂只扫描下游代码,
待 P4 挂载上游路由后再纳入 plugins/。
style: 修正模块路径改写导致的 import 分组排序漂移
refactor(layout): Go 代码迁入 backend/ 并将模块名简化为 OpenFlare
对齐上游 Wavelet 的仓库布局,为以第二 module 形态 vendoring Cordis 内核与
平台插件做准备:模块路径整体改写为 OpenFlare,Go 目标加 cd backend,
swaggo 产物移至 backend/docs 并把 json/yaml 复制回 docs/ 供站点消费,
Dockerfile 与 release 工作流的构建目录、ldflags 模块路径同步更新。
行为保持不变:232 条路由与改造前逐条一致,95 个测试包全绿,
四进制产物正常,前端零改动。
chore(cordis): 落地改造计划与 schema/路由基线
新增 legacy_dump_test 迁移快照 harness:在临时 sqlite 库上按生产顺序
(goose.UpTo → zone 导入 → goose.Up)跑完 76 个历史迁移并导出 schema 与
版本序列,作为改造前后一致性门禁的唯一事实来源。同时记录 232 条路由清单
与 foundation 实施计划。
docs(cordis): add OpenFlare Cordis 架构改造设计
明确上游以第二 module 形态 vendoring 进 backend/Wavelet、4 个插件
(server/agent/relay/flared) 全部装载内核,并规定保留 76 个历史 goose
迁移 + 一次性版本 stamp 桥接的迁移方案,配套三方 schema 一致性门禁,
确保已部署库不重跑历史、不丢数据。
786 lines
33 KiB
SQL
786 lines
33 KiB
SQL
-- index idx_of_apply_logs_created_at
|
|
CREATE INDEX idx_of_apply_logs_created_at ON of_apply_logs(created_at);
|
|
-- index idx_of_apply_logs_node_id
|
|
CREATE INDEX idx_of_apply_logs_node_id ON of_apply_logs(node_id);
|
|
-- index idx_of_cf_connections_dns_account_id
|
|
CREATE INDEX idx_of_cf_connections_dns_account_id ON of_cf_connections (dns_account_id);
|
|
-- index idx_of_cf_pointing_groups_active_node_id
|
|
CREATE INDEX idx_of_cf_pointing_groups_active_node_id ON of_cf_pointing_groups (active_node_id);
|
|
-- index idx_of_cf_pointing_groups_backup_node_id
|
|
CREATE INDEX idx_of_cf_pointing_groups_backup_node_id ON of_cf_pointing_groups (backup_node_id);
|
|
-- index idx_of_cf_pointing_groups_primary_node_id
|
|
CREATE INDEX idx_of_cf_pointing_groups_primary_node_id ON of_cf_pointing_groups (primary_node_id);
|
|
-- index idx_of_cf_pointing_members_group_id
|
|
CREATE INDEX idx_of_cf_pointing_members_group_id ON of_cf_pointing_members (group_id);
|
|
-- index idx_of_cf_pointing_members_zone_domain_id
|
|
CREATE UNIQUE INDEX idx_of_cf_pointing_members_zone_domain_id ON of_cf_pointing_members (zone_domain_id);
|
|
-- index idx_of_config_versions_is_active
|
|
CREATE INDEX idx_of_config_versions_is_active ON of_config_versions (is_active);
|
|
-- index idx_of_node_access_logs_host
|
|
CREATE INDEX idx_of_node_access_logs_host ON of_node_access_logs (host, logged_at DESC);
|
|
-- index idx_of_node_access_logs_host_lower
|
|
CREATE INDEX idx_of_node_access_logs_host_lower ON of_node_access_logs (lower(trim(host)));
|
|
-- index idx_of_node_access_logs_logged_at
|
|
CREATE INDEX idx_of_node_access_logs_logged_at ON of_node_access_logs (logged_at DESC, id DESC);
|
|
-- index idx_of_node_access_logs_node_id
|
|
CREATE INDEX idx_of_node_access_logs_node_id ON of_node_access_logs (node_id, logged_at DESC);
|
|
-- index idx_of_node_access_logs_remote_addr
|
|
CREATE INDEX idx_of_node_access_logs_remote_addr ON of_node_access_logs (remote_addr, logged_at DESC);
|
|
-- index idx_of_node_access_logs_status_code
|
|
CREATE INDEX idx_of_node_access_logs_status_code ON of_node_access_logs (status_code, logged_at DESC);
|
|
-- index idx_of_node_edge_health_node
|
|
CREATE INDEX idx_of_node_edge_health_node ON of_node_edge_health (node_id, captured_at DESC);
|
|
-- index idx_of_node_health_events_event_type
|
|
CREATE INDEX idx_of_node_health_events_event_type ON of_node_health_events (event_type);
|
|
-- index idx_of_node_health_events_first_triggered_at
|
|
CREATE INDEX idx_of_node_health_events_first_triggered_at ON of_node_health_events (first_triggered_at);
|
|
-- index idx_of_node_health_events_last_triggered_at
|
|
CREATE INDEX idx_of_node_health_events_last_triggered_at ON of_node_health_events (last_triggered_at);
|
|
-- index idx_of_node_health_events_node_id
|
|
CREATE INDEX idx_of_node_health_events_node_id ON of_node_health_events (node_id);
|
|
-- index idx_of_node_health_events_reported_at
|
|
CREATE INDEX idx_of_node_health_events_reported_at ON of_node_health_events (reported_at);
|
|
-- index idx_of_node_health_events_resolved_at
|
|
CREATE INDEX idx_of_node_health_events_resolved_at ON of_node_health_events (resolved_at);
|
|
-- index idx_of_node_health_events_status
|
|
CREATE INDEX idx_of_node_health_events_status ON of_node_health_events (status);
|
|
-- index idx_of_node_metric_snapshots_node
|
|
CREATE INDEX idx_of_node_metric_snapshots_node ON of_node_metric_snapshots (node_id, captured_at DESC);
|
|
-- index idx_of_node_obs_frpc_node
|
|
CREATE INDEX idx_of_node_obs_frpc_node ON of_node_obs_frpc (node_id, captured_at DESC);
|
|
-- index idx_of_node_obs_frps_node
|
|
CREATE INDEX idx_of_node_obs_frps_node ON of_node_obs_frps (node_id, captured_at DESC);
|
|
-- index idx_of_node_system_profiles_node_id
|
|
CREATE UNIQUE INDEX idx_of_node_system_profiles_node_id ON of_node_system_profiles (node_id);
|
|
-- index idx_of_node_system_profiles_reported_at
|
|
CREATE INDEX idx_of_node_system_profiles_reported_at ON of_node_system_profiles (reported_at);
|
|
-- index idx_of_nodes_access_token
|
|
CREATE INDEX idx_of_nodes_access_token ON of_nodes (access_token);
|
|
-- index idx_of_nodes_node_id
|
|
CREATE UNIQUE INDEX idx_of_nodes_node_id ON of_nodes (node_id);
|
|
-- index idx_of_origins_address
|
|
CREATE UNIQUE INDEX idx_of_origins_address ON of_origins (address);
|
|
-- index idx_of_pages_deployment_files_deployment_id
|
|
CREATE INDEX idx_of_pages_deployment_files_deployment_id ON of_pages_deployment_files (deployment_id);
|
|
-- index idx_of_pages_deployments_checksum
|
|
CREATE INDEX idx_of_pages_deployments_checksum ON of_pages_deployments (checksum);
|
|
-- index idx_of_pages_deployments_project_id
|
|
CREATE INDEX idx_of_pages_deployments_project_id ON of_pages_deployments (project_id);
|
|
-- index idx_of_pages_deployments_project_number
|
|
CREATE UNIQUE INDEX idx_of_pages_deployments_project_number
|
|
ON of_pages_deployments (project_id, deployment_number);
|
|
-- index idx_of_pages_deployments_source_revision
|
|
CREATE UNIQUE INDEX idx_of_pages_deployments_source_revision
|
|
ON of_pages_deployments (project_id, source_identity, source_revision)
|
|
WHERE source_identity IS NOT NULL AND source_revision IS NOT NULL;
|
|
-- index idx_of_pages_deployments_status
|
|
CREATE INDEX idx_of_pages_deployments_status ON of_pages_deployments (status);
|
|
-- index idx_of_pages_deployments_upload_id
|
|
CREATE INDEX idx_of_pages_deployments_upload_id ON of_pages_deployments (upload_id);
|
|
-- index idx_of_pages_project_source_runtime_next_check_at
|
|
CREATE INDEX idx_of_pages_project_source_runtime_next_check_at
|
|
ON of_pages_project_source_runtime (next_check_at);
|
|
-- index idx_of_pages_project_sources_project_id
|
|
CREATE UNIQUE INDEX idx_of_pages_project_sources_project_id
|
|
ON of_pages_project_sources (project_id);
|
|
-- index idx_of_pages_projects_active_deployment_id
|
|
CREATE INDEX idx_of_pages_projects_active_deployment_id ON of_pages_projects (active_deployment_id);
|
|
-- index idx_of_pages_projects_slug
|
|
CREATE UNIQUE INDEX idx_of_pages_projects_slug ON of_pages_projects (slug);
|
|
-- index idx_of_proxy_routes_origin_id
|
|
CREATE INDEX idx_of_proxy_routes_origin_id ON of_proxy_routes (origin_id);
|
|
-- index idx_of_proxy_routes_pages_project_id
|
|
CREATE INDEX idx_of_proxy_routes_pages_project_id ON of_proxy_routes (pages_project_id);
|
|
-- index idx_of_proxy_routes_site_name
|
|
CREATE UNIQUE INDEX idx_of_proxy_routes_site_name ON of_proxy_routes (site_name);
|
|
-- index idx_of_proxy_routes_tunnel_node_id
|
|
CREATE INDEX idx_of_proxy_routes_tunnel_node_id ON of_proxy_routes (tunnel_node_id);
|
|
-- index idx_of_tls_certificates_name
|
|
CREATE UNIQUE INDEX idx_of_tls_certificates_name ON of_tls_certificates (name);
|
|
-- index idx_of_waf_group_route
|
|
CREATE UNIQUE INDEX idx_of_waf_group_route ON of_waf_rule_group_bindings (rule_group_id, proxy_route_id);
|
|
-- index idx_of_waf_ip_groups_next_sync_at
|
|
CREATE INDEX idx_of_waf_ip_groups_next_sync_at ON of_waf_ip_groups (next_sync_at);
|
|
-- index idx_of_waf_ip_groups_type
|
|
CREATE INDEX idx_of_waf_ip_groups_type ON of_waf_ip_groups (type);
|
|
-- index idx_of_waf_rule_group_bindings_proxy_route_id
|
|
CREATE INDEX idx_of_waf_rule_group_bindings_proxy_route_id ON of_waf_rule_group_bindings (proxy_route_id);
|
|
-- index idx_of_waf_rule_groups_is_global
|
|
CREATE INDEX idx_of_waf_rule_groups_is_global ON of_waf_rule_groups (is_global);
|
|
-- index idx_of_zone_domains_cert_id
|
|
CREATE INDEX idx_of_zone_domains_cert_id ON of_zone_domains (cert_id);
|
|
-- index idx_of_zone_domains_domain
|
|
CREATE UNIQUE INDEX idx_of_zone_domains_domain ON of_zone_domains (domain);
|
|
-- index idx_of_zone_domains_proxy_route_id
|
|
CREATE INDEX idx_of_zone_domains_proxy_route_id ON of_zone_domains (proxy_route_id);
|
|
-- index idx_of_zone_domains_zone_id
|
|
CREATE INDEX idx_of_zone_domains_zone_id ON of_zone_domains (zone_id);
|
|
-- index idx_of_zones_domain
|
|
CREATE UNIQUE INDEX idx_of_zones_domain ON of_zones (domain);
|
|
-- index idx_w_access_tokens_user_id
|
|
CREATE INDEX idx_w_access_tokens_user_id ON w_access_tokens (user_id);
|
|
-- index idx_w_auth_sources_is_active
|
|
CREATE INDEX idx_w_auth_sources_is_active ON w_auth_sources (is_active);
|
|
-- index idx_w_external_accounts_auth_source_id
|
|
CREATE INDEX idx_w_external_accounts_auth_source_id ON w_external_accounts (auth_source_id);
|
|
-- index idx_w_external_accounts_source_external
|
|
CREATE UNIQUE INDEX idx_w_external_accounts_source_external ON w_external_accounts (auth_source_id, external_id);
|
|
-- index idx_w_external_accounts_user_id
|
|
CREATE INDEX idx_w_external_accounts_user_id ON w_external_accounts (user_id);
|
|
-- index idx_w_push_channels_enabled
|
|
CREATE INDEX idx_w_push_channels_enabled ON w_push_channels(enabled);
|
|
-- index idx_w_push_channels_name
|
|
CREATE INDEX idx_w_push_channels_name ON w_push_channels(name);
|
|
-- index idx_w_push_events_enabled
|
|
CREATE INDEX idx_w_push_events_enabled ON w_push_events(enabled);
|
|
-- index idx_w_push_events_task_type
|
|
CREATE INDEX idx_w_push_events_task_type ON w_push_events(task_type);
|
|
-- index idx_w_push_histories_created
|
|
CREATE INDEX idx_w_push_histories_created ON w_push_histories(created_at);
|
|
-- index idx_w_push_histories_event
|
|
CREATE INDEX idx_w_push_histories_event ON w_push_histories(event_key);
|
|
-- index idx_w_schedules_is_active
|
|
CREATE INDEX idx_w_schedules_is_active ON w_schedules (is_active);
|
|
-- index idx_w_task_executions_created_at
|
|
CREATE INDEX idx_w_task_executions_created_at ON w_task_executions (created_at);
|
|
-- index idx_w_task_executions_started_at
|
|
CREATE INDEX idx_w_task_executions_started_at ON w_task_executions (started_at);
|
|
-- index idx_w_task_executions_status
|
|
CREATE INDEX idx_w_task_executions_status ON w_task_executions (status);
|
|
-- index idx_w_task_executions_task_type
|
|
CREATE INDEX idx_w_task_executions_task_type ON w_task_executions (task_type);
|
|
-- index idx_w_templates_created_at
|
|
CREATE INDEX idx_w_templates_created_at ON w_templates (created_at);
|
|
-- index idx_w_templates_is_system
|
|
CREATE INDEX idx_w_templates_is_system ON w_templates (is_system);
|
|
-- index idx_w_templates_updated_at
|
|
CREATE INDEX idx_w_templates_updated_at ON w_templates (updated_at);
|
|
-- index idx_w_uploads_file_path
|
|
CREATE INDEX idx_w_uploads_file_path ON w_uploads (file_path);
|
|
-- index idx_w_uploads_hash
|
|
CREATE INDEX idx_w_uploads_hash ON w_uploads (hash);
|
|
-- index idx_w_uploads_hash_file_size_status
|
|
CREATE INDEX idx_w_uploads_hash_file_size_status ON w_uploads (hash, file_size, status);
|
|
-- index idx_w_uploads_status_created_at
|
|
CREATE INDEX idx_w_uploads_status_created_at ON w_uploads (status, created_at);
|
|
-- index idx_w_uploads_type
|
|
CREATE INDEX idx_w_uploads_type ON w_uploads (type);
|
|
-- index idx_w_uploads_user_id
|
|
CREATE INDEX idx_w_uploads_user_id ON w_uploads (user_id);
|
|
-- index idx_w_user_access_logs_user_id
|
|
CREATE INDEX idx_w_user_access_logs_user_id ON w_user_access_logs (user_id, created_at DESC);
|
|
-- index idx_w_users_created_at
|
|
CREATE INDEX idx_w_users_created_at ON w_users (created_at);
|
|
-- index idx_w_users_email
|
|
CREATE INDEX idx_w_users_email ON w_users (email);
|
|
-- index idx_w_users_is_active
|
|
CREATE INDEX idx_w_users_is_active ON w_users (is_active);
|
|
-- index idx_w_users_last_login_at
|
|
CREATE INDEX idx_w_users_last_login_at ON w_users (last_login_at);
|
|
-- table of_acme_accounts
|
|
CREATE TABLE of_acme_accounts (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
email TEXT NOT NULL DEFAULT '',
|
|
url TEXT NOT NULL DEFAULT '',
|
|
private_key TEXT NOT NULL DEFAULT '',
|
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
-- table of_apply_logs
|
|
CREATE TABLE of_apply_logs (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
node_id TEXT NOT NULL,
|
|
version TEXT NOT NULL,
|
|
result TEXT NOT NULL,
|
|
message TEXT,
|
|
checksum TEXT NOT NULL DEFAULT '',
|
|
main_config_checksum TEXT NOT NULL DEFAULT '',
|
|
route_config_checksum TEXT NOT NULL DEFAULT '',
|
|
support_file_count INTEGER NOT NULL DEFAULT 0,
|
|
created_at DATETIME NOT NULL
|
|
);
|
|
-- table of_cf_connections
|
|
CREATE TABLE of_cf_connections (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
source TEXT NOT NULL DEFAULT '',
|
|
dns_account_id INTEGER,
|
|
authorization TEXT NOT NULL DEFAULT '',
|
|
status TEXT NOT NULL DEFAULT '',
|
|
verified_at DATETIME,
|
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
-- table of_cf_pointing_groups
|
|
CREATE TABLE of_cf_pointing_groups (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
name TEXT NOT NULL,
|
|
primary_node_id INTEGER NOT NULL,
|
|
backup_node_id INTEGER,
|
|
active_node_id INTEGER NOT NULL,
|
|
default_proxied BOOLEAN NOT NULL DEFAULT FALSE,
|
|
enabled BOOLEAN NOT NULL DEFAULT FALSE,
|
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
-- table of_cf_pointing_members
|
|
CREATE TABLE of_cf_pointing_members (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
group_id INTEGER NOT NULL,
|
|
zone_domain_id INTEGER NOT NULL,
|
|
proxied BOOLEAN NOT NULL DEFAULT FALSE,
|
|
cf_zone_id TEXT NOT NULL DEFAULT '',
|
|
cf_record_id TEXT NOT NULL DEFAULT '',
|
|
desired_ip TEXT NOT NULL DEFAULT '',
|
|
sync_status TEXT NOT NULL DEFAULT 'pending',
|
|
last_error TEXT NOT NULL DEFAULT '',
|
|
synced_at DATETIME,
|
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
-- table of_config_versions
|
|
CREATE TABLE "of_config_versions" (
|
|
version VARCHAR(32) PRIMARY KEY,
|
|
snapshot_json TEXT NOT NULL,
|
|
main_config TEXT NOT NULL DEFAULT '',
|
|
rendered_config TEXT NOT NULL,
|
|
support_files_json TEXT NOT NULL DEFAULT '[]',
|
|
checksum VARCHAR(64) NOT NULL,
|
|
is_active BOOLEAN NOT NULL DEFAULT FALSE,
|
|
created_by VARCHAR(64) NOT NULL,
|
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
-- table of_dns_accounts
|
|
CREATE TABLE of_dns_accounts (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
name TEXT NOT NULL,
|
|
type TEXT NOT NULL,
|
|
authorization TEXT NOT NULL,
|
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
-- table of_node_access_logs
|
|
CREATE TABLE of_node_access_logs (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
node_id TEXT NOT NULL DEFAULT '',
|
|
logged_at DATETIME NOT NULL,
|
|
remote_addr TEXT NOT NULL DEFAULT '',
|
|
region TEXT NOT NULL DEFAULT '',
|
|
host TEXT NOT NULL DEFAULT '',
|
|
path TEXT NOT NULL DEFAULT '',
|
|
user_agent TEXT NOT NULL DEFAULT '',
|
|
cache_status TEXT NOT NULL DEFAULT '',
|
|
status_code INTEGER NOT NULL DEFAULT 0,
|
|
bytes_sent INTEGER NOT NULL DEFAULT 0,
|
|
request_length INTEGER NOT NULL DEFAULT 0,
|
|
request_time_ms INTEGER NOT NULL DEFAULT 0,
|
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
-- table of_node_edge_health
|
|
CREATE TABLE of_node_edge_health (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
node_id TEXT NOT NULL DEFAULT '',
|
|
captured_at DATETIME NOT NULL,
|
|
status TEXT NOT NULL DEFAULT '',
|
|
connections INTEGER NOT NULL DEFAULT 0,
|
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
-- table of_node_health_events
|
|
CREATE TABLE of_node_health_events (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
node_id TEXT NOT NULL,
|
|
event_type TEXT NOT NULL,
|
|
severity TEXT NOT NULL,
|
|
status TEXT NOT NULL,
|
|
message TEXT,
|
|
first_triggered_at DATETIME NOT NULL,
|
|
last_triggered_at DATETIME NOT NULL,
|
|
reported_at DATETIME NOT NULL,
|
|
resolved_at DATETIME,
|
|
metadata_json TEXT,
|
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
-- table of_node_metric_snapshots
|
|
CREATE TABLE of_node_metric_snapshots (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
node_id TEXT NOT NULL DEFAULT '',
|
|
captured_at DATETIME NOT NULL,
|
|
cpu_usage_percent REAL NOT NULL DEFAULT 0,
|
|
memory_used_bytes INTEGER NOT NULL DEFAULT 0,
|
|
memory_total_bytes INTEGER NOT NULL DEFAULT 0,
|
|
storage_used_bytes INTEGER NOT NULL DEFAULT 0,
|
|
storage_total_bytes INTEGER NOT NULL DEFAULT 0,
|
|
disk_read_bytes INTEGER NOT NULL DEFAULT 0,
|
|
disk_write_bytes INTEGER NOT NULL DEFAULT 0,
|
|
network_rx_bytes INTEGER NOT NULL DEFAULT 0,
|
|
network_tx_bytes INTEGER NOT NULL DEFAULT 0,
|
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
-- table of_node_obs_frpc
|
|
CREATE TABLE of_node_obs_frpc (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
node_id TEXT NOT NULL DEFAULT '',
|
|
captured_at DATETIME NOT NULL,
|
|
tunnel_status TEXT NOT NULL DEFAULT '',
|
|
connected_relays_count INTEGER NOT NULL DEFAULT 0,
|
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
-- table of_node_obs_frps
|
|
CREATE TABLE of_node_obs_frps (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
node_id TEXT NOT NULL DEFAULT '',
|
|
captured_at DATETIME NOT NULL,
|
|
frps_connections INTEGER NOT NULL DEFAULT 0,
|
|
frps_proxy_count INTEGER NOT NULL DEFAULT 0,
|
|
frps_client_count INTEGER NOT NULL DEFAULT 0,
|
|
frps_proxies TEXT NOT NULL DEFAULT '',
|
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
-- table of_node_system_profiles
|
|
CREATE TABLE of_node_system_profiles (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
node_id TEXT NOT NULL,
|
|
hostname TEXT NOT NULL DEFAULT '',
|
|
os_name TEXT NOT NULL DEFAULT '',
|
|
os_version TEXT NOT NULL DEFAULT '',
|
|
kernel_version TEXT NOT NULL DEFAULT '',
|
|
architecture TEXT NOT NULL DEFAULT '',
|
|
cpu_model TEXT NOT NULL DEFAULT '',
|
|
cpu_cores INTEGER NOT NULL DEFAULT 0,
|
|
total_memory_bytes INTEGER NOT NULL DEFAULT 0,
|
|
total_disk_bytes INTEGER NOT NULL DEFAULT 0,
|
|
uptime_seconds INTEGER NOT NULL DEFAULT 0,
|
|
reported_at DATETIME NOT NULL,
|
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
-- table of_nodes
|
|
CREATE TABLE of_nodes (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
node_id TEXT NOT NULL,
|
|
name TEXT NOT NULL,
|
|
ip TEXT NOT NULL DEFAULT '',
|
|
ip_manual_override INTEGER NOT NULL DEFAULT 0,
|
|
geo_name TEXT NOT NULL DEFAULT '',
|
|
geo_latitude REAL,
|
|
geo_longitude REAL,
|
|
geo_manual_override INTEGER NOT NULL DEFAULT 0,
|
|
access_token TEXT NOT NULL DEFAULT '',
|
|
auto_update_enabled INTEGER NOT NULL DEFAULT 0,
|
|
update_requested INTEGER NOT NULL DEFAULT 0,
|
|
update_channel TEXT NOT NULL DEFAULT 'stable',
|
|
update_tag TEXT NOT NULL DEFAULT '',
|
|
restart_openresty_requested INTEGER NOT NULL DEFAULT 0,
|
|
version TEXT NOT NULL DEFAULT '',
|
|
ext_version TEXT NOT NULL DEFAULT '',
|
|
openresty_status TEXT NOT NULL DEFAULT 'unknown',
|
|
openresty_message TEXT,
|
|
status TEXT NOT NULL DEFAULT 'offline',
|
|
current_version TEXT NOT NULL DEFAULT '',
|
|
last_seen_at DATETIME,
|
|
last_error TEXT,
|
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
node_type TEXT NOT NULL DEFAULT 'edge_node',
|
|
relay_bind_port INTEGER NOT NULL DEFAULT 0,
|
|
relay_vhost_http_port INTEGER NOT NULL DEFAULT 0,
|
|
relay_auth_token TEXT NOT NULL DEFAULT '',
|
|
relay_agent_access_addr TEXT NOT NULL DEFAULT '',
|
|
relay_client_access_addr TEXT NOT NULL DEFAULT '',
|
|
relay_client_proxy_url TEXT NOT NULL DEFAULT '',
|
|
capabilities_json TEXT NOT NULL DEFAULT '[]',
|
|
relay_status TEXT NOT NULL DEFAULT 'unknown',
|
|
relay_web_server_enabled INTEGER NOT NULL DEFAULT 0
|
|
);
|
|
-- table of_origins
|
|
CREATE TABLE of_origins (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
name TEXT NOT NULL,
|
|
address TEXT NOT NULL,
|
|
remark TEXT NOT NULL DEFAULT '',
|
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
-- table of_pages_deployment_files
|
|
CREATE TABLE of_pages_deployment_files (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
deployment_id INTEGER NOT NULL,
|
|
path TEXT NOT NULL,
|
|
size INTEGER NOT NULL DEFAULT 0,
|
|
checksum TEXT NOT NULL,
|
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
-- table of_pages_deployments
|
|
CREATE TABLE of_pages_deployments (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
project_id INTEGER NOT NULL,
|
|
deployment_number INTEGER NOT NULL,
|
|
checksum TEXT NOT NULL,
|
|
status TEXT NOT NULL DEFAULT 'uploaded',
|
|
artifact_path TEXT NOT NULL,
|
|
file_count INTEGER NOT NULL DEFAULT 0,
|
|
total_size INTEGER NOT NULL DEFAULT 0,
|
|
created_by TEXT NOT NULL DEFAULT '',
|
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
activated_at DATETIME
|
|
, upload_id INTEGER NOT NULL DEFAULT 0, source_type TEXT NOT NULL DEFAULT '', source_identity TEXT, source_revision TEXT, source_label TEXT NOT NULL DEFAULT '', source_meta TEXT NOT NULL DEFAULT '', trigger_type TEXT NOT NULL DEFAULT '');
|
|
-- table of_pages_project_source_runtime
|
|
CREATE TABLE of_pages_project_source_runtime (
|
|
source_id INTEGER PRIMARY KEY,
|
|
etag TEXT NOT NULL DEFAULT '',
|
|
last_seen_revision TEXT NOT NULL DEFAULT '',
|
|
last_seen_detail TEXT NOT NULL DEFAULT '',
|
|
last_applied_revision TEXT NOT NULL DEFAULT '',
|
|
last_applied_detail TEXT NOT NULL DEFAULT '',
|
|
sync_status TEXT NOT NULL DEFAULT '',
|
|
last_error TEXT NOT NULL DEFAULT '',
|
|
last_checked_at DATETIME,
|
|
last_synced_at DATETIME,
|
|
next_check_at DATETIME,
|
|
lease_expires_at DATETIME,
|
|
lease_token TEXT NOT NULL DEFAULT '',
|
|
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
-- table of_pages_project_sources
|
|
CREATE TABLE of_pages_project_sources (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
project_id INTEGER NOT NULL,
|
|
source_type TEXT NOT NULL DEFAULT '',
|
|
remote_url TEXT NOT NULL DEFAULT '',
|
|
allow_insecure INTEGER NOT NULL DEFAULT 0,
|
|
github_repository TEXT NOT NULL DEFAULT '',
|
|
release_selector TEXT NOT NULL DEFAULT '',
|
|
release_tag TEXT NOT NULL DEFAULT '',
|
|
asset_name TEXT NOT NULL DEFAULT '',
|
|
auto_update_enabled INTEGER NOT NULL DEFAULT 0,
|
|
check_interval_minutes INTEGER NOT NULL DEFAULT 0,
|
|
config_version INTEGER NOT NULL DEFAULT 0,
|
|
source_identity TEXT NOT NULL DEFAULT '',
|
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
-- table of_pages_projects
|
|
CREATE TABLE of_pages_projects (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
name TEXT NOT NULL,
|
|
slug TEXT NOT NULL,
|
|
description TEXT NOT NULL DEFAULT '',
|
|
enabled INTEGER NOT NULL DEFAULT 1,
|
|
spa_fallback_enabled INTEGER NOT NULL DEFAULT 0,
|
|
spa_fallback_path TEXT NOT NULL DEFAULT '/index.html',
|
|
api_proxy_enabled INTEGER NOT NULL DEFAULT 0,
|
|
api_proxy_path TEXT NOT NULL DEFAULT '',
|
|
api_proxy_pass TEXT NOT NULL DEFAULT '',
|
|
api_proxy_rewrite TEXT NOT NULL DEFAULT '',
|
|
active_deployment_id INTEGER,
|
|
root_dir TEXT NOT NULL DEFAULT '',
|
|
entry_file TEXT NOT NULL DEFAULT 'index.html',
|
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
, content_config_version INTEGER NOT NULL DEFAULT 0);
|
|
-- table of_proxy_routes
|
|
CREATE TABLE "of_proxy_routes" (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
site_name TEXT NOT NULL DEFAULT '',
|
|
origin_id INTEGER,
|
|
origin_url TEXT NOT NULL,
|
|
origin_host TEXT NOT NULL DEFAULT '',
|
|
upstreams TEXT NOT NULL DEFAULT '[]',
|
|
enabled INTEGER NOT NULL DEFAULT 1,
|
|
enable_https INTEGER NOT NULL DEFAULT 0,
|
|
redirect_http INTEGER NOT NULL DEFAULT 0,
|
|
limit_conn_per_server INTEGER NOT NULL DEFAULT 0,
|
|
limit_conn_per_ip INTEGER NOT NULL DEFAULT 0,
|
|
limit_rate TEXT NOT NULL DEFAULT '',
|
|
cache_enabled INTEGER NOT NULL DEFAULT 0,
|
|
cache_policy TEXT NOT NULL DEFAULT '',
|
|
cache_rules TEXT NOT NULL DEFAULT '[]',
|
|
custom_headers TEXT NOT NULL DEFAULT '[]',
|
|
basic_auth_enabled INTEGER NOT NULL DEFAULT 0,
|
|
basic_auth_username TEXT NOT NULL DEFAULT '',
|
|
basic_auth_password TEXT NOT NULL DEFAULT '',
|
|
upstream_type TEXT NOT NULL DEFAULT 'direct',
|
|
tunnel_node_id INTEGER,
|
|
tunnel_target_addr TEXT NOT NULL DEFAULT '',
|
|
tunnel_target_protocol TEXT NOT NULL DEFAULT '',
|
|
pages_project_id INTEGER,
|
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
, limit_req_per_ip VARCHAR(32) NOT NULL DEFAULT '');
|
|
-- table of_tls_certificates
|
|
CREATE TABLE of_tls_certificates (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
name TEXT NOT NULL,
|
|
cert_pem TEXT NOT NULL,
|
|
key_pem TEXT NOT NULL,
|
|
not_before DATETIME,
|
|
not_after DATETIME,
|
|
remark TEXT NOT NULL DEFAULT '',
|
|
provider TEXT NOT NULL DEFAULT 'upload',
|
|
acme_account_id INTEGER NOT NULL DEFAULT 0,
|
|
dns_account_id INTEGER NOT NULL DEFAULT 0,
|
|
key_algorithm TEXT NOT NULL DEFAULT '',
|
|
auto_renew INTEGER NOT NULL DEFAULT 0,
|
|
primary_domain TEXT NOT NULL DEFAULT '',
|
|
other_domains TEXT NOT NULL DEFAULT '',
|
|
disable_cname INTEGER NOT NULL DEFAULT 0,
|
|
skip_dns INTEGER NOT NULL DEFAULT 0,
|
|
dns1 TEXT NOT NULL DEFAULT '',
|
|
dns2 TEXT NOT NULL DEFAULT '',
|
|
apply_status TEXT NOT NULL DEFAULT 'ready',
|
|
apply_message TEXT NOT NULL DEFAULT '',
|
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
-- table of_waf_ip_groups
|
|
CREATE TABLE of_waf_ip_groups (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
name TEXT NOT NULL,
|
|
type TEXT NOT NULL,
|
|
enabled BOOLEAN NOT NULL DEFAULT TRUE,
|
|
ip_list TEXT NOT NULL DEFAULT '[]',
|
|
auto_config TEXT NOT NULL DEFAULT '{}',
|
|
ext_ips TEXT NOT NULL DEFAULT '[]',
|
|
subscription_url TEXT NOT NULL DEFAULT '',
|
|
subscription_format TEXT NOT NULL DEFAULT 'text',
|
|
subscription_mapping_rule TEXT NOT NULL DEFAULT '',
|
|
sync_interval_minutes INTEGER NOT NULL DEFAULT 1440,
|
|
last_synced_at DATETIME,
|
|
next_sync_at DATETIME,
|
|
last_sync_status TEXT NOT NULL DEFAULT '',
|
|
last_sync_message TEXT NOT NULL DEFAULT '',
|
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
-- table of_waf_rule_group_bindings
|
|
CREATE TABLE of_waf_rule_group_bindings (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
rule_group_id INTEGER NOT NULL,
|
|
proxy_route_id INTEGER NOT NULL,
|
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
, sequence INTEGER NOT NULL DEFAULT 0);
|
|
-- table of_waf_rule_groups
|
|
CREATE TABLE of_waf_rule_groups (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
name TEXT NOT NULL,
|
|
enabled BOOLEAN NOT NULL DEFAULT TRUE,
|
|
is_global BOOLEAN NOT NULL DEFAULT FALSE,
|
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
, graph TEXT NOT NULL DEFAULT '', revision INTEGER NOT NULL DEFAULT 1);
|
|
-- table of_zone_domains
|
|
CREATE TABLE of_zone_domains (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
zone_id INTEGER NOT NULL,
|
|
proxy_route_id INTEGER,
|
|
domain TEXT NOT NULL,
|
|
cert_id INTEGER,
|
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
-- table of_zones
|
|
CREATE TABLE of_zones (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
domain TEXT NOT NULL,
|
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
-- table w_access_tokens
|
|
CREATE TABLE "w_access_tokens" (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
user_id BIGINT NOT NULL,
|
|
name VARCHAR(128) NOT NULL,
|
|
token_hash VARCHAR(64) NOT NULL UNIQUE,
|
|
masked_token VARCHAR(64) NOT NULL,
|
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
, is_admin BOOLEAN NOT NULL DEFAULT 0);
|
|
-- table w_auth_sources
|
|
CREATE TABLE "w_auth_sources" (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
name VARCHAR(80) NOT NULL UNIQUE,
|
|
type VARCHAR(20) NOT NULL,
|
|
display_name VARCHAR(100),
|
|
is_active BOOLEAN NOT NULL DEFAULT FALSE,
|
|
client_id VARCHAR(255),
|
|
client_secret VARCHAR(1024),
|
|
openid_discovery_url VARCHAR(1024),
|
|
scopes VARCHAR(255),
|
|
icon_url VARCHAR(1024),
|
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
-- table w_external_accounts
|
|
CREATE TABLE "w_external_accounts" (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
auth_source_id BIGINT,
|
|
user_id BIGINT NOT NULL,
|
|
external_id VARCHAR(255) NOT NULL,
|
|
external_username VARCHAR(255),
|
|
email VARCHAR(255),
|
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
-- table w_push_channels
|
|
CREATE TABLE w_push_channels (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
name TEXT NOT NULL UNIQUE,
|
|
description TEXT,
|
|
type TEXT NOT NULL DEFAULT 'custom',
|
|
token TEXT,
|
|
url TEXT NOT NULL,
|
|
other TEXT NOT NULL,
|
|
enabled BOOLEAN NOT NULL DEFAULT TRUE,
|
|
created_at DATETIME NOT NULL,
|
|
updated_at DATETIME NOT NULL
|
|
);
|
|
-- table w_push_events
|
|
CREATE TABLE w_push_events (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
event_key TEXT NOT NULL UNIQUE,
|
|
name TEXT NOT NULL,
|
|
channels TEXT NOT NULL,
|
|
targets TEXT NOT NULL,
|
|
template TEXT NOT NULL,
|
|
enabled BOOLEAN NOT NULL DEFAULT FALSE,
|
|
created_at DATETIME NOT NULL,
|
|
updated_at DATETIME NOT NULL
|
|
, task_type VARCHAR(100) NOT NULL DEFAULT '');
|
|
-- table w_push_histories
|
|
CREATE TABLE w_push_histories (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
event_key TEXT NOT NULL,
|
|
channel TEXT NOT NULL,
|
|
target TEXT NOT NULL,
|
|
title TEXT NOT NULL,
|
|
content TEXT NOT NULL,
|
|
level TEXT NOT NULL,
|
|
status TEXT NOT NULL,
|
|
error_msg TEXT,
|
|
created_at DATETIME NOT NULL
|
|
);
|
|
-- table w_schedules
|
|
CREATE TABLE "w_schedules" (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
name VARCHAR(128) NOT NULL,
|
|
task_type VARCHAR(64) NOT NULL,
|
|
cron VARCHAR(64) NOT NULL,
|
|
payload TEXT,
|
|
is_active BOOLEAN NOT NULL DEFAULT TRUE,
|
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
-- table w_schedules_backup_of_database_auto_cleanup
|
|
CREATE TABLE w_schedules_backup_of_database_auto_cleanup(
|
|
id INT,
|
|
name TEXT,
|
|
task_type TEXT,
|
|
cron TEXT,
|
|
payload TEXT,
|
|
is_active NUM,
|
|
created_at NUM,
|
|
updated_at NUM
|
|
);
|
|
-- table w_system_configs
|
|
CREATE TABLE "w_system_configs" (
|
|
key VARCHAR(64) PRIMARY KEY,
|
|
value TEXT NOT NULL,
|
|
type VARCHAR(32) NOT NULL DEFAULT 'system',
|
|
visibility INTEGER NOT NULL DEFAULT 0,
|
|
description VARCHAR(255),
|
|
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
-- table w_task_executions
|
|
CREATE TABLE "w_task_executions" (
|
|
id BIGINT PRIMARY KEY,
|
|
task_id VARCHAR(128) NOT NULL UNIQUE,
|
|
task_type VARCHAR(64) NOT NULL,
|
|
task_name VARCHAR(128),
|
|
status VARCHAR(32) NOT NULL,
|
|
retryable BOOLEAN NOT NULL DEFAULT FALSE,
|
|
max_retry INTEGER NOT NULL DEFAULT 0,
|
|
retry_count INTEGER NOT NULL DEFAULT 0,
|
|
log TEXT,
|
|
error_message TEXT,
|
|
result TEXT,
|
|
started_at DATETIME,
|
|
finished_at DATETIME,
|
|
duration BIGINT,
|
|
payload TEXT,
|
|
triggered_by VARCHAR(32) NOT NULL DEFAULT 'system',
|
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
-- table w_templates
|
|
CREATE TABLE "w_templates" (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
key VARCHAR(80) NOT NULL UNIQUE,
|
|
name VARCHAR(100) NOT NULL,
|
|
type VARCHAR(20) NOT NULL DEFAULT 'email',
|
|
subject VARCHAR(255),
|
|
content TEXT NOT NULL,
|
|
description VARCHAR(255),
|
|
is_system BOOLEAN NOT NULL DEFAULT FALSE,
|
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
-- table w_upload_stats
|
|
CREATE TABLE w_upload_stats (
|
|
dimension VARCHAR(32) NOT NULL,
|
|
stat_key VARCHAR(64) NOT NULL DEFAULT '',
|
|
file_count BIGINT NOT NULL DEFAULT 0,
|
|
file_size BIGINT NOT NULL DEFAULT 0,
|
|
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
PRIMARY KEY (dimension, stat_key)
|
|
);
|
|
-- table w_uploads
|
|
CREATE TABLE "w_uploads" (
|
|
id BIGINT PRIMARY KEY,
|
|
user_id BIGINT NOT NULL,
|
|
file_name VARCHAR(255) NOT NULL,
|
|
file_path VARCHAR(500) NOT NULL,
|
|
file_size BIGINT NOT NULL,
|
|
mime_type VARCHAR(100) NOT NULL,
|
|
extension VARCHAR(50) NOT NULL,
|
|
hash VARCHAR(64),
|
|
type VARCHAR(50) NOT NULL,
|
|
status VARCHAR(20) NOT NULL,
|
|
metadata JSON,
|
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
, access_mode INTEGER NOT NULL DEFAULT 0);
|
|
-- table w_user_access_logs
|
|
CREATE TABLE w_user_access_logs (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
user_id INTEGER NOT NULL DEFAULT 0,
|
|
path TEXT NOT NULL DEFAULT '',
|
|
method TEXT NOT NULL DEFAULT '',
|
|
ip TEXT NOT NULL DEFAULT '',
|
|
user_agent TEXT NOT NULL DEFAULT '',
|
|
headers TEXT NOT NULL DEFAULT '',
|
|
status INTEGER NOT NULL DEFAULT 0,
|
|
latency INTEGER NOT NULL DEFAULT 0,
|
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
-- table w_users
|
|
CREATE TABLE "w_users" (
|
|
id BIGINT PRIMARY KEY,
|
|
username VARCHAR(64) UNIQUE,
|
|
password VARCHAR(255),
|
|
nickname VARCHAR(255),
|
|
email VARCHAR(255),
|
|
avatar_url VARCHAR(255),
|
|
is_active BOOLEAN DEFAULT TRUE,
|
|
is_admin BOOLEAN DEFAULT FALSE,
|
|
bio VARCHAR(500),
|
|
phone VARCHAR(32),
|
|
gender VARCHAR(16),
|
|
website VARCHAR(255),
|
|
location VARCHAR(255),
|
|
last_login_at DATETIME,
|
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
-- total objects (excl. bookkeeping): 130
|