From d531d717780b988a77f9110c2a4b7066fa1e7643 Mon Sep 17 00:00:00 2001 From: ryan Date: Sun, 30 Aug 2026 16:54:08 +0800 Subject: [PATCH] refactor(server): merge migrate package and drop unused admin/migrator trees Collapse stamp, of_* SQL and ClickHouse into server/migrate, hoist updater out of admin, and delete the unused 76-file historical chain. --- .../chmigrate.go => migrate/clickhouse.go} | 11 +- .../202606200001_create_node_access_logs.sql | 0 ...00002_create_node_observability_tables.sql | 0 ...202607020001_optimize_analytics_tables.sql | 0 ...07020002_create_node_traffic_hourly_mv.sql | 0 ...01_create_node_metric_openresty_hourly.sql | 0 ...02607100002_node_traffic_hourly_ttl_uv.sql | 0 ...00003_backfill_metric_openresty_hourly.sql | 0 ...001_add_bytes_sent_to_node_access_logs.sql | 0 ...202607180001_access_log_request_length.sql | 0 ...e_health_access_log_hourly_drop_legacy.sql | 0 ...02607180003_backfill_access_log_hourly.sql | 0 .../202607180004_access_log_user_agent.sql | 0 .../202607180005_access_log_cache_status.sql | 0 .../clickhouse_test.go} | 6 +- .../postgres/00001_initial.sql | 0 .../{migrations => migrate}/seed_diff_test.go | 2 +- .../sqlite/00001_initial.sql | 0 .../server/{stamp => migrate}/stamp.go | 4 +- .../server/{stamp => migrate}/stamp_test.go | 2 +- .../postgres/202606050001_bridge_legacy.sql | 7 - .../postgres/202606090001_initial_schema.sql | 184 ---------- .../202606100001_create_schedules.sql | 20 - .../202606100002_access_token_is_admin.sql | 5 - ...10001_remove_access_token_last_used_at.sql | 9 - ...0002_alter_schedules_id_auto_increment.sql | 9 - ...202606110003_rename_tables_to_w_prefix.sql | 66 ---- ...10004_add_file_access_whitelist_config.sql | 7 - .../202606110005_add_disk_cache_configs.sql | 10 - ...606120001_add_login_session_ttl_config.sql | 8 - ..._add_update_upstream_repository_config.sql | 7 - .../202606130001_add_upload_access_mode.sql | 6 - ...02606130002_expand_system_config_value.sql | 5 - .../202606130003_add_storage_config.sql | 15 - .../202606140001_create_push_tables.sql | 34 -- .../postgres/202606140003_add_system_user.sql | 8 - .../202606140004_create_push_channels.sql | 19 - ...6140005_update_system_cleanup_schedule.sql | 11 - ...606150001_add_task_type_to_push_events.sql | 7 - .../202606160001_remove_push_config.sql | 6 - ...606170001_add_upload_composite_indexes.sql | 9 - ...202606170002_create_upload_stats_table.sql | 12 - .../202606170003_backfill_upload_stats.sql | 67 ---- ...02606180001_drop_upload_storage_driver.sql | 7 - .../202606190001_create_of_options.sql | 67 ---- .../202606190002_create_of_origins.sql | 13 - .../202606190003_create_of_apply_logs.sql | 19 - .../202606190004_create_of_proxy_routes.sql | 43 --- .../postgres/202606190005_create_of_nodes.sql | 44 --- .../202606190006_create_of_waf_tables.sql | 60 --- .../202606190007_create_of_tls_tables.sql | 61 --- ...202606190008_create_of_config_versions.sql | 18 - .../202606190009_create_of_pages_tables.sql | 53 --- ...6190010_create_of_observability_tables.sql | 136 ------- ...dd_of_node_access_logs_composite_index.sql | 5 - .../202606190012_create_of_node_obs_frpc.sql | 15 - .../202606190013_seed_openflare_schedules.sql | 11 - ...6190014_add_pages_deployment_upload_id.sql | 14 - ...02606200001_rebrand_openflare_defaults.sql | 31 -- .../202606200002_update_security_defaults.sql | 17 - ...00003_remove_legacy_rate_limit_options.sql | 20 - .../202606200004_drop_of_node_access_logs.sql | 28 -- ..._drop_of_node_observability_timeseries.sql | 98 ----- .../202606200006_migrate_legacy_data.sql | 7 - ...606200007_sync_of_waf_binding_sequence.sql | 9 - ...02606220001_remove_legacy_auth_options.sql | 22 -- .../202606220002_remove_notice_option.sql | 5 - .../202606220003_add_frps_web_ui_config.sql | 9 - ...4_migrate_of_options_to_system_configs.sql | 347 ------------------ .../postgres/202606220005_drop_of_options.sql | 10 - .../202606270001_make_version_primary_key.sql | 19 - ...202606300001_sync_all_legacy_sequences.sql | 20 - ...202607120001_create_zone_domain_tables.sql | 28 -- .../202607120002_import_zone_domains.sql | 8 - ...30001_drop_legacy_route_domain_columns.sql | 35 -- ...02607140001_drop_unused_remark_columns.sql | 16 - .../202607150001_orchestrate_waf_rules.sql | 11 - .../202607150002_reset_waf_rule_graphs.sql | 17 - ...2607150003_drop_legacy_waf_rule_fields.sql | 27 -- .../202607170001_add_pages_system_configs.sql | 9 - ...pdate_agent_heartbeat_offline_defaults.sql | 27 -- ...0001_add_openresty_default_rate_limits.sql | 14 - .../202607190002_add_pages_source_runtime.sql | 82 ----- .../202607190003_seed_pages_source_scan.sql | 38 -- ...add_openresty_default_limit_req_per_ip.sql | 12 - ...02608040001_create_cloudflare_pointing.sql | 49 --- ...08060001_add_origin_error_page_options.sql | 14 - ...8060002_add_origin_error_page_get_only.sql | 8 - .../202608070001_add_sw_offline_options.sql | 12 - .../202608070002_add_sw_offline_domains.sql | 7 - .../202608080001_create_log_tables.sql | 115 ------ .../202608080002_log_retention_configs.sql | 23 -- ...8080003_drop_database_cleanup_schedule.sql | 19 - .../202608090001_metric_retention_config.sql | 9 - ...8090002_update_system_cleanup_schedule.sql | 13 - .../postgres/202608090003_add_log_indexes.sql | 9 - .../sqlite/202606050001_bridge_legacy.sql | 7 - .../sqlite/202606090001_initial_schema.sql | 184 ---------- .../sqlite/202606100001_create_schedules.sql | 20 - .../202606100002_access_token_is_admin.sql | 5 - ...10001_remove_access_token_last_used_at.sql | 9 - ...0002_alter_schedules_id_auto_increment.sql | 32 -- ...202606110003_rename_tables_to_w_prefix.sql | 123 ------- ...10004_add_file_access_whitelist_config.sql | 7 - .../202606110005_add_disk_cache_configs.sql | 10 - ...606120001_add_login_session_ttl_config.sql | 8 - ..._add_update_upstream_repository_config.sql | 7 - .../202606130001_add_upload_access_mode.sql | 6 - ...02606130002_expand_system_config_value.sql | 6 - .../202606130003_add_storage_config.sql | 15 - .../202606140001_create_push_tables.sql | 34 -- .../sqlite/202606140003_add_system_user.sql | 7 - .../202606140004_create_push_channels.sql | 19 - ...6140005_update_system_cleanup_schedule.sql | 11 - ...606150001_add_task_type_to_push_events.sql | 9 - .../202606160001_remove_push_config.sql | 6 - ...606170001_add_upload_composite_indexes.sql | 9 - ...202606170002_create_upload_stats_table.sql | 12 - .../202606170003_backfill_upload_stats.sql | 67 ---- ...02606180001_drop_upload_storage_driver.sql | 8 - .../sqlite/202606190001_create_of_options.sql | 66 ---- .../sqlite/202606190002_create_of_origins.sql | 13 - .../202606190003_create_of_apply_logs.sql | 19 - .../202606190004_create_of_proxy_routes.sql | 43 --- .../sqlite/202606190005_create_of_nodes.sql | 44 --- .../202606190006_create_of_waf_tables.sql | 60 --- .../202606190007_create_of_tls_tables.sql | 61 --- ...202606190008_create_of_config_versions.sql | 18 - .../202606190009_create_of_pages_tables.sql | 53 --- ...6190010_create_of_observability_tables.sql | 136 ------- ...dd_of_node_access_logs_composite_index.sql | 5 - .../202606190012_create_of_node_obs_frpc.sql | 15 - .../202606190013_seed_openflare_schedules.sql | 11 - ...6190014_add_pages_deployment_upload_id.sql | 10 - ...02606200001_rebrand_openflare_defaults.sql | 31 -- .../202606200002_update_security_defaults.sql | 17 - ...00003_remove_legacy_rate_limit_options.sql | 19 - .../202606200004_drop_of_node_access_logs.sql | 28 -- ..._drop_of_node_observability_timeseries.sql | 98 ----- .../202606200006_migrate_legacy_data.sql | 7 - ...606200007_sync_of_waf_binding_sequence.sql | 5 - ...02606220001_remove_legacy_auth_options.sql | 21 -- .../202606220002_remove_notice_option.sql | 5 - .../202606220003_add_frps_web_ui_config.sql | 9 - ...4_migrate_of_options_to_system_configs.sql | 291 --------------- .../sqlite/202606220005_drop_of_options.sql | 10 - .../202606270001_make_version_primary_key.sql | 46 --- ...202606300001_sync_all_legacy_sequences.sql | 5 - ...202607120001_create_zone_domain_tables.sql | 28 -- .../202607120002_import_zone_domains.sql | 8 - ...30001_drop_legacy_route_domain_columns.sql | 138 ------- ...02607140001_drop_unused_remark_columns.sql | 17 - .../202607150001_orchestrate_waf_rules.sql | 10 - .../202607150002_reset_waf_rule_graphs.sql | 16 - ...2607150003_drop_legacy_waf_rule_fields.sql | 27 -- .../202607170001_add_pages_system_configs.sql | 9 - ...pdate_agent_heartbeat_offline_defaults.sql | 27 -- ...0001_add_openresty_default_rate_limits.sql | 14 - .../202607190002_add_pages_source_runtime.sql | 151 -------- .../202607190003_seed_pages_source_scan.sql | 21 -- ...add_openresty_default_limit_req_per_ip.sql | 12 - ...02608040001_create_cloudflare_pointing.sql | 49 --- ...08060001_add_origin_error_page_options.sql | 14 - ...8060002_add_origin_error_page_get_only.sql | 8 - .../202608070001_add_sw_offline_options.sql | 12 - .../202608070002_add_sw_offline_domains.sql | 7 - .../sqlite/202608080001_create_log_tables.sql | 93 ----- .../202608080002_log_retention_configs.sql | 20 - ...8080003_drop_database_cleanup_schedule.sql | 17 - .../202608090001_metric_retention_config.sql | 8 - ...8090002_update_system_cleanup_schedule.sql | 13 - .../sqlite/202608090003_add_log_indexes.sql | 9 - backend/OpenFlare/plugins/server/plugin.go | 9 +- .../repository/logstore/imports_test.go | 2 +- .../repository/openflare_waf_graph_test.go | 63 ---- .../server/router/root/frontend_static.go | 34 -- .../router/root/frontend_static_test.go | 74 ---- .../router/v1/openflare/register_updater.go | 2 +- .../server/{admin => }/updater/errs.go | 0 .../server/{admin => }/updater/export.go | 0 .../server/{admin => }/updater/logics.go | 0 .../server/{admin => }/updater/logics_test.go | 0 .../{admin => }/updater/restart_unix.go | 0 .../{admin => }/updater/restart_windows.go | 0 .../server/{admin => }/updater/routers.go | 0 backend/cmd/app.go | 4 +- docs/changelog/index.md | 1 + 187 files changed, 22 insertions(+), 5028 deletions(-) rename backend/OpenFlare/plugins/server/{chmigrate/chmigrate.go => migrate/clickhouse.go} (90%) rename backend/OpenFlare/plugins/server/{chmigrate/goose => migrate}/clickhouse/202606200001_create_node_access_logs.sql (100%) rename backend/OpenFlare/plugins/server/{chmigrate/goose => migrate}/clickhouse/202606200002_create_node_observability_tables.sql (100%) rename backend/OpenFlare/plugins/server/{chmigrate/goose => migrate}/clickhouse/202607020001_optimize_analytics_tables.sql (100%) rename backend/OpenFlare/plugins/server/{chmigrate/goose => migrate}/clickhouse/202607020002_create_node_traffic_hourly_mv.sql (100%) rename backend/OpenFlare/plugins/server/{chmigrate/goose => migrate}/clickhouse/202607100001_create_node_metric_openresty_hourly.sql (100%) rename backend/OpenFlare/plugins/server/{chmigrate/goose => migrate}/clickhouse/202607100002_node_traffic_hourly_ttl_uv.sql (100%) rename backend/OpenFlare/plugins/server/{chmigrate/goose => migrate}/clickhouse/202607100003_backfill_metric_openresty_hourly.sql (100%) rename backend/OpenFlare/plugins/server/{chmigrate/goose => migrate}/clickhouse/202607120001_add_bytes_sent_to_node_access_logs.sql (100%) rename backend/OpenFlare/plugins/server/{chmigrate/goose => migrate}/clickhouse/202607180001_access_log_request_length.sql (100%) rename backend/OpenFlare/plugins/server/{chmigrate/goose => migrate}/clickhouse/202607180002_edge_health_access_log_hourly_drop_legacy.sql (100%) rename backend/OpenFlare/plugins/server/{chmigrate/goose => migrate}/clickhouse/202607180003_backfill_access_log_hourly.sql (100%) rename backend/OpenFlare/plugins/server/{chmigrate/goose => migrate}/clickhouse/202607180004_access_log_user_agent.sql (100%) rename backend/OpenFlare/plugins/server/{chmigrate/goose => migrate}/clickhouse/202607180005_access_log_cache_status.sql (100%) rename backend/OpenFlare/plugins/server/{chmigrate/chmigrate_test.go => migrate/clickhouse_test.go} (89%) rename backend/OpenFlare/plugins/server/{migrations => migrate}/postgres/00001_initial.sql (100%) rename backend/OpenFlare/plugins/server/{migrations => migrate}/seed_diff_test.go (99%) rename backend/OpenFlare/plugins/server/{migrations => migrate}/sqlite/00001_initial.sql (100%) rename backend/OpenFlare/plugins/server/{stamp => migrate}/stamp.go (98%) rename backend/OpenFlare/plugins/server/{stamp => migrate}/stamp_test.go (99%) delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202606050001_bridge_legacy.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202606090001_initial_schema.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202606100001_create_schedules.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202606100002_access_token_is_admin.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202606110001_remove_access_token_last_used_at.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202606110002_alter_schedules_id_auto_increment.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202606110003_rename_tables_to_w_prefix.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202606110004_add_file_access_whitelist_config.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202606110005_add_disk_cache_configs.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202606120001_add_login_session_ttl_config.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202606120002_add_update_upstream_repository_config.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202606130001_add_upload_access_mode.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202606130002_expand_system_config_value.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202606130003_add_storage_config.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202606140001_create_push_tables.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202606140003_add_system_user.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202606140004_create_push_channels.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202606140005_update_system_cleanup_schedule.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202606150001_add_task_type_to_push_events.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202606160001_remove_push_config.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202606170001_add_upload_composite_indexes.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202606170002_create_upload_stats_table.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202606170003_backfill_upload_stats.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202606180001_drop_upload_storage_driver.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190001_create_of_options.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190002_create_of_origins.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190003_create_of_apply_logs.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190004_create_of_proxy_routes.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190005_create_of_nodes.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190006_create_of_waf_tables.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190007_create_of_tls_tables.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190008_create_of_config_versions.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190009_create_of_pages_tables.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190010_create_of_observability_tables.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190011_add_of_node_access_logs_composite_index.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190012_create_of_node_obs_frpc.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190013_seed_openflare_schedules.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190014_add_pages_deployment_upload_id.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202606200001_rebrand_openflare_defaults.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202606200002_update_security_defaults.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202606200003_remove_legacy_rate_limit_options.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202606200004_drop_of_node_access_logs.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202606200005_drop_of_node_observability_timeseries.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202606200006_migrate_legacy_data.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202606200007_sync_of_waf_binding_sequence.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202606220001_remove_legacy_auth_options.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202606220002_remove_notice_option.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202606220003_add_frps_web_ui_config.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202606220004_migrate_of_options_to_system_configs.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202606220005_drop_of_options.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202606270001_make_version_primary_key.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202606300001_sync_all_legacy_sequences.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202607120001_create_zone_domain_tables.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202607120002_import_zone_domains.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202607130001_drop_legacy_route_domain_columns.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202607140001_drop_unused_remark_columns.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202607150001_orchestrate_waf_rules.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202607150002_reset_waf_rule_graphs.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202607150003_drop_legacy_waf_rule_fields.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202607170001_add_pages_system_configs.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202607180001_update_agent_heartbeat_offline_defaults.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202607190001_add_openresty_default_rate_limits.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202607190002_add_pages_source_runtime.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202607190003_seed_pages_source_scan.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202607200001_add_openresty_default_limit_req_per_ip.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202608040001_create_cloudflare_pointing.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202608060001_add_origin_error_page_options.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202608060002_add_origin_error_page_get_only.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202608070001_add_sw_offline_options.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202608070002_add_sw_offline_domains.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202608080001_create_log_tables.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202608080002_log_retention_configs.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202608080003_drop_database_cleanup_schedule.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202608090001_metric_retention_config.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202608090002_update_system_cleanup_schedule.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/postgres/202608090003_add_log_indexes.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606050001_bridge_legacy.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606090001_initial_schema.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606100001_create_schedules.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606100002_access_token_is_admin.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606110001_remove_access_token_last_used_at.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606110002_alter_schedules_id_auto_increment.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606110003_rename_tables_to_w_prefix.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606110004_add_file_access_whitelist_config.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606110005_add_disk_cache_configs.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606120001_add_login_session_ttl_config.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606120002_add_update_upstream_repository_config.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606130001_add_upload_access_mode.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606130002_expand_system_config_value.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606130003_add_storage_config.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606140001_create_push_tables.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606140003_add_system_user.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606140004_create_push_channels.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606140005_update_system_cleanup_schedule.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606150001_add_task_type_to_push_events.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606160001_remove_push_config.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606170001_add_upload_composite_indexes.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606170002_create_upload_stats_table.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606170003_backfill_upload_stats.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606180001_drop_upload_storage_driver.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190001_create_of_options.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190002_create_of_origins.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190003_create_of_apply_logs.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190004_create_of_proxy_routes.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190005_create_of_nodes.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190006_create_of_waf_tables.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190007_create_of_tls_tables.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190008_create_of_config_versions.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190009_create_of_pages_tables.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190010_create_of_observability_tables.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190011_add_of_node_access_logs_composite_index.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190012_create_of_node_obs_frpc.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190013_seed_openflare_schedules.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190014_add_pages_deployment_upload_id.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606200001_rebrand_openflare_defaults.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606200002_update_security_defaults.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606200003_remove_legacy_rate_limit_options.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606200004_drop_of_node_access_logs.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606200005_drop_of_node_observability_timeseries.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606200006_migrate_legacy_data.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606200007_sync_of_waf_binding_sequence.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606220001_remove_legacy_auth_options.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606220002_remove_notice_option.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606220003_add_frps_web_ui_config.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606220004_migrate_of_options_to_system_configs.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606220005_drop_of_options.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606270001_make_version_primary_key.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606300001_sync_all_legacy_sequences.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202607120001_create_zone_domain_tables.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202607120002_import_zone_domains.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202607130001_drop_legacy_route_domain_columns.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202607140001_drop_unused_remark_columns.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202607150001_orchestrate_waf_rules.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202607150002_reset_waf_rule_graphs.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202607150003_drop_legacy_waf_rule_fields.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202607170001_add_pages_system_configs.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202607180001_update_agent_heartbeat_offline_defaults.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202607190001_add_openresty_default_rate_limits.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202607190002_add_pages_source_runtime.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202607190003_seed_pages_source_scan.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202607200001_add_openresty_default_limit_req_per_ip.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202608040001_create_cloudflare_pointing.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202608060001_add_origin_error_page_options.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202608060002_add_origin_error_page_get_only.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202608070001_add_sw_offline_options.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202608070002_add_sw_offline_domains.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202608080001_create_log_tables.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202608080002_log_retention_configs.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202608080003_drop_database_cleanup_schedule.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202608090001_metric_retention_config.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202608090002_update_system_cleanup_schedule.sql delete mode 100644 backend/OpenFlare/plugins/server/migrator/goose/sqlite/202608090003_add_log_indexes.sql delete mode 100644 backend/OpenFlare/plugins/server/router/root/frontend_static.go delete mode 100644 backend/OpenFlare/plugins/server/router/root/frontend_static_test.go rename backend/OpenFlare/plugins/server/{admin => }/updater/errs.go (100%) rename backend/OpenFlare/plugins/server/{admin => }/updater/export.go (100%) rename backend/OpenFlare/plugins/server/{admin => }/updater/logics.go (100%) rename backend/OpenFlare/plugins/server/{admin => }/updater/logics_test.go (100%) rename backend/OpenFlare/plugins/server/{admin => }/updater/restart_unix.go (100%) rename backend/OpenFlare/plugins/server/{admin => }/updater/restart_windows.go (100%) rename backend/OpenFlare/plugins/server/{admin => }/updater/routers.go (100%) diff --git a/backend/OpenFlare/plugins/server/chmigrate/chmigrate.go b/backend/OpenFlare/plugins/server/migrate/clickhouse.go similarity index 90% rename from backend/OpenFlare/plugins/server/chmigrate/chmigrate.go rename to backend/OpenFlare/plugins/server/migrate/clickhouse.go index ad62d38f..78d2f45b 100644 --- a/backend/OpenFlare/plugins/server/chmigrate/chmigrate.go +++ b/backend/OpenFlare/plugins/server/migrate/clickhouse.go @@ -2,8 +2,7 @@ // Copyright 2026 Arctel.net // SPDX-License-Identifier: Apache-2.0 -// Package chmigrate applies ClickHouse of_node_* goose migrations. -package chmigrate +package migrate import ( "context" @@ -20,17 +19,17 @@ import ( ) const ( - clickhouseMigrationDir = "goose/clickhouse" + clickhouseMigrationDir = "clickhouse" clickhouseGooseVersionTable = "goose_clickhouse_version" clickhouseMaxExecTime = 60 clickhouseReadTimeoutFactor = 2 ) -//go:embed goose/clickhouse/*.sql +//go:embed clickhouse/*.sql var clickhouseMigrationFS embed.FS -// Up runs of_node_* goose migrations against ClickHouse when enabled. -func Up() error { +// UpClickHouse runs of_node_* goose migrations against ClickHouse when enabled. +func UpClickHouse() error { if !runtimeconfig.ClickHouseEnabled() { return nil } diff --git a/backend/OpenFlare/plugins/server/chmigrate/goose/clickhouse/202606200001_create_node_access_logs.sql b/backend/OpenFlare/plugins/server/migrate/clickhouse/202606200001_create_node_access_logs.sql similarity index 100% rename from backend/OpenFlare/plugins/server/chmigrate/goose/clickhouse/202606200001_create_node_access_logs.sql rename to backend/OpenFlare/plugins/server/migrate/clickhouse/202606200001_create_node_access_logs.sql diff --git a/backend/OpenFlare/plugins/server/chmigrate/goose/clickhouse/202606200002_create_node_observability_tables.sql b/backend/OpenFlare/plugins/server/migrate/clickhouse/202606200002_create_node_observability_tables.sql similarity index 100% rename from backend/OpenFlare/plugins/server/chmigrate/goose/clickhouse/202606200002_create_node_observability_tables.sql rename to backend/OpenFlare/plugins/server/migrate/clickhouse/202606200002_create_node_observability_tables.sql diff --git a/backend/OpenFlare/plugins/server/chmigrate/goose/clickhouse/202607020001_optimize_analytics_tables.sql b/backend/OpenFlare/plugins/server/migrate/clickhouse/202607020001_optimize_analytics_tables.sql similarity index 100% rename from backend/OpenFlare/plugins/server/chmigrate/goose/clickhouse/202607020001_optimize_analytics_tables.sql rename to backend/OpenFlare/plugins/server/migrate/clickhouse/202607020001_optimize_analytics_tables.sql diff --git a/backend/OpenFlare/plugins/server/chmigrate/goose/clickhouse/202607020002_create_node_traffic_hourly_mv.sql b/backend/OpenFlare/plugins/server/migrate/clickhouse/202607020002_create_node_traffic_hourly_mv.sql similarity index 100% rename from backend/OpenFlare/plugins/server/chmigrate/goose/clickhouse/202607020002_create_node_traffic_hourly_mv.sql rename to backend/OpenFlare/plugins/server/migrate/clickhouse/202607020002_create_node_traffic_hourly_mv.sql diff --git a/backend/OpenFlare/plugins/server/chmigrate/goose/clickhouse/202607100001_create_node_metric_openresty_hourly.sql b/backend/OpenFlare/plugins/server/migrate/clickhouse/202607100001_create_node_metric_openresty_hourly.sql similarity index 100% rename from backend/OpenFlare/plugins/server/chmigrate/goose/clickhouse/202607100001_create_node_metric_openresty_hourly.sql rename to backend/OpenFlare/plugins/server/migrate/clickhouse/202607100001_create_node_metric_openresty_hourly.sql diff --git a/backend/OpenFlare/plugins/server/chmigrate/goose/clickhouse/202607100002_node_traffic_hourly_ttl_uv.sql b/backend/OpenFlare/plugins/server/migrate/clickhouse/202607100002_node_traffic_hourly_ttl_uv.sql similarity index 100% rename from backend/OpenFlare/plugins/server/chmigrate/goose/clickhouse/202607100002_node_traffic_hourly_ttl_uv.sql rename to backend/OpenFlare/plugins/server/migrate/clickhouse/202607100002_node_traffic_hourly_ttl_uv.sql diff --git a/backend/OpenFlare/plugins/server/chmigrate/goose/clickhouse/202607100003_backfill_metric_openresty_hourly.sql b/backend/OpenFlare/plugins/server/migrate/clickhouse/202607100003_backfill_metric_openresty_hourly.sql similarity index 100% rename from backend/OpenFlare/plugins/server/chmigrate/goose/clickhouse/202607100003_backfill_metric_openresty_hourly.sql rename to backend/OpenFlare/plugins/server/migrate/clickhouse/202607100003_backfill_metric_openresty_hourly.sql diff --git a/backend/OpenFlare/plugins/server/chmigrate/goose/clickhouse/202607120001_add_bytes_sent_to_node_access_logs.sql b/backend/OpenFlare/plugins/server/migrate/clickhouse/202607120001_add_bytes_sent_to_node_access_logs.sql similarity index 100% rename from backend/OpenFlare/plugins/server/chmigrate/goose/clickhouse/202607120001_add_bytes_sent_to_node_access_logs.sql rename to backend/OpenFlare/plugins/server/migrate/clickhouse/202607120001_add_bytes_sent_to_node_access_logs.sql diff --git a/backend/OpenFlare/plugins/server/chmigrate/goose/clickhouse/202607180001_access_log_request_length.sql b/backend/OpenFlare/plugins/server/migrate/clickhouse/202607180001_access_log_request_length.sql similarity index 100% rename from backend/OpenFlare/plugins/server/chmigrate/goose/clickhouse/202607180001_access_log_request_length.sql rename to backend/OpenFlare/plugins/server/migrate/clickhouse/202607180001_access_log_request_length.sql diff --git a/backend/OpenFlare/plugins/server/chmigrate/goose/clickhouse/202607180002_edge_health_access_log_hourly_drop_legacy.sql b/backend/OpenFlare/plugins/server/migrate/clickhouse/202607180002_edge_health_access_log_hourly_drop_legacy.sql similarity index 100% rename from backend/OpenFlare/plugins/server/chmigrate/goose/clickhouse/202607180002_edge_health_access_log_hourly_drop_legacy.sql rename to backend/OpenFlare/plugins/server/migrate/clickhouse/202607180002_edge_health_access_log_hourly_drop_legacy.sql diff --git a/backend/OpenFlare/plugins/server/chmigrate/goose/clickhouse/202607180003_backfill_access_log_hourly.sql b/backend/OpenFlare/plugins/server/migrate/clickhouse/202607180003_backfill_access_log_hourly.sql similarity index 100% rename from backend/OpenFlare/plugins/server/chmigrate/goose/clickhouse/202607180003_backfill_access_log_hourly.sql rename to backend/OpenFlare/plugins/server/migrate/clickhouse/202607180003_backfill_access_log_hourly.sql diff --git a/backend/OpenFlare/plugins/server/chmigrate/goose/clickhouse/202607180004_access_log_user_agent.sql b/backend/OpenFlare/plugins/server/migrate/clickhouse/202607180004_access_log_user_agent.sql similarity index 100% rename from backend/OpenFlare/plugins/server/chmigrate/goose/clickhouse/202607180004_access_log_user_agent.sql rename to backend/OpenFlare/plugins/server/migrate/clickhouse/202607180004_access_log_user_agent.sql diff --git a/backend/OpenFlare/plugins/server/chmigrate/goose/clickhouse/202607180005_access_log_cache_status.sql b/backend/OpenFlare/plugins/server/migrate/clickhouse/202607180005_access_log_cache_status.sql similarity index 100% rename from backend/OpenFlare/plugins/server/chmigrate/goose/clickhouse/202607180005_access_log_cache_status.sql rename to backend/OpenFlare/plugins/server/migrate/clickhouse/202607180005_access_log_cache_status.sql diff --git a/backend/OpenFlare/plugins/server/chmigrate/chmigrate_test.go b/backend/OpenFlare/plugins/server/migrate/clickhouse_test.go similarity index 89% rename from backend/OpenFlare/plugins/server/chmigrate/chmigrate_test.go rename to backend/OpenFlare/plugins/server/migrate/clickhouse_test.go index 041494f7..87e833c9 100644 --- a/backend/OpenFlare/plugins/server/chmigrate/chmigrate_test.go +++ b/backend/OpenFlare/plugins/server/migrate/clickhouse_test.go @@ -1,7 +1,7 @@ // Copyright 2026 Arctel.net // SPDX-License-Identifier: Apache-2.0 -package chmigrate +package migrate import ( "strings" @@ -46,7 +46,7 @@ func TestClickHouseGooseDialect(t *testing.T) { func TestUpSkipsWhenDisabled(t *testing.T) { t.Cleanup(runtimeconfig.Override(runtimeconfig.DatabaseEnabled(), false)) - if err := Up(); err != nil { - t.Fatalf("Up() error = %v, want nil when ClickHouse disabled", err) + if err := UpClickHouse(); err != nil { + t.Fatalf("UpClickHouse() error = %v, want nil when ClickHouse disabled", err) } } diff --git a/backend/OpenFlare/plugins/server/migrations/postgres/00001_initial.sql b/backend/OpenFlare/plugins/server/migrate/postgres/00001_initial.sql similarity index 100% rename from backend/OpenFlare/plugins/server/migrations/postgres/00001_initial.sql rename to backend/OpenFlare/plugins/server/migrate/postgres/00001_initial.sql diff --git a/backend/OpenFlare/plugins/server/migrations/seed_diff_test.go b/backend/OpenFlare/plugins/server/migrate/seed_diff_test.go similarity index 99% rename from backend/OpenFlare/plugins/server/migrations/seed_diff_test.go rename to backend/OpenFlare/plugins/server/migrate/seed_diff_test.go index 02092629..df0dd647 100644 --- a/backend/OpenFlare/plugins/server/migrations/seed_diff_test.go +++ b/backend/OpenFlare/plugins/server/migrate/seed_diff_test.go @@ -1,7 +1,7 @@ // Copyright 2026 Arctel.net // SPDX-License-Identifier: Apache-2.0 -package migrations +package migrate import ( "os" diff --git a/backend/OpenFlare/plugins/server/migrations/sqlite/00001_initial.sql b/backend/OpenFlare/plugins/server/migrate/sqlite/00001_initial.sql similarity index 100% rename from backend/OpenFlare/plugins/server/migrations/sqlite/00001_initial.sql rename to backend/OpenFlare/plugins/server/migrate/sqlite/00001_initial.sql diff --git a/backend/OpenFlare/plugins/server/stamp/stamp.go b/backend/OpenFlare/plugins/server/migrate/stamp.go similarity index 98% rename from backend/OpenFlare/plugins/server/stamp/stamp.go rename to backend/OpenFlare/plugins/server/migrate/stamp.go index 10aa2b37..a167b588 100644 --- a/backend/OpenFlare/plugins/server/stamp/stamp.go +++ b/backend/OpenFlare/plugins/server/migrate/stamp.go @@ -1,8 +1,8 @@ // Copyright 2026 Arctel.net // SPDX-License-Identifier: Apache-2.0 -// Package stamp records pre-Cordis schema versions into w_schema_versions. -package stamp +// Package migrate records pre-Cordis schema versions and applies of_* SQL. +package migrate import ( "context" diff --git a/backend/OpenFlare/plugins/server/stamp/stamp_test.go b/backend/OpenFlare/plugins/server/migrate/stamp_test.go similarity index 99% rename from backend/OpenFlare/plugins/server/stamp/stamp_test.go rename to backend/OpenFlare/plugins/server/migrate/stamp_test.go index eeb23c66..f4298f42 100644 --- a/backend/OpenFlare/plugins/server/stamp/stamp_test.go +++ b/backend/OpenFlare/plugins/server/migrate/stamp_test.go @@ -1,7 +1,7 @@ // Copyright 2026 Arctel.net // SPDX-License-Identifier: Apache-2.0 -package stamp +package migrate import ( "context" diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606050001_bridge_legacy.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606050001_bridge_legacy.sql deleted file mode 100644 index 52839fa9..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606050001_bridge_legacy.sql +++ /dev/null @@ -1,7 +0,0 @@ --- +goose Up --- Historical Wavelet→OpenFlare table rename bridge (formerly Go migration). --- Fresh installs and current of_* schemas need no action. -SELECT 1; - --- +goose Down -SELECT 1; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606090001_initial_schema.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606090001_initial_schema.sql deleted file mode 100644 index 3b6f72a6..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606090001_initial_schema.sql +++ /dev/null @@ -1,184 +0,0 @@ --- +goose Up -CREATE TABLE IF NOT EXISTS 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 TIMESTAMPTZ, - created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP, - updated_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP -); -CREATE INDEX IF NOT EXISTS idx_users_email ON users (email); -CREATE INDEX IF NOT EXISTS idx_users_is_active ON users (is_active); -CREATE INDEX IF NOT EXISTS idx_users_last_login_at ON users (last_login_at); -CREATE INDEX IF NOT EXISTS idx_users_created_at ON users (created_at); - -CREATE TABLE IF NOT EXISTS auth_sources ( - id BIGSERIAL PRIMARY KEY, - 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 TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP, - updated_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP -); -CREATE INDEX IF NOT EXISTS idx_auth_sources_is_active ON auth_sources (is_active); - -CREATE TABLE IF NOT EXISTS external_accounts ( - id BIGSERIAL PRIMARY KEY, - auth_source_id BIGINT, - user_id BIGINT NOT NULL, - external_id VARCHAR(255) NOT NULL, - external_username VARCHAR(255), - email VARCHAR(255), - created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP, - updated_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP -); -CREATE INDEX IF NOT EXISTS idx_external_accounts_auth_source_id ON external_accounts (auth_source_id); -CREATE INDEX IF NOT EXISTS idx_external_accounts_user_id ON external_accounts (user_id); -CREATE UNIQUE INDEX IF NOT EXISTS idx_external_accounts_source_external ON external_accounts (auth_source_id, external_id); - -CREATE TABLE IF NOT EXISTS 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 TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP, - created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP -); - -CREATE TABLE IF NOT EXISTS 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), - storage_driver VARCHAR(50) NOT NULL, - type VARCHAR(50) NOT NULL, - status VARCHAR(20) NOT NULL, - metadata JSONB, - created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP, - updated_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP -); -CREATE INDEX IF NOT EXISTS idx_uploads_user_id ON uploads (user_id); -CREATE INDEX IF NOT EXISTS idx_uploads_file_path ON uploads (file_path); -CREATE INDEX IF NOT EXISTS idx_uploads_hash ON uploads (hash); -CREATE INDEX IF NOT EXISTS idx_uploads_type ON uploads (type); - -CREATE TABLE IF NOT EXISTS access_tokens ( - id BIGSERIAL PRIMARY KEY, - user_id BIGINT NOT NULL, - name VARCHAR(128) NOT NULL, - token_hash VARCHAR(64) NOT NULL UNIQUE, - masked_token VARCHAR(64) NOT NULL, - last_used_at TIMESTAMPTZ, - created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP, - updated_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP -); -CREATE INDEX IF NOT EXISTS idx_access_tokens_user_id ON access_tokens (user_id); - -CREATE TABLE IF NOT EXISTS 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 TIMESTAMPTZ, - finished_at TIMESTAMPTZ, - duration BIGINT, - payload TEXT, - triggered_by VARCHAR(32) NOT NULL DEFAULT 'system', - created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP, - updated_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP -); -CREATE INDEX IF NOT EXISTS idx_task_executions_task_type ON task_executions (task_type); -CREATE INDEX IF NOT EXISTS idx_task_executions_status ON task_executions (status); -CREATE INDEX IF NOT EXISTS idx_task_executions_started_at ON task_executions (started_at); -CREATE INDEX IF NOT EXISTS idx_task_executions_created_at ON task_executions (created_at); - -CREATE TABLE IF NOT EXISTS templates ( - id BIGSERIAL PRIMARY KEY, - 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 TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP, - updated_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP -); -CREATE INDEX IF NOT EXISTS idx_templates_is_system ON templates (is_system); -CREATE INDEX IF NOT EXISTS idx_templates_created_at ON templates (created_at); -CREATE INDEX IF NOT EXISTS idx_templates_updated_at ON templates (updated_at); - -INSERT INTO system_configs (key, value, type, visibility, description, created_at, updated_at) VALUES - ('cap_login_enabled', 'false', 'system', 1, '是否启用登录人机验证(true/false)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('cap_auto_solve', 'true', 'system', 1, '打开页面后是否自动开始计算,关闭则需用户手动点击触发', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('cap_challenge_count', '1', 'system', 0, '客户端需求解的 PoW 难题总数,默认 1,推荐 1~5', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('cap_challenge_size', '32', 'system', 0, '人机验证盐值长度', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('cap_challenge_difficulty', '4', 'system', 0, '人机验证 PoW 难度(目标前缀长度)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('cap_challenge_ttl_seconds', '600', 'system', 0, '人机验证难题有效时间(秒)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('cap_token_ttl_seconds', '1200', 'system', 0, '人机验证兑换凭证有效时间(秒)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('server_address', '', 'system', 0, '服务器地址(用于跨域源控制,不设定则允许任意源)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('smtp_host', '', 'system', 0, 'SMTP 服务器地址(例如 smtp.example.com)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('smtp_port', '587', 'system', 0, 'SMTP 端口(例如 587 或 465)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('smtp_username', '', 'system', 0, 'SMTP 账户(如 sender@example.com)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('smtp_password', '', 'system', 0, 'SMTP 访问凭证(授权码/密码)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('upload_allowed_extensions', 'jpg,png,webp', 'system', 1, '允许上传的图片扩展名(逗号分隔)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('site_name', 'OpenFlare', 'system', 1, '系统平台的展示名称', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('password_login_enabled', 'true', 'system', 1, '是否允许使用账号密码登录', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('registration_enabled', 'false', 'system', 1, '控制普通用户是否可以自主注册(true/false)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('password_register_enabled', 'false', 'system', 1, '是否允许通过密码创建本地账号', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('oidc_login_enabled', 'true', 'system', 1, '是否允许使用第三方 OIDC 认证源登录', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('max_api_keys_per_user', '5', 'business', 1, '限制每个普通用户可以创建的 API Key 最大数量', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('email_login_verification_enabled', 'false', 'system', 1, '是否开启邮箱登录验证(true/false)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('email_register_verification_enabled', 'false', 'system', 1, '是否开启邮箱注册验证(true/false)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('menu_display_config', '{}', 'system', 1, '目录显示配置(JSON 字符串,格式为 {url: enabled})', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('search_engine_indexing_enabled', 'false', 'system', 1, '是否允许搜索引擎爬取/检索该站点(true/false)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('update_upstream_repository', 'Rain-kl/OpenFlare', 'system', 0, 'GitHub Actions Release 上游仓库(owner/repo 或 GitHub 仓库地址)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('storage_config', '{"driver":"local","local":{"root":"."},"s3":{"region":"us-east-1"},"r2":{"region":"auto"},"minio":{"region":"us-east-1","path_style":true},"oss":{},"webdav":{}}', 'system', 0, '文件存储驱动及连接配置(JSON)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP) -ON CONFLICT (key) DO NOTHING; - -INSERT INTO users (id, username, password, nickname, avatar_url, is_active, is_admin, last_login_at, created_at, updated_at) -VALUES (1, 'admin', '12345678', 'Administrator', '', TRUE, TRUE, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP) -ON CONFLICT (username) DO NOTHING; - -INSERT INTO templates (key, name, type, subject, content, description, is_system, created_at, updated_at) VALUES - ('login_email', '登录验证码邮件', 'email', 'OpenFlare 登录验证码', '

OpenFlare 登录验证

您的登录验证码为:{{.Code}},5分钟内有效,请勿将验证码泄露给他人。

', '用户密码登录时发送的验证码邮件模板,支持变量:{{.Code}}', TRUE, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('register_email', '注册验证码邮件', 'email', 'OpenFlare 注册验证码', '

OpenFlare 注册验证

您的注册验证码为:{{.Code}},5分钟内有效,请勿泄露给他人。

', '用户注册时发送的验证码邮件模板,支持变量:{{.Code}}', TRUE, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP) -ON CONFLICT (key) DO NOTHING; - --- +goose Down -DROP TABLE IF EXISTS templates; -DROP TABLE IF EXISTS task_executions; -DROP TABLE IF EXISTS access_tokens; -DROP TABLE IF EXISTS uploads; -DROP TABLE IF EXISTS system_configs; -DROP TABLE IF EXISTS external_accounts; -DROP TABLE IF EXISTS auth_sources; -DROP TABLE IF EXISTS users; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606100001_create_schedules.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606100001_create_schedules.sql deleted file mode 100644 index bb107c9a..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606100001_create_schedules.sql +++ /dev/null @@ -1,20 +0,0 @@ --- +goose Up -CREATE TABLE IF NOT EXISTS schedules ( - id BIGINT PRIMARY KEY, - 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 TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP, - updated_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP -); -CREATE INDEX IF NOT EXISTS idx_schedules_is_active ON schedules (is_active); - --- Seed initial cleanup task -INSERT INTO schedules (id, name, task_type, cron, payload, is_active, created_at, updated_at) -VALUES (1, '清理未使用上传', 'cleanup_unused_uploads', '0 */2 * * *', '{}', TRUE, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP) -ON CONFLICT (id) DO NOTHING; - --- +goose Down -DROP TABLE IF EXISTS schedules; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606100002_access_token_is_admin.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606100002_access_token_is_admin.sql deleted file mode 100644 index 3163d6cf..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606100002_access_token_is_admin.sql +++ /dev/null @@ -1,5 +0,0 @@ --- +goose Up -ALTER TABLE access_tokens ADD COLUMN is_admin BOOLEAN NOT NULL DEFAULT FALSE; - --- +goose Down -ALTER TABLE access_tokens DROP COLUMN IF EXISTS is_admin; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606110001_remove_access_token_last_used_at.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606110001_remove_access_token_last_used_at.sql deleted file mode 100644 index 4a0fa676..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606110001_remove_access_token_last_used_at.sql +++ /dev/null @@ -1,9 +0,0 @@ --- +goose Up --- +goose StatementBegin -ALTER TABLE access_tokens DROP COLUMN IF EXISTS last_used_at; --- +goose StatementEnd - --- +goose Down --- +goose StatementBegin -ALTER TABLE access_tokens ADD COLUMN last_used_at TIMESTAMPTZ; --- +goose StatementEnd diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606110002_alter_schedules_id_auto_increment.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606110002_alter_schedules_id_auto_increment.sql deleted file mode 100644 index 0797bd64..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606110002_alter_schedules_id_auto_increment.sql +++ /dev/null @@ -1,9 +0,0 @@ --- +goose Up --- +goose StatementBegin -ALTER TABLE schedules ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (START WITH 100); --- +goose StatementEnd - --- +goose Down --- +goose StatementBegin -ALTER TABLE schedules ALTER COLUMN id DROP IDENTITY IF EXISTS; --- +goose StatementEnd diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606110003_rename_tables_to_w_prefix.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606110003_rename_tables_to_w_prefix.sql deleted file mode 100644 index b635e677..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606110003_rename_tables_to_w_prefix.sql +++ /dev/null @@ -1,66 +0,0 @@ --- +goose Up -ALTER TABLE users RENAME TO w_users; -ALTER TABLE auth_sources RENAME TO w_auth_sources; -ALTER TABLE external_accounts RENAME TO w_external_accounts; -ALTER TABLE system_configs RENAME TO w_system_configs; -ALTER TABLE uploads RENAME TO w_uploads; -ALTER TABLE access_tokens RENAME TO w_access_tokens; -ALTER TABLE task_executions RENAME TO w_task_executions; -ALTER TABLE templates RENAME TO w_templates; -ALTER TABLE schedules RENAME TO w_schedules; - --- Rename indexes for consistency -ALTER INDEX IF EXISTS idx_users_email RENAME TO idx_w_users_email; -ALTER INDEX IF EXISTS idx_users_is_active RENAME TO idx_w_users_is_active; -ALTER INDEX IF EXISTS idx_users_last_login_at RENAME TO idx_w_users_last_login_at; -ALTER INDEX IF EXISTS idx_users_created_at RENAME TO idx_w_users_created_at; -ALTER INDEX IF EXISTS idx_auth_sources_is_active RENAME TO idx_w_auth_sources_is_active; -ALTER INDEX IF EXISTS idx_external_accounts_auth_source_id RENAME TO idx_w_external_accounts_auth_source_id; -ALTER INDEX IF EXISTS idx_external_accounts_user_id RENAME TO idx_w_external_accounts_user_id; -ALTER INDEX IF EXISTS idx_external_accounts_source_external RENAME TO idx_w_external_accounts_source_external; -ALTER INDEX IF EXISTS idx_uploads_user_id RENAME TO idx_w_uploads_user_id; -ALTER INDEX IF EXISTS idx_uploads_file_path RENAME TO idx_w_uploads_file_path; -ALTER INDEX IF EXISTS idx_uploads_hash RENAME TO idx_w_uploads_hash; -ALTER INDEX IF EXISTS idx_uploads_type RENAME TO idx_w_uploads_type; -ALTER INDEX IF EXISTS idx_access_tokens_user_id RENAME TO idx_w_access_tokens_user_id; -ALTER INDEX IF EXISTS idx_task_executions_task_type RENAME TO idx_w_task_executions_task_type; -ALTER INDEX IF EXISTS idx_task_executions_status RENAME TO idx_w_task_executions_status; -ALTER INDEX IF EXISTS idx_task_executions_started_at RENAME TO idx_w_task_executions_started_at; -ALTER INDEX IF EXISTS idx_task_executions_created_at RENAME TO idx_w_task_executions_created_at; -ALTER INDEX IF EXISTS idx_templates_is_system RENAME TO idx_w_templates_is_system; -ALTER INDEX IF EXISTS idx_templates_created_at RENAME TO idx_w_templates_created_at; -ALTER INDEX IF EXISTS idx_templates_updated_at RENAME TO idx_w_templates_updated_at; -ALTER INDEX IF EXISTS idx_schedules_is_active RENAME TO idx_w_schedules_is_active; - --- +goose Down -ALTER INDEX IF EXISTS idx_w_schedules_is_active RENAME TO idx_schedules_is_active; -ALTER INDEX IF EXISTS idx_w_templates_updated_at RENAME TO idx_templates_updated_at; -ALTER INDEX IF EXISTS idx_w_templates_created_at RENAME TO idx_templates_created_at; -ALTER INDEX IF EXISTS idx_w_templates_is_system RENAME TO idx_templates_is_system; -ALTER INDEX IF EXISTS idx_w_task_executions_created_at RENAME TO idx_task_executions_created_at; -ALTER INDEX IF EXISTS idx_w_task_executions_started_at RENAME TO idx_task_executions_started_at; -ALTER INDEX IF EXISTS idx_w_task_executions_status RENAME TO idx_task_executions_status; -ALTER INDEX IF EXISTS idx_w_task_executions_task_type RENAME TO idx_task_executions_task_type; -ALTER INDEX IF EXISTS idx_w_access_tokens_user_id RENAME TO idx_access_tokens_user_id; -ALTER INDEX IF EXISTS idx_w_uploads_type RENAME TO idx_uploads_type; -ALTER INDEX IF EXISTS idx_w_uploads_hash RENAME TO idx_uploads_hash; -ALTER INDEX IF EXISTS idx_w_uploads_file_path RENAME TO idx_uploads_file_path; -ALTER INDEX IF EXISTS idx_w_uploads_user_id RENAME TO idx_uploads_user_id; -ALTER INDEX IF EXISTS idx_w_external_accounts_source_external RENAME TO idx_external_accounts_source_external; -ALTER INDEX IF EXISTS idx_w_external_accounts_user_id RENAME TO idx_external_accounts_user_id; -ALTER INDEX IF EXISTS idx_w_external_accounts_auth_source_id RENAME TO idx_external_accounts_auth_source_id; -ALTER INDEX IF EXISTS idx_w_auth_sources_is_active RENAME TO idx_auth_sources_is_active; -ALTER INDEX IF EXISTS idx_w_users_created_at RENAME TO idx_users_created_at; -ALTER INDEX IF EXISTS idx_w_users_last_login_at RENAME TO idx_users_last_login_at; -ALTER INDEX IF EXISTS idx_w_users_is_active RENAME TO idx_users_is_active; -ALTER INDEX IF EXISTS idx_w_users_email RENAME TO idx_users_email; - -ALTER TABLE w_schedules RENAME TO schedules; -ALTER TABLE w_templates RENAME TO templates; -ALTER TABLE w_task_executions RENAME TO task_executions; -ALTER TABLE w_access_tokens RENAME TO access_tokens; -ALTER TABLE w_uploads RENAME TO uploads; -ALTER TABLE w_system_configs RENAME TO system_configs; -ALTER TABLE w_external_accounts RENAME TO external_accounts; -ALTER TABLE w_auth_sources RENAME TO auth_sources; -ALTER TABLE w_users RENAME TO users; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606110004_add_file_access_whitelist_config.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606110004_add_file_access_whitelist_config.sql deleted file mode 100644 index 20963f50..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606110004_add_file_access_whitelist_config.sql +++ /dev/null @@ -1,7 +0,0 @@ --- +goose Up -INSERT INTO w_system_configs (key, value, type, visibility, description, created_at, updated_at) -VALUES ('file_access_whitelist', '["avatar"]', 'system', 1, '免登录访问的文件业务类型白名单 (JSON 数组格式)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP) -ON CONFLICT (key) DO NOTHING; - --- +goose Down -DELETE FROM w_system_configs WHERE key = 'file_access_whitelist'; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606110005_add_disk_cache_configs.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606110005_add_disk_cache_configs.sql deleted file mode 100644 index 8a27b6a3..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606110005_add_disk_cache_configs.sql +++ /dev/null @@ -1,10 +0,0 @@ --- +goose Up -INSERT INTO w_system_configs (key, value, type, visibility, description, created_at, updated_at) -VALUES - ('disk_cache_max_size_mb', '100', 'system', 0, '磁盘缓存最大空间大小 (MB)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('disk_cache_ttl_minutes', '60', 'system', 0, '磁盘缓存默认有效期 (分钟)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('disk_cache_lru_enabled', 'true', 'system', 0, '是否启用 LRU 淘汰机制', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP) -ON CONFLICT (key) DO NOTHING; - --- +goose Down -DELETE FROM w_system_configs WHERE key IN ('disk_cache_max_size_mb', 'disk_cache_ttl_minutes', 'disk_cache_lru_enabled'); diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606120001_add_login_session_ttl_config.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606120001_add_login_session_ttl_config.sql deleted file mode 100644 index 4300c4c4..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606120001_add_login_session_ttl_config.sql +++ /dev/null @@ -1,8 +0,0 @@ --- +goose Up -INSERT INTO w_system_configs (key, value, type, visibility, description, created_at, updated_at) -VALUES - ('login_session_ttl_hours', '0', 'system', 0, '登录会话过期时间 (小时,0表示浏览器关闭后自动退出,-1表示永不过期)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP) -ON CONFLICT (key) DO NOTHING; - --- +goose Down -DELETE FROM w_system_configs WHERE key = 'login_session_ttl_hours'; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606120002_add_update_upstream_repository_config.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606120002_add_update_upstream_repository_config.sql deleted file mode 100644 index 8ddb1f8c..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606120002_add_update_upstream_repository_config.sql +++ /dev/null @@ -1,7 +0,0 @@ --- +goose Up -INSERT INTO w_system_configs (key, value, type, visibility, description, created_at, updated_at) -VALUES ('update_upstream_repository', 'Rain-kl/OpenFlare', 'system', 0, 'GitHub Actions Release 上游仓库(owner/repo 或 GitHub 仓库地址)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP) -ON CONFLICT (key) DO NOTHING; - --- +goose Down -DELETE FROM w_system_configs WHERE key = 'update_upstream_repository'; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606130001_add_upload_access_mode.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606130001_add_upload_access_mode.sql deleted file mode 100644 index f5f4120a..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606130001_add_upload_access_mode.sql +++ /dev/null @@ -1,6 +0,0 @@ --- +goose Up -ALTER TABLE w_uploads ADD COLUMN access_mode INTEGER NOT NULL DEFAULT 0; -UPDATE w_uploads SET access_mode = 1 WHERE type = 'avatar'; - --- +goose Down -ALTER TABLE w_uploads DROP COLUMN access_mode; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606130002_expand_system_config_value.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606130002_expand_system_config_value.sql deleted file mode 100644 index 0d806e27..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606130002_expand_system_config_value.sql +++ /dev/null @@ -1,5 +0,0 @@ --- +goose Up -ALTER TABLE w_system_configs ALTER COLUMN value TYPE TEXT; - --- +goose Down -ALTER TABLE w_system_configs ALTER COLUMN value TYPE VARCHAR(255); diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606130003_add_storage_config.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606130003_add_storage_config.sql deleted file mode 100644 index 4d49aa64..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606130003_add_storage_config.sql +++ /dev/null @@ -1,15 +0,0 @@ --- +goose Up -INSERT INTO w_system_configs (key, value, type, visibility, description, created_at, updated_at) -VALUES ( - 'storage_config', - '{"driver":"local","local":{"root":"."},"s3":{"region":"us-east-1"},"r2":{"region":"auto"},"minio":{"region":"us-east-1","path_style":true},"oss":{},"webdav":{}}', - 'system', - 0, - '文件存储驱动及连接配置(JSON)', - CURRENT_TIMESTAMP, - CURRENT_TIMESTAMP -) -ON CONFLICT (key) DO NOTHING; - --- +goose Down -DELETE FROM w_system_configs WHERE key = 'storage_config'; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606140001_create_push_tables.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606140001_create_push_tables.sql deleted file mode 100644 index 708073a3..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606140001_create_push_tables.sql +++ /dev/null @@ -1,34 +0,0 @@ --- +goose Up -CREATE TABLE w_push_events ( - id BIGSERIAL PRIMARY KEY, - event_key VARCHAR(80) NOT NULL UNIQUE, - name VARCHAR(100) NOT NULL, - channels TEXT NOT NULL, - targets TEXT NOT NULL, - template TEXT NOT NULL, - enabled BOOLEAN NOT NULL DEFAULT FALSE, - created_at TIMESTAMPTZ NOT NULL, - updated_at TIMESTAMPTZ NOT NULL -); - -CREATE INDEX idx_w_push_events_enabled ON w_push_events(enabled); - -CREATE TABLE w_push_histories ( - id BIGSERIAL PRIMARY KEY, - event_key VARCHAR(80) NOT NULL, - channel VARCHAR(50) NOT NULL, - target VARCHAR(255) NOT NULL, - title VARCHAR(255) NOT NULL, - content TEXT NOT NULL, - level VARCHAR(20) NOT NULL, - status VARCHAR(20) NOT NULL, - error_msg TEXT, - created_at TIMESTAMPTZ NOT NULL -); - -CREATE INDEX idx_w_push_histories_event ON w_push_histories(event_key); -CREATE INDEX idx_w_push_histories_created ON w_push_histories(created_at); - --- +goose Down -DROP TABLE IF EXISTS w_push_histories; -DROP TABLE IF EXISTS w_push_events; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606140003_add_system_user.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606140003_add_system_user.sql deleted file mode 100644 index a6b3f981..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606140003_add_system_user.sql +++ /dev/null @@ -1,8 +0,0 @@ --- +goose Up -INSERT INTO w_users (id, username, password, nickname, avatar_url, is_active, is_admin, last_login_at, created_at, updated_at) -VALUES (999, 'system', '*', '系统', '', TRUE, FALSE, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP) -ON CONFLICT (username) DO NOTHING; -SELECT setval(pg_get_serial_sequence('w_users', 'id'), COALESCE((SELECT MAX(id) FROM w_users), 1)); - --- +goose Down -DELETE FROM w_users WHERE username = 'system'; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606140004_create_push_channels.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606140004_create_push_channels.sql deleted file mode 100644 index 72371d86..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606140004_create_push_channels.sql +++ /dev/null @@ -1,19 +0,0 @@ --- +goose Up -CREATE TABLE w_push_channels ( - id BIGSERIAL PRIMARY KEY, - name VARCHAR(80) NOT NULL UNIQUE, - description VARCHAR(255), - type VARCHAR(50) NOT NULL DEFAULT 'custom', - token VARCHAR(100), - url TEXT NOT NULL, - other TEXT NOT NULL, - enabled BOOLEAN NOT NULL DEFAULT TRUE, - created_at TIMESTAMPTZ NOT NULL, - updated_at TIMESTAMPTZ NOT NULL -); - -CREATE INDEX idx_w_push_channels_name ON w_push_channels(name); -CREATE INDEX idx_w_push_channels_enabled ON w_push_channels(enabled); - --- +goose Down -DROP TABLE IF EXISTS w_push_channels; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606140005_update_system_cleanup_schedule.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606140005_update_system_cleanup_schedule.sql deleted file mode 100644 index f7965f22..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606140005_update_system_cleanup_schedule.sql +++ /dev/null @@ -1,11 +0,0 @@ --- +goose Up -UPDATE w_schedules -SET name = '系统定期垃圾清理', - task_type = 'system_cleanup' -WHERE id = 1; - --- +goose Down -UPDATE w_schedules -SET name = '清理未使用上传', - task_type = 'cleanup_unused_uploads' -WHERE id = 1; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606150001_add_task_type_to_push_events.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606150001_add_task_type_to_push_events.sql deleted file mode 100644 index eb27dae3..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606150001_add_task_type_to_push_events.sql +++ /dev/null @@ -1,7 +0,0 @@ --- +goose Up -ALTER TABLE w_push_events ADD COLUMN task_type VARCHAR(100) NOT NULL DEFAULT ''; -CREATE INDEX idx_w_push_events_task_type ON w_push_events(task_type); - --- +goose Down -DROP INDEX IF EXISTS idx_w_push_events_task_type; -ALTER TABLE w_push_events DROP COLUMN task_type; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606160001_remove_push_config.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606160001_remove_push_config.sql deleted file mode 100644 index d3214a00..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606160001_remove_push_config.sql +++ /dev/null @@ -1,6 +0,0 @@ --- +goose Up -DELETE FROM w_system_configs WHERE key = 'push_config'; -DELETE FROM w_push_events WHERE event_key = 'admin_login'; -DELETE FROM w_system_configs WHERE key = 'push_global_token'; - --- +goose Down diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606170001_add_upload_composite_indexes.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606170001_add_upload_composite_indexes.sql deleted file mode 100644 index 7d2f0e7d..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606170001_add_upload_composite_indexes.sql +++ /dev/null @@ -1,9 +0,0 @@ --- +goose Up -CREATE INDEX IF NOT EXISTS idx_w_uploads_status_created_at ON w_uploads (status, created_at); -CREATE INDEX IF NOT EXISTS idx_w_uploads_storage_driver_status ON w_uploads (storage_driver, status); -CREATE INDEX IF NOT EXISTS idx_w_uploads_hash_file_size_status ON w_uploads (hash, file_size, status); - --- +goose Down -DROP INDEX IF EXISTS idx_w_uploads_hash_file_size_status; -DROP INDEX IF EXISTS idx_w_uploads_storage_driver_status; -DROP INDEX IF EXISTS idx_w_uploads_status_created_at; \ No newline at end of file diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606170002_create_upload_stats_table.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606170002_create_upload_stats_table.sql deleted file mode 100644 index 332932ba..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606170002_create_upload_stats_table.sql +++ /dev/null @@ -1,12 +0,0 @@ --- +goose Up -CREATE TABLE IF NOT EXISTS 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 TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY (dimension, stat_key) -); - --- +goose Down -DROP TABLE IF EXISTS w_upload_stats; \ No newline at end of file diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606170003_backfill_upload_stats.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606170003_backfill_upload_stats.sql deleted file mode 100644 index 6e5bf473..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606170003_backfill_upload_stats.sql +++ /dev/null @@ -1,67 +0,0 @@ --- +goose Up -INSERT INTO w_upload_stats (dimension, stat_key, file_count, file_size) -SELECT 'total', '', COUNT(*), COALESCE(SUM(file_size), 0) -FROM w_uploads -WHERE status != 'deleted' -ON CONFLICT (dimension, stat_key) DO UPDATE SET - file_count = EXCLUDED.file_count, - file_size = EXCLUDED.file_size, - updated_at = CURRENT_TIMESTAMP; - -INSERT INTO w_upload_stats (dimension, stat_key, file_count, file_size) -SELECT - 'type', - COALESCE(NULLIF(type, ''), 'generic'), - COUNT(*), - COALESCE(SUM(file_size), 0) -FROM w_uploads -WHERE status != 'deleted' -GROUP BY COALESCE(NULLIF(type, ''), 'generic') -ON CONFLICT (dimension, stat_key) DO UPDATE SET - file_count = EXCLUDED.file_count, - file_size = EXCLUDED.file_size, - updated_at = CURRENT_TIMESTAMP; - -INSERT INTO w_upload_stats (dimension, stat_key, file_count, file_size) -SELECT - 'category', - CASE - WHEN LOWER(mime_type) LIKE 'image/%' - OR LOWER(extension) IN ('jpg', 'jpeg', 'png', 'webp', 'gif') THEN '图片' - WHEN LOWER(mime_type) LIKE 'video/%' THEN '视频' - WHEN LOWER(mime_type) LIKE 'audio/%' THEN '音频' - WHEN LOWER(extension) IN ('zip', 'rar', '7z', 'tar', 'gz', 'tgz', 'bz2', 'xz') - OR LOWER(mime_type) LIKE '%zip%' - OR LOWER(mime_type) LIKE '%tar%' - OR LOWER(mime_type) LIKE '%gzip%' THEN '压缩包' - WHEN LOWER(extension) IN ('pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'txt', 'md', 'csv', 'json', 'yaml', 'yml', 'xml') - OR LOWER(mime_type) LIKE 'text/%' - OR LOWER(mime_type) = 'application/pdf' THEN '文档' - ELSE '其他' - END, - COUNT(*), - COALESCE(SUM(file_size), 0) -FROM w_uploads -WHERE status != 'deleted' -GROUP BY 2 -ON CONFLICT (dimension, stat_key) DO UPDATE SET - file_count = EXCLUDED.file_count, - file_size = EXCLUDED.file_size, - updated_at = CURRENT_TIMESTAMP; - -INSERT INTO w_upload_stats (dimension, stat_key, file_count, file_size) -SELECT - 'trend', - TO_CHAR(created_at, 'YYYY-MM-DD'), - COUNT(*), - COALESCE(SUM(file_size), 0) -FROM w_uploads -WHERE status != 'deleted' -GROUP BY TO_CHAR(created_at, 'YYYY-MM-DD') -ON CONFLICT (dimension, stat_key) DO UPDATE SET - file_count = EXCLUDED.file_count, - file_size = EXCLUDED.file_size, - updated_at = CURRENT_TIMESTAMP; - --- +goose Down -DELETE FROM w_upload_stats; \ No newline at end of file diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606180001_drop_upload_storage_driver.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606180001_drop_upload_storage_driver.sql deleted file mode 100644 index 3ba6aa08..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606180001_drop_upload_storage_driver.sql +++ /dev/null @@ -1,7 +0,0 @@ --- +goose Up -DROP INDEX IF EXISTS idx_w_uploads_storage_driver_status; -ALTER TABLE w_uploads DROP COLUMN IF EXISTS storage_driver; - --- +goose Down -ALTER TABLE w_uploads ADD COLUMN IF NOT EXISTS storage_driver VARCHAR(50) NOT NULL DEFAULT 'local'; -CREATE INDEX IF NOT EXISTS idx_w_uploads_storage_driver_status ON w_uploads (storage_driver, status); \ No newline at end of file diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190001_create_of_options.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190001_create_of_options.sql deleted file mode 100644 index 93ef5e31..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190001_create_of_options.sql +++ /dev/null @@ -1,67 +0,0 @@ --- +goose Up -CREATE TABLE IF NOT EXISTS of_options ( - key VARCHAR(128) PRIMARY KEY, - value TEXT NOT NULL DEFAULT '' -); - -INSERT INTO of_options (key, value) VALUES - ('PasswordLoginEnabled', 'true'), - ('CapLoginEnabled', 'true'), - ('PasswordRegisterEnabled', 'false'), - ('EmailVerificationEnabled', 'false'), - ('GitHubOAuthEnabled', 'false'), - ('WeChatAuthEnabled', 'false'), - ('SMTPPort', '587'), - ('SystemName', 'OpenFlare'), - ('AgentHeartbeatInterval', '10000'), - ('AgentWebsocketUpgradeEnabled', 'true'), - ('NodeOfflineThreshold', '120000'), - ('AgentUpdateRepo', 'Rain-kl/OpenFlare'), - ('GeoIPProvider', 'ipinfo'), - ('DatabaseAutoCleanupEnabled', 'false'), - ('DatabaseAutoCleanupRetentionDays', '30'), - ('UptimeKumaEnabled', 'false'), - ('UptimeKumaMonitorScope', 'all'), - ('UptimeKumaSyncInterval', '5'), - ('UptimeKumaInterval', '60'), - ('UptimeKumaRetry', '0'), - ('UptimeKumaRetryInterval', '60'), - ('UptimeKumaTimeout', '48'), - ('OpenRestyDefaultServerReturnStatus', '421'), - ('OpenRestyWorkerProcesses', 'auto'), - ('OpenRestyWorkerConnections', '4096'), - ('OpenRestyWorkerRlimitNofile', '65535'), - ('OpenRestyEventsUse', 'epoll'), - ('OpenRestyEventsMultiAcceptEnabled', 'true'), - ('OpenRestyKeepaliveTimeout', '20'), - ('OpenRestyKeepaliveRequests', '1000'), - ('OpenRestyClientHeaderTimeout', '15'), - ('OpenRestyClientBodyTimeout', '15'), - ('OpenRestyClientMaxBodySize', '64m'), - ('OpenRestyLargeClientHeaderBuffers', '4 16k'), - ('OpenRestySendTimeout', '30'), - ('OpenRestyProxyConnectTimeout', '3'), - ('OpenRestyProxySendTimeout', '60'), - ('OpenRestyProxyReadTimeout', '60'), - ('OpenRestyWebsocketEnabled', 'true'), - ('OpenRestyHTTP3Enabled', 'true'), - ('OpenRestyProxyRequestBufferingEnabled', 'false'), - ('OpenRestyProxyBufferingEnabled', 'true'), - ('OpenRestyProxyBuffers', '16 16k'), - ('OpenRestyProxyBufferSize', '8k'), - ('OpenRestyProxyBusyBuffersSize', '64k'), - ('OpenRestyGzipEnabled', 'true'), - ('OpenRestyGzipMinLength', '1024'), - ('OpenRestyGzipCompLevel', '5'), - ('OpenRestyCacheEnabled', 'false'), - ('OpenRestyCacheLevels', '1:2'), - ('OpenRestyCacheInactive', '30m'), - ('OpenRestyCacheMaxSize', '1g'), - ('OpenRestyCacheKeyTemplate', '$scheme$host$request_uri'), - ('OpenRestyCacheLockEnabled', 'true'), - ('OpenRestyCacheLockTimeout', '5s'), - ('OpenRestyCacheUseStale', 'error timeout updating http_500 http_502 http_503 http_504') -ON CONFLICT (key) DO NOTHING; - --- +goose Down -DROP TABLE IF EXISTS of_options; \ No newline at end of file diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190002_create_of_origins.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190002_create_of_origins.sql deleted file mode 100644 index 14914d66..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190002_create_of_origins.sql +++ /dev/null @@ -1,13 +0,0 @@ --- +goose Up -CREATE TABLE IF NOT EXISTS of_origins ( - id BIGSERIAL PRIMARY KEY, - name VARCHAR(255) NOT NULL, - address VARCHAR(255) NOT NULL, - remark VARCHAR(255) NOT NULL DEFAULT '', - created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP -); -CREATE UNIQUE INDEX IF NOT EXISTS idx_of_origins_address ON of_origins (address); - --- +goose Down -DROP TABLE IF EXISTS of_origins; \ No newline at end of file diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190003_create_of_apply_logs.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190003_create_of_apply_logs.sql deleted file mode 100644 index 6cc983ab..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190003_create_of_apply_logs.sql +++ /dev/null @@ -1,19 +0,0 @@ --- +goose Up -CREATE TABLE of_apply_logs ( - id BIGSERIAL PRIMARY KEY, - node_id VARCHAR(64) NOT NULL, - version VARCHAR(32) NOT NULL, - result VARCHAR(32) NOT NULL, - message TEXT, - checksum VARCHAR(64) NOT NULL DEFAULT '', - main_config_checksum VARCHAR(64) NOT NULL DEFAULT '', - route_config_checksum VARCHAR(64) NOT NULL DEFAULT '', - support_file_count INTEGER NOT NULL DEFAULT 0, - created_at TIMESTAMPTZ NOT NULL -); - -CREATE INDEX idx_of_apply_logs_node_id ON of_apply_logs(node_id); -CREATE INDEX idx_of_apply_logs_created_at ON of_apply_logs(created_at); - --- +goose Down -DROP TABLE IF EXISTS of_apply_logs; \ No newline at end of file diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190004_create_of_proxy_routes.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190004_create_of_proxy_routes.sql deleted file mode 100644 index 3c49916c..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190004_create_of_proxy_routes.sql +++ /dev/null @@ -1,43 +0,0 @@ --- +goose Up -CREATE TABLE IF NOT EXISTS of_proxy_routes ( - id BIGSERIAL PRIMARY KEY, - site_name VARCHAR(255) NOT NULL DEFAULT '', - domain VARCHAR(255) NOT NULL, - domains TEXT NOT NULL DEFAULT '[]', - origin_id BIGINT, - origin_url VARCHAR(2048) NOT NULL, - origin_host VARCHAR(255) NOT NULL DEFAULT '', - upstreams TEXT NOT NULL DEFAULT '[]', - enabled BOOLEAN NOT NULL DEFAULT TRUE, - enable_https BOOLEAN NOT NULL DEFAULT FALSE, - cert_id BIGINT, - cert_ids TEXT NOT NULL DEFAULT '[]', - domain_cert_ids TEXT NOT NULL DEFAULT '[]', - redirect_http BOOLEAN NOT NULL DEFAULT FALSE, - limit_conn_per_server INTEGER NOT NULL DEFAULT 0, - limit_conn_per_ip INTEGER NOT NULL DEFAULT 0, - limit_rate VARCHAR(32) NOT NULL DEFAULT '', - cache_enabled BOOLEAN NOT NULL DEFAULT FALSE, - cache_policy VARCHAR(32) NOT NULL DEFAULT '', - cache_rules TEXT NOT NULL DEFAULT '[]', - custom_headers TEXT NOT NULL DEFAULT '[]', - basic_auth_enabled BOOLEAN NOT NULL DEFAULT FALSE, - basic_auth_username VARCHAR(255) NOT NULL DEFAULT '', - basic_auth_password VARCHAR(255) NOT NULL DEFAULT '', - remark VARCHAR(255) NOT NULL DEFAULT '', - upstream_type VARCHAR(32) NOT NULL DEFAULT 'direct', - tunnel_node_id BIGINT, - tunnel_target_addr VARCHAR(512) NOT NULL DEFAULT '', - tunnel_target_protocol VARCHAR(16) NOT NULL DEFAULT '', - pages_project_id BIGINT, - created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP -); -CREATE UNIQUE INDEX IF NOT EXISTS idx_of_proxy_routes_domain ON of_proxy_routes (domain); -CREATE UNIQUE INDEX IF NOT EXISTS idx_of_proxy_routes_site_name ON of_proxy_routes (site_name); -CREATE INDEX IF NOT EXISTS idx_of_proxy_routes_origin_id ON of_proxy_routes (origin_id); -CREATE INDEX IF NOT EXISTS idx_of_proxy_routes_tunnel_node_id ON of_proxy_routes (tunnel_node_id); -CREATE INDEX IF NOT EXISTS idx_of_proxy_routes_pages_project_id ON of_proxy_routes (pages_project_id); - --- +goose Down -DROP TABLE IF EXISTS of_proxy_routes; \ No newline at end of file diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190005_create_of_nodes.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190005_create_of_nodes.sql deleted file mode 100644 index ff43d62a..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190005_create_of_nodes.sql +++ /dev/null @@ -1,44 +0,0 @@ --- +goose Up -CREATE TABLE IF NOT EXISTS of_nodes ( - id BIGSERIAL PRIMARY KEY, - node_id VARCHAR(64) NOT NULL, - name VARCHAR(128) NOT NULL, - ip VARCHAR(64) NOT NULL DEFAULT '', - ip_manual_override BOOLEAN NOT NULL DEFAULT FALSE, - geo_name VARCHAR(128) NOT NULL DEFAULT '', - geo_latitude DOUBLE PRECISION, - geo_longitude DOUBLE PRECISION, - geo_manual_override BOOLEAN NOT NULL DEFAULT FALSE, - access_token VARCHAR(128) NOT NULL DEFAULT '', - auto_update_enabled BOOLEAN NOT NULL DEFAULT FALSE, - update_requested BOOLEAN NOT NULL DEFAULT FALSE, - update_channel VARCHAR(16) NOT NULL DEFAULT 'stable', - update_tag VARCHAR(64) NOT NULL DEFAULT '', - restart_openresty_requested BOOLEAN NOT NULL DEFAULT FALSE, - version VARCHAR(64) NOT NULL DEFAULT '', - ext_version VARCHAR(64) NOT NULL DEFAULT '', - openresty_status VARCHAR(16) NOT NULL DEFAULT 'unknown', - openresty_message TEXT, - status VARCHAR(16) NOT NULL DEFAULT 'offline', - current_version VARCHAR(32) NOT NULL DEFAULT '', - last_seen_at TIMESTAMPTZ, - last_error TEXT, - created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP, - node_type VARCHAR(32) 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 VARCHAR(128) NOT NULL DEFAULT '', - relay_agent_access_addr VARCHAR(255) NOT NULL DEFAULT '', - relay_client_access_addr VARCHAR(255) NOT NULL DEFAULT '', - relay_client_proxy_url VARCHAR(512) NOT NULL DEFAULT '', - capabilities_json TEXT NOT NULL DEFAULT '[]', - relay_status VARCHAR(16) NOT NULL DEFAULT 'unknown', - relay_web_server_enabled BOOLEAN NOT NULL DEFAULT FALSE -); - -CREATE UNIQUE INDEX IF NOT EXISTS idx_of_nodes_node_id ON of_nodes (node_id); -CREATE INDEX IF NOT EXISTS idx_of_nodes_access_token ON of_nodes (access_token); - --- +goose Down -DROP TABLE IF EXISTS of_nodes; \ No newline at end of file diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190006_create_of_waf_tables.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190006_create_of_waf_tables.sql deleted file mode 100644 index def71e73..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190006_create_of_waf_tables.sql +++ /dev/null @@ -1,60 +0,0 @@ --- +goose Up -CREATE TABLE IF NOT EXISTS of_waf_rule_groups ( - id BIGSERIAL PRIMARY KEY, - name VARCHAR(255) NOT NULL, - enabled BOOLEAN NOT NULL DEFAULT TRUE, - is_global BOOLEAN NOT NULL DEFAULT FALSE, - block_status_code INTEGER NOT NULL DEFAULT 418, - block_response_body TEXT NOT NULL DEFAULT '', - ip_whitelist TEXT NOT NULL DEFAULT '[]', - ip_blacklist TEXT NOT NULL DEFAULT '[]', - ip_whitelist_groups TEXT NOT NULL DEFAULT '[]', - ip_blacklist_groups TEXT NOT NULL DEFAULT '[]', - country_whitelist TEXT NOT NULL DEFAULT '[]', - country_blacklist TEXT NOT NULL DEFAULT '[]', - region_whitelist TEXT NOT NULL DEFAULT '[]', - region_blacklist TEXT NOT NULL DEFAULT '[]', - pow_enabled BOOLEAN NOT NULL DEFAULT FALSE, - pow_config TEXT NOT NULL DEFAULT '{}', - remark VARCHAR(255) NOT NULL DEFAULT '', - created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP -); -CREATE INDEX IF NOT EXISTS idx_of_waf_rule_groups_is_global ON of_waf_rule_groups (is_global); - -CREATE TABLE IF NOT EXISTS of_waf_ip_groups ( - id BIGSERIAL PRIMARY KEY, - name VARCHAR(255) NOT NULL, - type VARCHAR(32) 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 VARCHAR(2048) NOT NULL DEFAULT '', - subscription_format VARCHAR(32) NOT NULL DEFAULT 'text', - subscription_mapping_rule VARCHAR(255) NOT NULL DEFAULT '', - sync_interval_minutes INTEGER NOT NULL DEFAULT 1440, - last_synced_at TIMESTAMPTZ, - next_sync_at TIMESTAMPTZ, - last_sync_status VARCHAR(32) NOT NULL DEFAULT '', - last_sync_message TEXT NOT NULL DEFAULT '', - remark VARCHAR(255) NOT NULL DEFAULT '', - created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP -); -CREATE INDEX IF NOT EXISTS idx_of_waf_ip_groups_type ON of_waf_ip_groups (type); -CREATE INDEX IF NOT EXISTS idx_of_waf_ip_groups_next_sync_at ON of_waf_ip_groups (next_sync_at); - -CREATE TABLE IF NOT EXISTS of_waf_rule_group_bindings ( - id BIGSERIAL PRIMARY KEY, - rule_group_id BIGINT NOT NULL, - proxy_route_id BIGINT NOT NULL, - created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP -); -CREATE UNIQUE INDEX IF NOT EXISTS idx_of_waf_group_route ON of_waf_rule_group_bindings (rule_group_id, proxy_route_id); -CREATE INDEX IF NOT EXISTS idx_of_waf_rule_group_bindings_proxy_route_id ON of_waf_rule_group_bindings (proxy_route_id); - --- +goose Down -DROP TABLE IF EXISTS of_waf_rule_group_bindings; -DROP TABLE IF EXISTS of_waf_ip_groups; -DROP TABLE IF EXISTS of_waf_rule_groups; \ No newline at end of file diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190007_create_of_tls_tables.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190007_create_of_tls_tables.sql deleted file mode 100644 index 0683a5f6..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190007_create_of_tls_tables.sql +++ /dev/null @@ -1,61 +0,0 @@ --- +goose Up -CREATE TABLE IF NOT EXISTS of_tls_certificates ( - id BIGSERIAL PRIMARY KEY, - name VARCHAR(255) NOT NULL, - cert_pem TEXT NOT NULL, - key_pem TEXT NOT NULL, - not_before TIMESTAMPTZ, - not_after TIMESTAMPTZ, - remark VARCHAR(255) NOT NULL DEFAULT '', - provider VARCHAR(64) NOT NULL DEFAULT 'upload', - acme_account_id BIGINT NOT NULL DEFAULT 0, - dns_account_id BIGINT NOT NULL DEFAULT 0, - key_algorithm VARCHAR(32) NOT NULL DEFAULT '', - auto_renew BOOLEAN NOT NULL DEFAULT FALSE, - primary_domain VARCHAR(255) NOT NULL DEFAULT '', - other_domains TEXT NOT NULL DEFAULT '', - disable_cname BOOLEAN NOT NULL DEFAULT FALSE, - skip_dns BOOLEAN NOT NULL DEFAULT FALSE, - dns1 VARCHAR(128) NOT NULL DEFAULT '', - dns2 VARCHAR(128) NOT NULL DEFAULT '', - apply_status VARCHAR(64) NOT NULL DEFAULT 'ready', - apply_message TEXT NOT NULL DEFAULT '', - created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP -); -CREATE UNIQUE INDEX IF NOT EXISTS idx_of_tls_certificates_name ON of_tls_certificates (name); - -CREATE TABLE IF NOT EXISTS of_managed_domains ( - id BIGSERIAL PRIMARY KEY, - domain VARCHAR(255) NOT NULL, - cert_id BIGINT, - enabled BOOLEAN NOT NULL DEFAULT TRUE, - remark VARCHAR(255) NOT NULL DEFAULT '', - created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP -); -CREATE UNIQUE INDEX IF NOT EXISTS idx_of_managed_domains_domain ON of_managed_domains (domain); - -CREATE TABLE IF NOT EXISTS of_dns_accounts ( - id BIGSERIAL PRIMARY KEY, - name VARCHAR(255) NOT NULL, - type VARCHAR(64) NOT NULL, - "authorization" TEXT NOT NULL, - created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP -); - -CREATE TABLE IF NOT EXISTS of_acme_accounts ( - id BIGSERIAL PRIMARY KEY, - email VARCHAR(255) NOT NULL DEFAULT '', - url VARCHAR(255) NOT NULL DEFAULT '', - private_key TEXT NOT NULL DEFAULT '', - created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP -); - --- +goose Down -DROP TABLE IF EXISTS of_managed_domains; -DROP TABLE IF EXISTS of_tls_certificates; -DROP TABLE IF EXISTS of_dns_accounts; -DROP TABLE IF EXISTS of_acme_accounts; \ No newline at end of file diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190008_create_of_config_versions.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190008_create_of_config_versions.sql deleted file mode 100644 index e923ad06..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190008_create_of_config_versions.sql +++ /dev/null @@ -1,18 +0,0 @@ --- +goose Up -CREATE TABLE IF NOT EXISTS of_config_versions ( - id BIGSERIAL PRIMARY KEY, - version VARCHAR(32) NOT NULL, - 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 TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP -); -CREATE UNIQUE INDEX IF NOT EXISTS idx_of_config_versions_version ON of_config_versions (version); -CREATE INDEX IF NOT EXISTS idx_of_config_versions_is_active ON of_config_versions (is_active); - --- +goose Down -DROP TABLE IF EXISTS of_config_versions; \ No newline at end of file diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190009_create_of_pages_tables.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190009_create_of_pages_tables.sql deleted file mode 100644 index 030fafa2..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190009_create_of_pages_tables.sql +++ /dev/null @@ -1,53 +0,0 @@ --- +goose Up -CREATE TABLE IF NOT EXISTS of_pages_projects ( - id BIGSERIAL PRIMARY KEY, - name VARCHAR(255) NOT NULL, - slug VARCHAR(128) NOT NULL, - description TEXT NOT NULL DEFAULT '', - enabled BOOLEAN NOT NULL DEFAULT TRUE, - spa_fallback_enabled BOOLEAN NOT NULL DEFAULT FALSE, - spa_fallback_path VARCHAR(512) NOT NULL DEFAULT '/index.html', - api_proxy_enabled BOOLEAN NOT NULL DEFAULT FALSE, - api_proxy_path VARCHAR(255) NOT NULL DEFAULT '', - api_proxy_pass VARCHAR(2048) NOT NULL DEFAULT '', - api_proxy_rewrite VARCHAR(255) NOT NULL DEFAULT '', - active_deployment_id BIGINT, - root_dir VARCHAR(512) NOT NULL DEFAULT '', - entry_file VARCHAR(512) NOT NULL DEFAULT 'index.html', - created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP -); -CREATE UNIQUE INDEX IF NOT EXISTS idx_of_pages_projects_slug ON of_pages_projects (slug); -CREATE INDEX IF NOT EXISTS idx_of_pages_projects_active_deployment_id ON of_pages_projects (active_deployment_id); - -CREATE TABLE IF NOT EXISTS of_pages_deployments ( - id BIGSERIAL PRIMARY KEY, - project_id BIGINT NOT NULL, - deployment_number INTEGER NOT NULL, - checksum VARCHAR(64) NOT NULL, - status VARCHAR(32) NOT NULL DEFAULT 'uploaded', - artifact_path VARCHAR(2048) NOT NULL, - file_count INTEGER NOT NULL DEFAULT 0, - total_size BIGINT NOT NULL DEFAULT 0, - created_by VARCHAR(64) NOT NULL DEFAULT '', - created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP, - activated_at TIMESTAMPTZ -); -CREATE INDEX IF NOT EXISTS idx_of_pages_deployments_project_id ON of_pages_deployments (project_id); -CREATE INDEX IF NOT EXISTS idx_of_pages_deployments_checksum ON of_pages_deployments (checksum); -CREATE INDEX IF NOT EXISTS idx_of_pages_deployments_status ON of_pages_deployments (status); - -CREATE TABLE IF NOT EXISTS of_pages_deployment_files ( - id BIGSERIAL PRIMARY KEY, - deployment_id BIGINT NOT NULL, - path VARCHAR(2048) NOT NULL, - size BIGINT NOT NULL DEFAULT 0, - checksum VARCHAR(64) NOT NULL, - created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP -); -CREATE INDEX IF NOT EXISTS idx_of_pages_deployment_files_deployment_id ON of_pages_deployment_files (deployment_id); - --- +goose Down -DROP TABLE IF EXISTS of_pages_deployment_files; -DROP TABLE IF EXISTS of_pages_deployments; -DROP TABLE IF EXISTS of_pages_projects; \ No newline at end of file diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190010_create_of_observability_tables.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190010_create_of_observability_tables.sql deleted file mode 100644 index 24d22a19..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190010_create_of_observability_tables.sql +++ /dev/null @@ -1,136 +0,0 @@ --- +goose Up -CREATE TABLE of_node_system_profiles ( - id BIGSERIAL PRIMARY KEY, - node_id VARCHAR(64) NOT NULL, - hostname VARCHAR(255) NOT NULL DEFAULT '', - os_name VARCHAR(128) NOT NULL DEFAULT '', - os_version VARCHAR(128) NOT NULL DEFAULT '', - kernel_version VARCHAR(128) NOT NULL DEFAULT '', - architecture VARCHAR(64) NOT NULL DEFAULT '', - cpu_model VARCHAR(255) NOT NULL DEFAULT '', - cpu_cores INTEGER NOT NULL DEFAULT 0, - total_memory_bytes BIGINT NOT NULL DEFAULT 0, - total_disk_bytes BIGINT NOT NULL DEFAULT 0, - uptime_seconds BIGINT NOT NULL DEFAULT 0, - reported_at TIMESTAMPTZ NOT NULL, - created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP -); - -CREATE UNIQUE INDEX idx_of_node_system_profiles_node_id ON of_node_system_profiles (node_id); -CREATE INDEX idx_of_node_system_profiles_reported_at ON of_node_system_profiles (reported_at); - -CREATE TABLE of_node_metric_snapshots ( - id BIGSERIAL PRIMARY KEY, - node_id VARCHAR(64) NOT NULL, - captured_at TIMESTAMPTZ NOT NULL, - cpu_usage_percent DOUBLE PRECISION NOT NULL DEFAULT 0, - memory_used_bytes BIGINT NOT NULL DEFAULT 0, - memory_total_bytes BIGINT NOT NULL DEFAULT 0, - storage_used_bytes BIGINT NOT NULL DEFAULT 0, - storage_total_bytes BIGINT NOT NULL DEFAULT 0, - disk_read_bytes BIGINT NOT NULL DEFAULT 0, - disk_write_bytes BIGINT NOT NULL DEFAULT 0, - network_rx_bytes BIGINT NOT NULL DEFAULT 0, - network_tx_bytes BIGINT NOT NULL DEFAULT 0, - created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP -); - -CREATE INDEX idx_of_node_metric_snapshots_node_id ON of_node_metric_snapshots (node_id); -CREATE INDEX idx_of_node_metric_snapshots_captured_at ON of_node_metric_snapshots (captured_at); - -CREATE TABLE of_node_request_reports ( - id BIGSERIAL PRIMARY KEY, - node_id VARCHAR(64) NOT NULL, - window_started_at TIMESTAMPTZ NOT NULL, - window_ended_at TIMESTAMPTZ NOT NULL, - request_count BIGINT NOT NULL DEFAULT 0, - error_count BIGINT NOT NULL DEFAULT 0, - unique_visitor_count BIGINT NOT NULL DEFAULT 0, - status_codes_json TEXT, - top_domains_json TEXT, - source_countries_json TEXT, - created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP -); - -CREATE INDEX idx_of_node_request_reports_node_id ON of_node_request_reports (node_id); -CREATE INDEX idx_of_node_request_reports_window_started_at ON of_node_request_reports (window_started_at); -CREATE INDEX idx_of_node_request_reports_window_ended_at ON of_node_request_reports (window_ended_at); - -CREATE TABLE of_node_health_events ( - id BIGSERIAL PRIMARY KEY, - node_id VARCHAR(64) NOT NULL, - event_type VARCHAR(64) NOT NULL, - severity VARCHAR(16) NOT NULL, - status VARCHAR(16) NOT NULL, - message TEXT, - first_triggered_at TIMESTAMPTZ NOT NULL, - last_triggered_at TIMESTAMPTZ NOT NULL, - reported_at TIMESTAMPTZ NOT NULL, - resolved_at TIMESTAMPTZ, - metadata_json TEXT, - created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP -); - -CREATE INDEX idx_of_node_health_events_node_id ON of_node_health_events (node_id); -CREATE INDEX idx_of_node_health_events_event_type ON of_node_health_events (event_type); -CREATE INDEX idx_of_node_health_events_status ON of_node_health_events (status); -CREATE INDEX idx_of_node_health_events_first_triggered_at ON of_node_health_events (first_triggered_at); -CREATE INDEX idx_of_node_health_events_last_triggered_at ON of_node_health_events (last_triggered_at); -CREATE INDEX idx_of_node_health_events_reported_at ON of_node_health_events (reported_at); -CREATE INDEX idx_of_node_health_events_resolved_at ON of_node_health_events (resolved_at); - -CREATE TABLE of_node_obs_openresty ( - id BIGSERIAL PRIMARY KEY, - node_id VARCHAR(64) NOT NULL, - captured_at TIMESTAMPTZ NOT NULL, - openresty_rx_bytes BIGINT NOT NULL DEFAULT 0, - openresty_tx_bytes BIGINT NOT NULL DEFAULT 0, - openresty_connections BIGINT NOT NULL DEFAULT 0, - created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP -); - -CREATE INDEX idx_of_node_obs_openresty_node_id ON of_node_obs_openresty (node_id); -CREATE INDEX idx_of_node_obs_openresty_captured_at ON of_node_obs_openresty (captured_at); - -CREATE TABLE of_node_obs_frps ( - id BIGSERIAL PRIMARY KEY, - node_id VARCHAR(64) NOT NULL, - captured_at TIMESTAMPTZ 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, - created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP -); - -CREATE INDEX idx_of_node_obs_frps_node_id ON of_node_obs_frps (node_id); -CREATE INDEX idx_of_node_obs_frps_captured_at ON of_node_obs_frps (captured_at); - -CREATE TABLE of_node_access_logs ( - id BIGSERIAL PRIMARY KEY, - node_id VARCHAR(64) NOT NULL, - logged_at TIMESTAMPTZ NOT NULL, - remote_addr VARCHAR(128) NOT NULL DEFAULT '', - region VARCHAR(128) NOT NULL DEFAULT '', - host VARCHAR(255) NOT NULL DEFAULT '', - path VARCHAR(2048) NOT NULL DEFAULT '', - status_code INTEGER NOT NULL DEFAULT 0, - created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP -); - -CREATE INDEX idx_of_node_access_logs_node_id ON of_node_access_logs (node_id); -CREATE INDEX idx_of_node_access_logs_logged_at ON of_node_access_logs (logged_at); -CREATE INDEX idx_of_node_access_logs_remote_addr ON of_node_access_logs (remote_addr); -CREATE INDEX idx_of_node_access_logs_host ON of_node_access_logs (host); -CREATE INDEX idx_of_node_access_logs_status_code ON of_node_access_logs (status_code); - --- +goose Down -DROP TABLE IF EXISTS of_node_access_logs; -DROP TABLE IF EXISTS of_node_obs_frps; -DROP TABLE IF EXISTS of_node_obs_openresty; -DROP TABLE IF EXISTS of_node_health_events; -DROP TABLE IF EXISTS of_node_request_reports; -DROP TABLE IF EXISTS of_node_metric_snapshots; -DROP TABLE IF EXISTS of_node_system_profiles; \ No newline at end of file diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190011_add_of_node_access_logs_composite_index.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190011_add_of_node_access_logs_composite_index.sql deleted file mode 100644 index a478ae9d..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190011_add_of_node_access_logs_composite_index.sql +++ /dev/null @@ -1,5 +0,0 @@ --- +goose Up -CREATE INDEX IF NOT EXISTS idx_of_node_access_logs_node_id_logged_at ON of_node_access_logs (node_id, logged_at); - --- +goose Down -DROP INDEX IF EXISTS idx_of_node_access_logs_node_id_logged_at; \ No newline at end of file diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190012_create_of_node_obs_frpc.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190012_create_of_node_obs_frpc.sql deleted file mode 100644 index a98437ac..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190012_create_of_node_obs_frpc.sql +++ /dev/null @@ -1,15 +0,0 @@ --- +goose Up -CREATE TABLE of_node_obs_frpc ( - id BIGSERIAL PRIMARY KEY, - node_id VARCHAR(64) NOT NULL, - captured_at TIMESTAMPTZ NOT NULL, - tunnel_status VARCHAR(16) NOT NULL DEFAULT '', - connected_relays_count INTEGER NOT NULL DEFAULT 0, - created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP -); - -CREATE INDEX idx_of_node_obs_frpc_node_id ON of_node_obs_frpc (node_id); -CREATE INDEX idx_of_node_obs_frpc_captured_at ON of_node_obs_frpc (captured_at); - --- +goose Down -DROP TABLE IF EXISTS of_node_obs_frpc; \ No newline at end of file diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190013_seed_openflare_schedules.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190013_seed_openflare_schedules.sql deleted file mode 100644 index 1a47e19d..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190013_seed_openflare_schedules.sql +++ /dev/null @@ -1,11 +0,0 @@ --- +goose Up -INSERT INTO w_schedules (id, name, task_type, cron, payload, is_active, created_at, updated_at) -VALUES - (101, 'OpenFlare SSL 自动续期', 'of_ssl_renew', '0 0 * * *', '{}', TRUE, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - (102, 'OpenFlare 可观测数据自动清理', 'of_database_auto_cleanup', '0 3 * * *', '{}', TRUE, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - (103, 'OpenFlare WAF IP 组同步', 'of_waf_ip_group_sync', '*/5 * * * *', '{}', TRUE, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - (104, 'OpenFlare Uptime Kuma 同步', 'of_uptime_kuma_sync', '* * * * *', '{}', TRUE, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP) -ON CONFLICT (id) DO NOTHING; - --- +goose Down -DELETE FROM w_schedules WHERE id IN (101, 102, 103, 104); \ No newline at end of file diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190014_add_pages_deployment_upload_id.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190014_add_pages_deployment_upload_id.sql deleted file mode 100644 index 8e791795..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606190014_add_pages_deployment_upload_id.sql +++ /dev/null @@ -1,14 +0,0 @@ --- +goose Up -ALTER TABLE of_pages_deployments - ADD COLUMN IF NOT EXISTS upload_id BIGINT NOT NULL DEFAULT 0; - -CREATE INDEX IF NOT EXISTS idx_of_pages_deployments_upload_id ON of_pages_deployments (upload_id); - -ALTER TABLE of_pages_deployments - ALTER COLUMN artifact_path SET DEFAULT ''; - --- +goose Down -DROP INDEX IF EXISTS idx_of_pages_deployments_upload_id; - -ALTER TABLE of_pages_deployments - DROP COLUMN IF EXISTS upload_id; \ No newline at end of file diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606200001_rebrand_openflare_defaults.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606200001_rebrand_openflare_defaults.sql deleted file mode 100644 index 1de73272..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606200001_rebrand_openflare_defaults.sql +++ /dev/null @@ -1,31 +0,0 @@ --- +goose Up -UPDATE w_system_configs -SET value = 'OpenFlare', updated_at = CURRENT_TIMESTAMP -WHERE key = 'site_name' AND value = 'Wavelet'; - -UPDATE w_system_configs -SET value = 'Rain-kl/OpenFlare', updated_at = CURRENT_TIMESTAMP -WHERE key = 'update_upstream_repository' AND value = 'Rain-kl/Wavelet'; - -UPDATE w_templates -SET - subject = REPLACE(subject, 'Wavelet', 'OpenFlare'), - content = REPLACE(content, 'Wavelet', 'OpenFlare'), - updated_at = CURRENT_TIMESTAMP -WHERE key IN ('login_email', 'register_email'); - --- +goose Down -UPDATE w_system_configs -SET value = 'Wavelet', updated_at = CURRENT_TIMESTAMP -WHERE key = 'site_name' AND value = 'OpenFlare'; - -UPDATE w_system_configs -SET value = 'Rain-kl/Wavelet', updated_at = CURRENT_TIMESTAMP -WHERE key = 'update_upstream_repository' AND value = 'Rain-kl/OpenFlare'; - -UPDATE w_templates -SET - subject = REPLACE(subject, 'OpenFlare', 'Wavelet'), - content = REPLACE(content, 'OpenFlare', 'Wavelet'), - updated_at = CURRENT_TIMESTAMP -WHERE key IN ('login_email', 'register_email'); \ No newline at end of file diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606200002_update_security_defaults.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606200002_update_security_defaults.sql deleted file mode 100644 index 68484a8b..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606200002_update_security_defaults.sql +++ /dev/null @@ -1,17 +0,0 @@ --- +goose Up -UPDATE w_system_configs -SET value = 'false', updated_at = CURRENT_TIMESTAMP -WHERE key = 'registration_enabled' AND value = 'true'; - -UPDATE w_system_configs -SET value = 'false', updated_at = CURRENT_TIMESTAMP -WHERE key = 'password_register_enabled' AND value = 'true'; - --- +goose Down -UPDATE w_system_configs -SET value = 'true', updated_at = CURRENT_TIMESTAMP -WHERE key = 'registration_enabled' AND value = 'false'; - -UPDATE w_system_configs -SET value = 'true', updated_at = CURRENT_TIMESTAMP -WHERE key = 'password_register_enabled' AND value = 'false'; \ No newline at end of file diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606200003_remove_legacy_rate_limit_options.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606200003_remove_legacy_rate_limit_options.sql deleted file mode 100644 index 0a813478..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606200003_remove_legacy_rate_limit_options.sql +++ /dev/null @@ -1,20 +0,0 @@ --- +goose Up -DELETE FROM of_options -WHERE key IN ( - 'GlobalApiRateLimitNum', - 'GlobalApiRateLimitDuration', - 'GlobalWebRateLimitNum', - 'GlobalWebRateLimitDuration', - 'CriticalRateLimitNum', - 'CriticalRateLimitDuration' -); - --- +goose Down -INSERT INTO of_options (key, value) VALUES - ('GlobalApiRateLimitNum', '300'), - ('GlobalApiRateLimitDuration', '180'), - ('GlobalWebRateLimitNum', '300'), - ('GlobalWebRateLimitDuration', '180'), - ('CriticalRateLimitNum', '100'), - ('CriticalRateLimitDuration', '1200') -ON CONFLICT (key) DO NOTHING; \ No newline at end of file diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606200004_drop_of_node_access_logs.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606200004_drop_of_node_access_logs.sql deleted file mode 100644 index aafeeebe..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606200004_drop_of_node_access_logs.sql +++ /dev/null @@ -1,28 +0,0 @@ --- +goose Up -DROP INDEX IF EXISTS idx_of_node_access_logs_node_id_logged_at; -DROP INDEX IF EXISTS idx_of_node_access_logs_status_code; -DROP INDEX IF EXISTS idx_of_node_access_logs_host; -DROP INDEX IF EXISTS idx_of_node_access_logs_remote_addr; -DROP INDEX IF EXISTS idx_of_node_access_logs_logged_at; -DROP INDEX IF EXISTS idx_of_node_access_logs_node_id; -DROP TABLE IF EXISTS of_node_access_logs; - --- +goose Down -CREATE TABLE of_node_access_logs ( - id BIGSERIAL PRIMARY KEY, - node_id VARCHAR(64) NOT NULL, - logged_at TIMESTAMPTZ NOT NULL, - remote_addr VARCHAR(128) NOT NULL DEFAULT '', - region VARCHAR(128) NOT NULL DEFAULT '', - host VARCHAR(255) NOT NULL DEFAULT '', - path VARCHAR(2048) NOT NULL DEFAULT '', - status_code INTEGER NOT NULL DEFAULT 0, - created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP -); - -CREATE INDEX idx_of_node_access_logs_node_id ON of_node_access_logs (node_id); -CREATE INDEX idx_of_node_access_logs_logged_at ON of_node_access_logs (logged_at); -CREATE INDEX idx_of_node_access_logs_remote_addr ON of_node_access_logs (remote_addr); -CREATE INDEX idx_of_node_access_logs_host ON of_node_access_logs (host); -CREATE INDEX idx_of_node_access_logs_status_code ON of_node_access_logs (status_code); -CREATE INDEX idx_of_node_access_logs_node_id_logged_at ON of_node_access_logs (node_id, logged_at); \ No newline at end of file diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606200005_drop_of_node_observability_timeseries.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606200005_drop_of_node_observability_timeseries.sql deleted file mode 100644 index 0309fe57..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606200005_drop_of_node_observability_timeseries.sql +++ /dev/null @@ -1,98 +0,0 @@ --- +goose Up -DROP INDEX IF EXISTS idx_of_node_obs_frpc_captured_at; -DROP INDEX IF EXISTS idx_of_node_obs_frpc_node_id; -DROP TABLE IF EXISTS of_node_obs_frpc; - -DROP INDEX IF EXISTS idx_of_node_obs_frps_captured_at; -DROP INDEX IF EXISTS idx_of_node_obs_frps_node_id; -DROP TABLE IF EXISTS of_node_obs_frps; - -DROP INDEX IF EXISTS idx_of_node_obs_openresty_captured_at; -DROP INDEX IF EXISTS idx_of_node_obs_openresty_node_id; -DROP TABLE IF EXISTS of_node_obs_openresty; - -DROP INDEX IF EXISTS idx_of_node_request_reports_window_ended_at; -DROP INDEX IF EXISTS idx_of_node_request_reports_window_started_at; -DROP INDEX IF EXISTS idx_of_node_request_reports_node_id; -DROP TABLE IF EXISTS of_node_request_reports; - -DROP INDEX IF EXISTS idx_of_node_metric_snapshots_captured_at; -DROP INDEX IF EXISTS idx_of_node_metric_snapshots_node_id; -DROP TABLE IF EXISTS of_node_metric_snapshots; - --- +goose Down -CREATE TABLE of_node_metric_snapshots ( - id BIGSERIAL PRIMARY KEY, - node_id VARCHAR(64) NOT NULL, - captured_at TIMESTAMPTZ NOT NULL, - cpu_usage_percent DOUBLE PRECISION NOT NULL DEFAULT 0, - memory_used_bytes BIGINT NOT NULL DEFAULT 0, - memory_total_bytes BIGINT NOT NULL DEFAULT 0, - storage_used_bytes BIGINT NOT NULL DEFAULT 0, - storage_total_bytes BIGINT NOT NULL DEFAULT 0, - disk_read_bytes BIGINT NOT NULL DEFAULT 0, - disk_write_bytes BIGINT NOT NULL DEFAULT 0, - network_rx_bytes BIGINT NOT NULL DEFAULT 0, - network_tx_bytes BIGINT NOT NULL DEFAULT 0, - created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP -); - -CREATE INDEX idx_of_node_metric_snapshots_node_id ON of_node_metric_snapshots (node_id); -CREATE INDEX idx_of_node_metric_snapshots_captured_at ON of_node_metric_snapshots (captured_at); - -CREATE TABLE of_node_request_reports ( - id BIGSERIAL PRIMARY KEY, - node_id VARCHAR(64) NOT NULL, - window_started_at TIMESTAMPTZ NOT NULL, - window_ended_at TIMESTAMPTZ NOT NULL, - request_count BIGINT NOT NULL DEFAULT 0, - error_count BIGINT NOT NULL DEFAULT 0, - unique_visitor_count BIGINT NOT NULL DEFAULT 0, - status_codes_json TEXT, - top_domains_json TEXT, - source_countries_json TEXT, - created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP -); - -CREATE INDEX idx_of_node_request_reports_node_id ON of_node_request_reports (node_id); -CREATE INDEX idx_of_node_request_reports_window_started_at ON of_node_request_reports (window_started_at); -CREATE INDEX idx_of_node_request_reports_window_ended_at ON of_node_request_reports (window_ended_at); - -CREATE TABLE of_node_obs_openresty ( - id BIGSERIAL PRIMARY KEY, - node_id VARCHAR(64) NOT NULL, - captured_at TIMESTAMPTZ NOT NULL, - openresty_rx_bytes BIGINT NOT NULL DEFAULT 0, - openresty_tx_bytes BIGINT NOT NULL DEFAULT 0, - openresty_connections BIGINT NOT NULL DEFAULT 0, - created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP -); - -CREATE INDEX idx_of_node_obs_openresty_node_id ON of_node_obs_openresty (node_id); -CREATE INDEX idx_of_node_obs_openresty_captured_at ON of_node_obs_openresty (captured_at); - -CREATE TABLE of_node_obs_frps ( - id BIGSERIAL PRIMARY KEY, - node_id VARCHAR(64) NOT NULL, - captured_at TIMESTAMPTZ 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, - created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP -); - -CREATE INDEX idx_of_node_obs_frps_node_id ON of_node_obs_frps (node_id); -CREATE INDEX idx_of_node_obs_frps_captured_at ON of_node_obs_frps (captured_at); - -CREATE TABLE of_node_obs_frpc ( - id BIGSERIAL PRIMARY KEY, - node_id VARCHAR(64) NOT NULL, - captured_at TIMESTAMPTZ NOT NULL, - tunnel_status VARCHAR(16) NOT NULL DEFAULT '', - connected_relays_count INTEGER NOT NULL DEFAULT 0, - created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP -); - -CREATE INDEX idx_of_node_obs_frpc_node_id ON of_node_obs_frpc (node_id); -CREATE INDEX idx_of_node_obs_frpc_captured_at ON of_node_obs_frpc (captured_at); \ No newline at end of file diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606200006_migrate_legacy_data.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606200006_migrate_legacy_data.sql deleted file mode 100644 index 9840f6cd..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606200006_migrate_legacy_data.sql +++ /dev/null @@ -1,7 +0,0 @@ --- +goose Up --- Historical copy from legacy_* tables into of_* / w_* (formerly Go migration). --- Already-applied environments keep their data; new installs have no legacy_* sources. -SELECT 1; - --- +goose Down -SELECT 1; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606200007_sync_of_waf_binding_sequence.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606200007_sync_of_waf_binding_sequence.sql deleted file mode 100644 index 3ff439a5..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606200007_sync_of_waf_binding_sequence.sql +++ /dev/null @@ -1,9 +0,0 @@ --- +goose Up -SELECT setval( - pg_get_serial_sequence('of_waf_rule_group_bindings', 'id'), - GREATEST(COALESCE((SELECT MAX(id) FROM of_waf_rule_group_bindings), 0), 1), - COALESCE((SELECT MAX(id) FROM of_waf_rule_group_bindings), 0) > 0 -); - --- +goose Down -SELECT 1; \ No newline at end of file diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606220001_remove_legacy_auth_options.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606220001_remove_legacy_auth_options.sql deleted file mode 100644 index 0655cb00..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606220001_remove_legacy_auth_options.sql +++ /dev/null @@ -1,22 +0,0 @@ --- +goose Up -DELETE FROM of_options -WHERE key IN ( - 'GitHubOAuthEnabled', - 'GitHubClientId', - 'GitHubClientSecret', - 'WeChatAuthEnabled', - 'WeChatServerAddress', - 'WeChatServerToken', - 'WeChatAccountQRCodeImageURL' -); - --- +goose Down -INSERT INTO of_options (key, value) VALUES - ('GitHubOAuthEnabled', 'false'), - ('GitHubClientId', ''), - ('GitHubClientSecret', ''), - ('WeChatAuthEnabled', 'false'), - ('WeChatServerAddress', ''), - ('WeChatServerToken', ''), - ('WeChatAccountQRCodeImageURL', '') -ON CONFLICT (key) DO NOTHING; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606220002_remove_notice_option.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606220002_remove_notice_option.sql deleted file mode 100644 index 8ac27973..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606220002_remove_notice_option.sql +++ /dev/null @@ -1,5 +0,0 @@ --- +goose Up -DELETE FROM of_options WHERE key = 'Notice'; - --- +goose Down -INSERT OR IGNORE INTO of_options (key, value) VALUES ('Notice', ''); diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606220003_add_frps_web_ui_config.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606220003_add_frps_web_ui_config.sql deleted file mode 100644 index e4b2db58..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606220003_add_frps_web_ui_config.sql +++ /dev/null @@ -1,9 +0,0 @@ --- +goose Up -INSERT INTO w_system_configs (key, value, type, visibility, description, created_at, updated_at) -VALUES - ('relay_frps_web_ui_enabled', 'false', 'business', 0, '是否启用 FRPS 内置 Web 管理界面', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('relay_frps_web_ui_port', '17500', 'business', 0, 'FRPS 内置 Web 管理界面端口', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP) -ON CONFLICT (key) DO NOTHING; - --- +goose Down -DELETE FROM w_system_configs WHERE key IN ('relay_frps_web_ui_enabled', 'relay_frps_web_ui_port'); diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606220004_migrate_of_options_to_system_configs.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606220004_migrate_of_options_to_system_configs.sql deleted file mode 100644 index 9d660bfb..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606220004_migrate_of_options_to_system_configs.sql +++ /dev/null @@ -1,347 +0,0 @@ --- +goose Up --- 将 of_options 配置迁移到 w_system_configs(仅迁移新配置,已存在的不重复) - --- Agent 相关配置 (business, visibility=0) -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'agent_discovery_token', COALESCE(value, ''), 'business', 0, 'Agent 发现令牌' -FROM of_options WHERE key = 'AgentDiscoveryToken' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'agent_heartbeat_interval', value, 'business', 0, 'Agent 心跳间隔(毫秒)' -FROM of_options WHERE key = 'AgentHeartbeatInterval' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'agent_websocket_upgrade_enabled', value, 'business', 0, 'Agent WebSocket 升级开关' -FROM of_options WHERE key = 'AgentWebsocketUpgradeEnabled' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'node_offline_threshold', value, 'business', 0, '节点离线阈值(毫秒)' -FROM of_options WHERE key = 'NodeOfflineThreshold' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'agent_update_repo', value, 'business', 0, 'Agent 更新仓库' -FROM of_options WHERE key = 'AgentUpdateRepo' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - --- 系统功能配置 (business, visibility=0) -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'geoip_provider', value, 'business', 0, 'GeoIP 服务商' -FROM of_options WHERE key = 'GeoIPProvider' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'database_auto_cleanup_enabled', value, 'business', 0, '数据库自动清理开关' -FROM of_options WHERE key = 'DatabaseAutoCleanupEnabled' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'database_auto_cleanup_retention_days', value, 'business', 0, '数据库保留天数' -FROM of_options WHERE key = 'DatabaseAutoCleanupRetentionDays' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - --- UptimeKuma 集成配置 (business, visibility=0) -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'uptime_kuma_enabled', value, 'business', 0, 'UptimeKuma 集成开关' -FROM of_options WHERE key = 'UptimeKumaEnabled' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'uptime_kuma_url', COALESCE(value, ''), 'business', 0, 'UptimeKuma URL' -FROM of_options WHERE key = 'UptimeKumaUrl' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'uptime_kuma_username', COALESCE(value, ''), 'business', 0, 'UptimeKuma 用户名' -FROM of_options WHERE key = 'UptimeKumaUsername' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'uptime_kuma_password', COALESCE(value, ''), 'business', 0, 'UptimeKuma 密码' -FROM of_options WHERE key = 'UptimeKumaPassword' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'uptime_kuma_monitor_scope', value, 'business', 0, 'UptimeKuma 监控范围' -FROM of_options WHERE key = 'UptimeKumaMonitorScope' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'uptime_kuma_selected_sites', COALESCE(value, ''), 'business', 0, 'UptimeKuma 选定站点' -FROM of_options WHERE key = 'UptimeKumaSelectedSites' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'uptime_kuma_sync_interval', value, 'business', 0, 'UptimeKuma 同步间隔(分钟)' -FROM of_options WHERE key = 'UptimeKumaSyncInterval' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'uptime_kuma_interval', value, 'business', 0, 'UptimeKuma 监控间隔(秒)' -FROM of_options WHERE key = 'UptimeKumaInterval' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'uptime_kuma_retry', value, 'business', 0, 'UptimeKuma 重试次数' -FROM of_options WHERE key = 'UptimeKumaRetry' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'uptime_kuma_retry_interval', value, 'business', 0, 'UptimeKuma 重试间隔(秒)' -FROM of_options WHERE key = 'UptimeKumaRetryInterval' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'uptime_kuma_timeout', value, 'business', 0, 'UptimeKuma 超时(秒)' -FROM of_options WHERE key = 'UptimeKumaTimeout' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - --- OpenResty 配置(全部 business 类型,visibility=0) -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_default_server_return_status', value, 'business', 0, '默认服务器返回状态码' -FROM of_options WHERE key = 'OpenRestyDefaultServerReturnStatus' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_worker_processes', value, 'business', 0, 'Worker 进程数' -FROM of_options WHERE key = 'OpenRestyWorkerProcesses' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_worker_connections', value, 'business', 0, 'Worker 连接数' -FROM of_options WHERE key = 'OpenRestyWorkerConnections' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_worker_rlimit_nofile', value, 'business', 0, 'Worker 文件描述符限制' -FROM of_options WHERE key = 'OpenRestyWorkerRlimitNofile' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_events_use', value, 'business', 0, '事件模型' -FROM of_options WHERE key = 'OpenRestyEventsUse' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_events_multi_accept_enabled', value, 'business', 0, '多路接受开关' -FROM of_options WHERE key = 'OpenRestyEventsMultiAcceptEnabled' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_keepalive_timeout', value, 'business', 0, 'Keepalive 超时(秒)' -FROM of_options WHERE key = 'OpenRestyKeepaliveTimeout' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_keepalive_requests', value, 'business', 0, 'Keepalive 请求数' -FROM of_options WHERE key = 'OpenRestyKeepaliveRequests' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_client_header_timeout', value, 'business', 0, '客户端头超时(秒)' -FROM of_options WHERE key = 'OpenRestyClientHeaderTimeout' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_client_body_timeout', value, 'business', 0, '客户端体超时(秒)' -FROM of_options WHERE key = 'OpenRestyClientBodyTimeout' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_client_max_body_size', value, 'business', 0, '客户端最大体大小' -FROM of_options WHERE key = 'OpenRestyClientMaxBodySize' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_large_client_header_buffers', value, 'business', 0, '大客户端头缓冲区' -FROM of_options WHERE key = 'OpenRestyLargeClientHeaderBuffers' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_send_timeout', value, 'business', 0, '发送超时(秒)' -FROM of_options WHERE key = 'OpenRestySendTimeout' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_resolvers', COALESCE(value, ''), 'business', 0, 'DNS 解析器' -FROM of_options WHERE key = 'OpenRestyResolvers' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_proxy_connect_timeout', value, 'business', 0, '代理连接超时(秒)' -FROM of_options WHERE key = 'OpenRestyProxyConnectTimeout' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_proxy_send_timeout', value, 'business', 0, '代理发送超时(秒)' -FROM of_options WHERE key = 'OpenRestyProxySendTimeout' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_proxy_read_timeout', value, 'business', 0, '代理读取超时(秒)' -FROM of_options WHERE key = 'OpenRestyProxyReadTimeout' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_websocket_enabled', value, 'business', 0, 'WebSocket 支持开关' -FROM of_options WHERE key = 'OpenRestyWebsocketEnabled' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_http3_enabled', value, 'business', 0, 'HTTP/3 支持开关' -FROM of_options WHERE key = 'OpenRestyHTTP3Enabled' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_proxy_request_buffering_enabled', value, 'business', 0, '代理请求缓冲开关' -FROM of_options WHERE key = 'OpenRestyProxyRequestBufferingEnabled' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_proxy_buffering_enabled', value, 'business', 0, '代理响应缓冲开关' -FROM of_options WHERE key = 'OpenRestyProxyBufferingEnabled' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_proxy_buffers', value, 'business', 0, '代理缓冲区' -FROM of_options WHERE key = 'OpenRestyProxyBuffers' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_proxy_buffer_size', value, 'business', 0, '代理缓冲区大小' -FROM of_options WHERE key = 'OpenRestyProxyBufferSize' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_proxy_busy_buffers_size', value, 'business', 0, '代理繁忙缓冲区大小' -FROM of_options WHERE key = 'OpenRestyProxyBusyBuffersSize' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_gzip_enabled', value, 'business', 0, 'Gzip 压缩开关' -FROM of_options WHERE key = 'OpenRestyGzipEnabled' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_gzip_min_length', value, 'business', 0, 'Gzip 最小长度' -FROM of_options WHERE key = 'OpenRestyGzipMinLength' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_gzip_comp_level', value, 'business', 0, 'Gzip 压缩级别' -FROM of_options WHERE key = 'OpenRestyGzipCompLevel' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_cache_enabled', value, 'business', 0, '缓存开关' -FROM of_options WHERE key = 'OpenRestyCacheEnabled' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_cache_path', COALESCE(value, ''), 'business', 0, '缓存路径' -FROM of_options WHERE key = 'OpenRestyCachePath' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_cache_levels', value, 'business', 0, '缓存层级' -FROM of_options WHERE key = 'OpenRestyCacheLevels' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_cache_inactive', value, 'business', 0, '缓存不活跃时间' -FROM of_options WHERE key = 'OpenRestyCacheInactive' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_cache_max_size', value, 'business', 0, '缓存最大大小' -FROM of_options WHERE key = 'OpenRestyCacheMaxSize' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_cache_key_template', value, 'business', 0, '缓存键模板' -FROM of_options WHERE key = 'OpenRestyCacheKeyTemplate' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_cache_lock_enabled', value, 'business', 0, '缓存锁开关' -FROM of_options WHERE key = 'OpenRestyCacheLockEnabled' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_cache_lock_timeout', value, 'business', 0, '缓存锁超时' -FROM of_options WHERE key = 'OpenRestyCacheLockTimeout' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_cache_use_stale', value, 'business', 0, '缓存失效策略' -FROM of_options WHERE key = 'OpenRestyCacheUseStale' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - -INSERT INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_main_config_template', value, 'business', 0, '主配置模板' -FROM of_options WHERE key = 'OpenRestyMainConfigTemplate' -ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value; - --- +goose Down --- 回滚时删除所有迁移的配置项 -DELETE FROM w_system_configs WHERE key IN ( - 'agent_discovery_token', - 'agent_heartbeat_interval', - 'agent_websocket_upgrade_enabled', - 'node_offline_threshold', - 'agent_update_repo', - 'geoip_provider', - 'database_auto_cleanup_enabled', - 'database_auto_cleanup_retention_days', - 'uptime_kuma_enabled', - 'uptime_kuma_url', - 'uptime_kuma_username', - 'uptime_kuma_password', - 'uptime_kuma_monitor_scope', - 'uptime_kuma_selected_sites', - 'uptime_kuma_sync_interval', - 'uptime_kuma_interval', - 'uptime_kuma_retry', - 'uptime_kuma_retry_interval', - 'uptime_kuma_timeout', - 'openresty_default_server_return_status', - 'openresty_worker_processes', - 'openresty_worker_connections', - 'openresty_worker_rlimit_nofile', - 'openresty_events_use', - 'openresty_events_multi_accept_enabled', - 'openresty_keepalive_timeout', - 'openresty_keepalive_requests', - 'openresty_client_header_timeout', - 'openresty_client_body_timeout', - 'openresty_client_max_body_size', - 'openresty_large_client_header_buffers', - 'openresty_send_timeout', - 'openresty_resolvers', - 'openresty_proxy_connect_timeout', - 'openresty_proxy_send_timeout', - 'openresty_proxy_read_timeout', - 'openresty_websocket_enabled', - 'openresty_http3_enabled', - 'openresty_proxy_request_buffering_enabled', - 'openresty_proxy_buffering_enabled', - 'openresty_proxy_buffers', - 'openresty_proxy_buffer_size', - 'openresty_proxy_busy_buffers_size', - 'openresty_gzip_enabled', - 'openresty_gzip_min_length', - 'openresty_gzip_comp_level', - 'openresty_cache_enabled', - 'openresty_cache_path', - 'openresty_cache_levels', - 'openresty_cache_inactive', - 'openresty_cache_max_size', - 'openresty_cache_key_template', - 'openresty_cache_lock_enabled', - 'openresty_cache_lock_timeout', - 'openresty_cache_use_stale', - 'openresty_main_config_template' -); diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606220005_drop_of_options.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606220005_drop_of_options.sql deleted file mode 100644 index 3d72ee6a..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606220005_drop_of_options.sql +++ /dev/null @@ -1,10 +0,0 @@ --- +goose Up --- of_options 配置已于 202606220004 迁移至 w_system_configs,删除遗留表。 -DROP TABLE IF EXISTS of_options; - --- +goose Down --- 回滚时重建空表结构(数据无法恢复,迁移来源已为 w_system_configs)。 -CREATE TABLE IF NOT EXISTS of_options ( - key VARCHAR(128) PRIMARY KEY, - value TEXT NOT NULL DEFAULT '' -); diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606270001_make_version_primary_key.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606270001_make_version_primary_key.sql deleted file mode 100644 index 00aee00d..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606270001_make_version_primary_key.sql +++ /dev/null @@ -1,19 +0,0 @@ --- +goose Up --- Remove old PRIMARY KEY on id, set version as PRIMARY KEY, drop id column - --- 1. 移除旧主键约束 -ALTER TABLE of_config_versions DROP CONSTRAINT IF EXISTS of_config_versions_pkey; - --- 2. 移除原先在 version 字段的唯一索引(因为 version 变成主键,主键隐含唯一性) -DROP INDEX IF EXISTS idx_of_config_versions_version; - --- 3. 将 version 设为新主键 -ALTER TABLE of_config_versions ADD PRIMARY KEY (version); - --- 4. 彻底删除 id 列 -ALTER TABLE of_config_versions DROP COLUMN IF EXISTS id; - --- +goose Down -ALTER TABLE of_config_versions DROP CONSTRAINT IF EXISTS of_config_versions_pkey; -ALTER TABLE of_config_versions ADD COLUMN IF NOT EXISTS id BIGSERIAL PRIMARY KEY; -CREATE UNIQUE INDEX IF NOT EXISTS idx_of_config_versions_version ON of_config_versions (version); diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606300001_sync_all_legacy_sequences.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606300001_sync_all_legacy_sequences.sql deleted file mode 100644 index 3d8d5400..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202606300001_sync_all_legacy_sequences.sql +++ /dev/null @@ -1,20 +0,0 @@ --- +goose Up -SELECT setval(pg_get_serial_sequence('w_users', 'id'), GREATEST(COALESCE((SELECT MAX(id) FROM w_users), 0), 1), COALESCE((SELECT MAX(id) FROM w_users), 0) > 0); -SELECT setval(pg_get_serial_sequence('w_auth_sources', 'id'), GREATEST(COALESCE((SELECT MAX(id) FROM w_auth_sources), 0), 1), COALESCE((SELECT MAX(id) FROM w_auth_sources), 0) > 0); -SELECT setval(pg_get_serial_sequence('w_external_accounts', 'id'), GREATEST(COALESCE((SELECT MAX(id) FROM w_external_accounts), 0), 1), COALESCE((SELECT MAX(id) FROM w_external_accounts), 0) > 0); -SELECT setval(pg_get_serial_sequence('of_origins', 'id'), GREATEST(COALESCE((SELECT MAX(id) FROM of_origins), 0), 1), COALESCE((SELECT MAX(id) FROM of_origins), 0) > 0); -SELECT setval(pg_get_serial_sequence('of_apply_logs', 'id'), GREATEST(COALESCE((SELECT MAX(id) FROM of_apply_logs), 0), 1), COALESCE((SELECT MAX(id) FROM of_apply_logs), 0) > 0); -SELECT setval(pg_get_serial_sequence('of_proxy_routes', 'id'), GREATEST(COALESCE((SELECT MAX(id) FROM of_proxy_routes), 0), 1), COALESCE((SELECT MAX(id) FROM of_proxy_routes), 0) > 0); -SELECT setval(pg_get_serial_sequence('of_nodes', 'id'), GREATEST(COALESCE((SELECT MAX(id) FROM of_nodes), 0), 1), COALESCE((SELECT MAX(id) FROM of_nodes), 0) > 0); -SELECT setval(pg_get_serial_sequence('of_waf_rule_groups', 'id'), GREATEST(COALESCE((SELECT MAX(id) FROM of_waf_rule_groups), 0), 1), COALESCE((SELECT MAX(id) FROM of_waf_rule_groups), 0) > 0); -SELECT setval(pg_get_serial_sequence('of_waf_ip_groups', 'id'), GREATEST(COALESCE((SELECT MAX(id) FROM of_waf_ip_groups), 0), 1), COALESCE((SELECT MAX(id) FROM of_waf_ip_groups), 0) > 0); -SELECT setval(pg_get_serial_sequence('of_tls_certificates', 'id'), GREATEST(COALESCE((SELECT MAX(id) FROM of_tls_certificates), 0), 1), COALESCE((SELECT MAX(id) FROM of_tls_certificates), 0) > 0); -SELECT setval(pg_get_serial_sequence('of_managed_domains', 'id'), GREATEST(COALESCE((SELECT MAX(id) FROM of_managed_domains), 0), 1), COALESCE((SELECT MAX(id) FROM of_managed_domains), 0) > 0); -SELECT setval(pg_get_serial_sequence('of_dns_accounts', 'id'), GREATEST(COALESCE((SELECT MAX(id) FROM of_dns_accounts), 0), 1), COALESCE((SELECT MAX(id) FROM of_dns_accounts), 0) > 0); -SELECT setval(pg_get_serial_sequence('of_acme_accounts', 'id'), GREATEST(COALESCE((SELECT MAX(id) FROM of_acme_accounts), 0), 1), COALESCE((SELECT MAX(id) FROM of_acme_accounts), 0) > 0); -SELECT setval(pg_get_serial_sequence('of_pages_projects', 'id'), GREATEST(COALESCE((SELECT MAX(id) FROM of_pages_projects), 0), 1), COALESCE((SELECT MAX(id) FROM of_pages_projects), 0) > 0); -SELECT setval(pg_get_serial_sequence('of_pages_deployments', 'id'), GREATEST(COALESCE((SELECT MAX(id) FROM of_pages_deployments), 0), 1), COALESCE((SELECT MAX(id) FROM of_pages_deployments), 0) > 0); -SELECT setval(pg_get_serial_sequence('of_pages_deployment_files', 'id'), GREATEST(COALESCE((SELECT MAX(id) FROM of_pages_deployment_files), 0), 1), COALESCE((SELECT MAX(id) FROM of_pages_deployment_files), 0) > 0); - --- +goose Down -SELECT 1; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202607120001_create_zone_domain_tables.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202607120001_create_zone_domain_tables.sql deleted file mode 100644 index 00b8170e..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202607120001_create_zone_domain_tables.sql +++ /dev/null @@ -1,28 +0,0 @@ --- +goose Up -CREATE TABLE IF NOT EXISTS of_zones ( - id BIGSERIAL PRIMARY KEY, - domain VARCHAR(255) NOT NULL, - remark VARCHAR(255) NOT NULL DEFAULT '', - created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP -); -CREATE UNIQUE INDEX IF NOT EXISTS idx_of_zones_domain ON of_zones (domain); - -CREATE TABLE IF NOT EXISTS of_zone_domains ( - id BIGSERIAL PRIMARY KEY, - zone_id BIGINT NOT NULL, - proxy_route_id BIGINT, - domain VARCHAR(255) NOT NULL, - cert_id BIGINT, - remark VARCHAR(255) NOT NULL DEFAULT '', - created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP -); -CREATE UNIQUE INDEX IF NOT EXISTS idx_of_zone_domains_domain ON of_zone_domains (domain); -CREATE INDEX IF NOT EXISTS idx_of_zone_domains_zone_id ON of_zone_domains (zone_id); -CREATE INDEX IF NOT EXISTS idx_of_zone_domains_proxy_route_id ON of_zone_domains (proxy_route_id); -CREATE INDEX IF NOT EXISTS idx_of_zone_domains_cert_id ON of_zone_domains (cert_id); - --- +goose Down -DROP TABLE IF EXISTS of_zone_domains; -DROP TABLE IF EXISTS of_zones; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202607120002_import_zone_domains.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202607120002_import_zone_domains.sql deleted file mode 100644 index 97890d8c..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202607120002_import_zone_domains.sql +++ /dev/null @@ -1,8 +0,0 @@ --- +goose Up --- Marker: Zone 域名从旧路由列 / of_managed_domains 的导入由 migrator.Migrate() --- 在全部 goose SQL 应用后自动执行(publicsuffix 根域解析无法用纯 SQL 正确完成)。 --- 本文件仅占位版本号,保证升级链路有序:建表 → 导入 → 删旧列。 -SELECT 1; - --- +goose Down -SELECT 1; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202607130001_drop_legacy_route_domain_columns.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202607130001_drop_legacy_route_domain_columns.sql deleted file mode 100644 index 7fe1d6cb..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202607130001_drop_legacy_route_domain_columns.sql +++ /dev/null @@ -1,35 +0,0 @@ --- +goose Up --- 第二阶段:删除反代路由冗余域名/证书列与托管域名表。 --- 执行前必须完成 migrate-zones 且配置预览验收通过。 - -DROP INDEX IF EXISTS idx_of_proxy_routes_domain; - -ALTER TABLE of_proxy_routes DROP COLUMN IF EXISTS domain; -ALTER TABLE of_proxy_routes DROP COLUMN IF EXISTS domains; -ALTER TABLE of_proxy_routes DROP COLUMN IF EXISTS cert_id; -ALTER TABLE of_proxy_routes DROP COLUMN IF EXISTS cert_ids; -ALTER TABLE of_proxy_routes DROP COLUMN IF EXISTS domain_cert_ids; - -DROP TABLE IF EXISTS of_managed_domains; - --- +goose Down --- 仅恢复开发库结构,不回填历史域名/证书数据。 - -CREATE TABLE IF NOT EXISTS of_managed_domains ( - id BIGSERIAL PRIMARY KEY, - domain VARCHAR(255) NOT NULL, - cert_id BIGINT, - enabled BOOLEAN NOT NULL DEFAULT TRUE, - remark VARCHAR(255) NOT NULL DEFAULT '', - created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP -); -CREATE UNIQUE INDEX IF NOT EXISTS idx_of_managed_domains_domain ON of_managed_domains (domain); - -ALTER TABLE of_proxy_routes ADD COLUMN IF NOT EXISTS domain VARCHAR(255) NOT NULL DEFAULT ''; -ALTER TABLE of_proxy_routes ADD COLUMN IF NOT EXISTS domains TEXT NOT NULL DEFAULT '[]'; -ALTER TABLE of_proxy_routes ADD COLUMN IF NOT EXISTS cert_id BIGINT; -ALTER TABLE of_proxy_routes ADD COLUMN IF NOT EXISTS cert_ids TEXT NOT NULL DEFAULT '[]'; -ALTER TABLE of_proxy_routes ADD COLUMN IF NOT EXISTS domain_cert_ids TEXT NOT NULL DEFAULT '[]'; - -CREATE UNIQUE INDEX IF NOT EXISTS idx_of_proxy_routes_domain ON of_proxy_routes (domain); diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202607140001_drop_unused_remark_columns.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202607140001_drop_unused_remark_columns.sql deleted file mode 100644 index 7a640a4c..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202607140001_drop_unused_remark_columns.sql +++ /dev/null @@ -1,16 +0,0 @@ --- +goose Up --- 移除业务实体上未再使用的备注列(证书与源站备注保留)。 - -ALTER TABLE of_zones DROP COLUMN IF EXISTS remark; -ALTER TABLE of_zone_domains DROP COLUMN IF EXISTS remark; -ALTER TABLE of_proxy_routes DROP COLUMN IF EXISTS remark; -ALTER TABLE of_waf_rule_groups DROP COLUMN IF EXISTS remark; -ALTER TABLE of_waf_ip_groups DROP COLUMN IF EXISTS remark; - --- +goose Down - -ALTER TABLE of_zones ADD COLUMN IF NOT EXISTS remark VARCHAR(255) NOT NULL DEFAULT ''; -ALTER TABLE of_zone_domains ADD COLUMN IF NOT EXISTS remark VARCHAR(255) NOT NULL DEFAULT ''; -ALTER TABLE of_proxy_routes ADD COLUMN IF NOT EXISTS remark VARCHAR(255) NOT NULL DEFAULT ''; -ALTER TABLE of_waf_rule_groups ADD COLUMN IF NOT EXISTS remark VARCHAR(255) NOT NULL DEFAULT ''; -ALTER TABLE of_waf_ip_groups ADD COLUMN IF NOT EXISTS remark VARCHAR(255) NOT NULL DEFAULT ''; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202607150001_orchestrate_waf_rules.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202607150001_orchestrate_waf_rules.sql deleted file mode 100644 index 4682a5ac..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202607150001_orchestrate_waf_rules.sql +++ /dev/null @@ -1,11 +0,0 @@ --- +goose Up -ALTER TABLE of_waf_rule_groups - ADD COLUMN graph TEXT NOT NULL DEFAULT '', - ADD COLUMN revision BIGINT NOT NULL DEFAULT 1; - -ALTER TABLE of_waf_rule_group_bindings - ADD COLUMN sequence INTEGER NOT NULL DEFAULT 0; - --- +goose Down -ALTER TABLE of_waf_rule_group_bindings DROP COLUMN sequence; -ALTER TABLE of_waf_rule_groups DROP COLUMN revision, DROP COLUMN graph; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202607150002_reset_waf_rule_graphs.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202607150002_reset_waf_rule_graphs.sql deleted file mode 100644 index 59803d72..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202607150002_reset_waf_rule_graphs.sql +++ /dev/null @@ -1,17 +0,0 @@ --- +goose Up -UPDATE of_waf_rule_groups -SET graph = '{"schema_version":1,"nodes":[{"id":"start","type":"start","position":{"x":0,"y":0},"config":{}},{"id":"allow","type":"allow","position":{"x":320,"y":0},"config":{}}],"edges":[{"id":"start-allow","source":"start","source_handle":"next","target":"allow"}]}', - revision = 1; - -WITH ordered AS ( - SELECT id, ROW_NUMBER() OVER (PARTITION BY proxy_route_id ORDER BY id) - 1 AS new_sequence - FROM of_waf_rule_group_bindings -) -UPDATE of_waf_rule_group_bindings AS binding -SET sequence = ordered.new_sequence -FROM ordered -WHERE binding.id = ordered.id; - --- +goose Down -UPDATE of_waf_rule_group_bindings SET sequence = 0; -UPDATE of_waf_rule_groups SET revision = 1; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202607150003_drop_legacy_waf_rule_fields.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202607150003_drop_legacy_waf_rule_fields.sql deleted file mode 100644 index 70268652..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202607150003_drop_legacy_waf_rule_fields.sql +++ /dev/null @@ -1,27 +0,0 @@ --- +goose Up -ALTER TABLE of_waf_rule_groups DROP COLUMN block_status_code; -ALTER TABLE of_waf_rule_groups DROP COLUMN block_response_body; -ALTER TABLE of_waf_rule_groups DROP COLUMN ip_whitelist; -ALTER TABLE of_waf_rule_groups DROP COLUMN ip_blacklist; -ALTER TABLE of_waf_rule_groups DROP COLUMN ip_whitelist_groups; -ALTER TABLE of_waf_rule_groups DROP COLUMN ip_blacklist_groups; -ALTER TABLE of_waf_rule_groups DROP COLUMN country_whitelist; -ALTER TABLE of_waf_rule_groups DROP COLUMN country_blacklist; -ALTER TABLE of_waf_rule_groups DROP COLUMN region_whitelist; -ALTER TABLE of_waf_rule_groups DROP COLUMN region_blacklist; -ALTER TABLE of_waf_rule_groups DROP COLUMN pow_enabled; -ALTER TABLE of_waf_rule_groups DROP COLUMN pow_config; - --- +goose Down -ALTER TABLE of_waf_rule_groups ADD COLUMN block_status_code INTEGER NOT NULL DEFAULT 418; -ALTER TABLE of_waf_rule_groups ADD COLUMN block_response_body TEXT NOT NULL DEFAULT ''; -ALTER TABLE of_waf_rule_groups ADD COLUMN ip_whitelist TEXT NOT NULL DEFAULT '[]'; -ALTER TABLE of_waf_rule_groups ADD COLUMN ip_blacklist TEXT NOT NULL DEFAULT '[]'; -ALTER TABLE of_waf_rule_groups ADD COLUMN ip_whitelist_groups TEXT NOT NULL DEFAULT '[]'; -ALTER TABLE of_waf_rule_groups ADD COLUMN ip_blacklist_groups TEXT NOT NULL DEFAULT '[]'; -ALTER TABLE of_waf_rule_groups ADD COLUMN country_whitelist TEXT NOT NULL DEFAULT '[]'; -ALTER TABLE of_waf_rule_groups ADD COLUMN country_blacklist TEXT NOT NULL DEFAULT '[]'; -ALTER TABLE of_waf_rule_groups ADD COLUMN region_whitelist TEXT NOT NULL DEFAULT '[]'; -ALTER TABLE of_waf_rule_groups ADD COLUMN region_blacklist TEXT NOT NULL DEFAULT '[]'; -ALTER TABLE of_waf_rule_groups ADD COLUMN pow_enabled BOOLEAN NOT NULL DEFAULT FALSE; -ALTER TABLE of_waf_rule_groups ADD COLUMN pow_config TEXT NOT NULL DEFAULT '{}'; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202607170001_add_pages_system_configs.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202607170001_add_pages_system_configs.sql deleted file mode 100644 index fea0b27d..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202607170001_add_pages_system_configs.sql +++ /dev/null @@ -1,9 +0,0 @@ --- +goose Up -INSERT INTO w_system_configs (key, value, type, visibility, description, created_at, updated_at) -VALUES - ('pages_max_package_size_mb', '100', 'business', 0, 'Pages 部署包上传大小上限(MiB)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('pages_max_history_count', '20', 'business', 0, 'Pages 每个项目最大历史部署保留数(0 表示不限制)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP) -ON CONFLICT (key) DO NOTHING; - --- +goose Down -DELETE FROM w_system_configs WHERE key IN ('pages_max_package_size_mb', 'pages_max_history_count'); diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202607180001_update_agent_heartbeat_offline_defaults.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202607180001_update_agent_heartbeat_offline_defaults.sql deleted file mode 100644 index b92a9a19..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202607180001_update_agent_heartbeat_offline_defaults.sql +++ /dev/null @@ -1,27 +0,0 @@ --- +goose Up --- 将仍为历史默认值的心跳/离线配置升级为新默认:心跳 3s、离线 60s。 --- 已由管理员改成其他值的配置不受影响。 -UPDATE w_system_configs -SET value = '3000', - updated_at = CURRENT_TIMESTAMP -WHERE key = 'agent_heartbeat_interval' - AND value = '10000'; - -UPDATE w_system_configs -SET value = '60000', - updated_at = CURRENT_TIMESTAMP -WHERE key = 'node_offline_threshold' - AND value = '120000'; - --- +goose Down -UPDATE w_system_configs -SET value = '10000', - updated_at = CURRENT_TIMESTAMP -WHERE key = 'agent_heartbeat_interval' - AND value = '3000'; - -UPDATE w_system_configs -SET value = '120000', - updated_at = CURRENT_TIMESTAMP -WHERE key = 'node_offline_threshold' - AND value = '60000'; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202607190001_add_openresty_default_rate_limits.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202607190001_add_openresty_default_rate_limits.sql deleted file mode 100644 index ab39b72f..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202607190001_add_openresty_default_rate_limits.sql +++ /dev/null @@ -1,14 +0,0 @@ --- +goose Up -INSERT INTO w_system_configs (key, value, type, visibility, description, created_at, updated_at) -VALUES - ('openresty_default_limit_conn_per_server', '0', 'business', 0, '默认站点并发连接上限(0 关闭)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('openresty_default_limit_conn_per_ip', '0', 'business', 0, '默认单 IP 并发连接上限(0 关闭)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('openresty_default_limit_rate', '', 'business', 0, '默认单请求带宽限速(空关闭)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP) -ON CONFLICT (key) DO NOTHING; - --- +goose Down -DELETE FROM w_system_configs WHERE key IN ( - 'openresty_default_limit_conn_per_server', - 'openresty_default_limit_conn_per_ip', - 'openresty_default_limit_rate' -); diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202607190002_add_pages_source_runtime.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202607190002_add_pages_source_runtime.sql deleted file mode 100644 index 93125237..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202607190002_add_pages_source_runtime.sql +++ /dev/null @@ -1,82 +0,0 @@ --- +goose Up -ALTER TABLE of_pages_projects - ADD COLUMN IF NOT EXISTS content_config_version INTEGER NOT NULL DEFAULT 0; - -ALTER TABLE of_pages_deployments - ADD COLUMN IF NOT EXISTS source_type VARCHAR(32) NOT NULL DEFAULT '', - ADD COLUMN IF NOT EXISTS source_identity CHAR(64), - ADD COLUMN IF NOT EXISTS source_revision CHAR(64), - ADD COLUMN IF NOT EXISTS source_label VARCHAR(255) NOT NULL DEFAULT '', - ADD COLUMN IF NOT EXISTS source_meta TEXT NOT NULL DEFAULT '', - ADD COLUMN IF NOT EXISTS trigger_type VARCHAR(32) NOT NULL DEFAULT ''; - -UPDATE of_pages_deployments -SET source_type = 'manual_upload', - trigger_type = 'manual_upload'; - -CREATE TABLE IF NOT EXISTS of_pages_project_sources ( - id BIGSERIAL PRIMARY KEY, - project_id BIGINT NOT NULL, - source_type VARCHAR(32) NOT NULL DEFAULT '', - remote_url TEXT NOT NULL DEFAULT '', - allow_insecure BOOLEAN NOT NULL DEFAULT FALSE, - github_repository VARCHAR(255) NOT NULL DEFAULT '', - release_selector VARCHAR(16) NOT NULL DEFAULT '', - release_tag VARCHAR(255) NOT NULL DEFAULT '', - asset_name VARCHAR(255) NOT NULL DEFAULT '', - auto_update_enabled BOOLEAN NOT NULL DEFAULT FALSE, - check_interval_minutes INTEGER NOT NULL DEFAULT 0, - config_version INTEGER NOT NULL DEFAULT 0, - source_identity CHAR(64) NOT NULL DEFAULT '', - created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP -); - -CREATE UNIQUE INDEX IF NOT EXISTS idx_of_pages_project_sources_project_id - ON of_pages_project_sources (project_id); - -CREATE TABLE IF NOT EXISTS of_pages_project_source_runtime ( - source_id BIGINT PRIMARY KEY, - etag VARCHAR(512) NOT NULL DEFAULT '', - last_seen_revision CHAR(64) NOT NULL DEFAULT '', - last_seen_detail TEXT NOT NULL DEFAULT '', - last_applied_revision CHAR(64) NOT NULL DEFAULT '', - last_applied_detail TEXT NOT NULL DEFAULT '', - sync_status VARCHAR(32) NOT NULL DEFAULT '', - last_error TEXT NOT NULL DEFAULT '', - last_checked_at TIMESTAMPTZ, - last_synced_at TIMESTAMPTZ, - next_check_at TIMESTAMPTZ, - lease_expires_at TIMESTAMPTZ, - lease_token VARCHAR(64) NOT NULL DEFAULT '', - updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP -); - -CREATE INDEX IF NOT EXISTS idx_of_pages_project_source_runtime_next_check_at - ON of_pages_project_source_runtime (next_check_at); - -CREATE UNIQUE INDEX IF NOT EXISTS idx_of_pages_deployments_project_number - ON of_pages_deployments (project_id, deployment_number); - -CREATE UNIQUE INDEX IF NOT EXISTS 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; - --- +goose Down -DROP INDEX IF EXISTS idx_of_pages_deployments_source_revision; -DROP INDEX IF EXISTS idx_of_pages_deployments_project_number; -DROP INDEX IF EXISTS idx_of_pages_project_source_runtime_next_check_at; -DROP TABLE IF EXISTS of_pages_project_source_runtime; -DROP INDEX IF EXISTS idx_of_pages_project_sources_project_id; -DROP TABLE IF EXISTS of_pages_project_sources; - -ALTER TABLE of_pages_deployments - DROP COLUMN IF EXISTS trigger_type, - DROP COLUMN IF EXISTS source_meta, - DROP COLUMN IF EXISTS source_label, - DROP COLUMN IF EXISTS source_revision, - DROP COLUMN IF EXISTS source_identity, - DROP COLUMN IF EXISTS source_type; - -ALTER TABLE of_pages_projects - DROP COLUMN IF EXISTS content_config_version; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202607190003_seed_pages_source_scan.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202607190003_seed_pages_source_scan.sql deleted file mode 100644 index 2c64b37d..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202607190003_seed_pages_source_scan.sql +++ /dev/null @@ -1,38 +0,0 @@ --- +goose Up --- Earlier built-in schedules used explicit IDs, so advance the identity only --- when it trails either existing rows or an already-higher sequence value. -SELECT setval( - pg_get_serial_sequence('w_schedules', 'id'), - GREATEST( - 1, - COALESCE((SELECT MAX(id) FROM w_schedules), 0), - COALESCE(( - SELECT sequences.last_value - FROM pg_sequences AS sequences - WHERE format('%I.%I', sequences.schemaname, sequences.sequencename)::regclass = - pg_get_serial_sequence('w_schedules', 'id')::regclass - ), 0) - ), - TRUE -); - -INSERT INTO w_schedules (name, task_type, cron, payload, is_active, created_at, updated_at) -SELECT - 'OpenFlare Pages 部署源扫描', - 'of_pages_source_scan', - '0 0 * * *', - '{}', - TRUE, - CURRENT_TIMESTAMP, - CURRENT_TIMESTAMP -WHERE NOT EXISTS ( - SELECT 1 FROM w_schedules WHERE task_type = 'of_pages_source_scan' -); - --- +goose Down -DELETE FROM w_schedules -WHERE task_type = 'of_pages_source_scan' - AND name = 'OpenFlare Pages 部署源扫描' - AND cron = '0 0 * * *' - AND payload = '{}' - AND is_active = TRUE; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202607200001_add_openresty_default_limit_req_per_ip.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202607200001_add_openresty_default_limit_req_per_ip.sql deleted file mode 100644 index 5755eea6..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202607200001_add_openresty_default_limit_req_per_ip.sql +++ /dev/null @@ -1,12 +0,0 @@ --- +goose Up -INSERT INTO w_system_configs (key, value, type, visibility, description, created_at, updated_at) -VALUES - ('openresty_default_limit_req_per_ip', '', 'business', 0, '默认单 IP 请求频率限制(空关闭,例如 10r/s、100r/m)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP) -ON CONFLICT (key) DO NOTHING; - -ALTER TABLE of_proxy_routes ADD COLUMN limit_req_per_ip VARCHAR(32) NOT NULL DEFAULT ''; - --- +goose Down -ALTER TABLE of_proxy_routes DROP COLUMN limit_req_per_ip; - -DELETE FROM w_system_configs WHERE key = 'openresty_default_limit_req_per_ip'; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202608040001_create_cloudflare_pointing.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202608040001_create_cloudflare_pointing.sql deleted file mode 100644 index 87b60df6..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202608040001_create_cloudflare_pointing.sql +++ /dev/null @@ -1,49 +0,0 @@ --- +goose Up -CREATE TABLE IF NOT EXISTS of_cf_connections ( - id BIGSERIAL PRIMARY KEY, - source VARCHAR(32) NOT NULL DEFAULT '', - dns_account_id BIGINT, - "authorization" TEXT NOT NULL DEFAULT '', - status VARCHAR(16) NOT NULL DEFAULT '', - verified_at TIMESTAMPTZ, - created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP -); -CREATE INDEX IF NOT EXISTS idx_of_cf_connections_dns_account_id ON of_cf_connections (dns_account_id); - -CREATE TABLE IF NOT EXISTS of_cf_pointing_groups ( - id BIGSERIAL PRIMARY KEY, - name VARCHAR(128) NOT NULL, - primary_node_id BIGINT NOT NULL, - backup_node_id BIGINT, - active_node_id BIGINT NOT NULL, - default_proxied BOOLEAN NOT NULL DEFAULT FALSE, - enabled BOOLEAN NOT NULL DEFAULT FALSE, - created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP -); -CREATE INDEX IF NOT EXISTS idx_of_cf_pointing_groups_primary_node_id ON of_cf_pointing_groups (primary_node_id); -CREATE INDEX IF NOT EXISTS idx_of_cf_pointing_groups_backup_node_id ON of_cf_pointing_groups (backup_node_id); -CREATE INDEX IF NOT EXISTS idx_of_cf_pointing_groups_active_node_id ON of_cf_pointing_groups (active_node_id); - -CREATE TABLE IF NOT EXISTS of_cf_pointing_members ( - id BIGSERIAL PRIMARY KEY, - group_id BIGINT NOT NULL, - zone_domain_id BIGINT NOT NULL, - proxied BOOLEAN NOT NULL DEFAULT FALSE, - cf_zone_id VARCHAR(64) NOT NULL DEFAULT '', - cf_record_id VARCHAR(64) NOT NULL DEFAULT '', - desired_ip VARCHAR(64) NOT NULL DEFAULT '', - sync_status VARCHAR(16) NOT NULL DEFAULT 'pending', - last_error TEXT NOT NULL DEFAULT '', - synced_at TIMESTAMPTZ, - created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP -); -CREATE INDEX IF NOT EXISTS idx_of_cf_pointing_members_group_id ON of_cf_pointing_members (group_id); -CREATE UNIQUE INDEX IF NOT EXISTS idx_of_cf_pointing_members_zone_domain_id ON of_cf_pointing_members (zone_domain_id); - --- +goose Down -DROP TABLE IF EXISTS of_cf_pointing_members; -DROP TABLE IF EXISTS of_cf_pointing_groups; -DROP TABLE IF EXISTS of_cf_connections; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202608060001_add_origin_error_page_options.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202608060001_add_origin_error_page_options.sql deleted file mode 100644 index 6646d974..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202608060001_add_origin_error_page_options.sql +++ /dev/null @@ -1,14 +0,0 @@ --- +goose Up -INSERT INTO w_system_configs (key, value, type, visibility, description, created_at, updated_at) -VALUES - ('origin_error_page_enabled', 'true', 'business', 0, '是否启用源站错误页', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('origin_error_page_status_codes', '["500-599"]', 'business', 0, '源站错误页触发状态码标签 JSON 数组', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('origin_error_page_html', '', 'business', 0, '源站错误页自定义 HTML,空则使用内置默认', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP) -ON CONFLICT (key) DO NOTHING; - --- +goose Down -DELETE FROM w_system_configs WHERE key IN ( - 'origin_error_page_enabled', - 'origin_error_page_status_codes', - 'origin_error_page_html' -); diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202608060002_add_origin_error_page_get_only.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202608060002_add_origin_error_page_get_only.sql deleted file mode 100644 index d6fe39aa..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202608060002_add_origin_error_page_get_only.sql +++ /dev/null @@ -1,8 +0,0 @@ --- +goose Up -INSERT INTO w_system_configs (key, value, type, visibility, description, created_at, updated_at) -VALUES - ('origin_error_page_get_only', 'false', 'business', 0, '源站错误页是否仅对 GET 请求生效(其它方法透传)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP) -ON CONFLICT (key) DO NOTHING; - --- +goose Down -DELETE FROM w_system_configs WHERE key = 'origin_error_page_get_only'; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202608070001_add_sw_offline_options.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202608070001_add_sw_offline_options.sql deleted file mode 100644 index f92b4d3e..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202608070001_add_sw_offline_options.sql +++ /dev/null @@ -1,12 +0,0 @@ --- +goose Up -INSERT INTO w_system_configs (key, value, type, visibility, description, created_at, updated_at) -VALUES - ('sw_offline_enabled', 'false', 'business', 0, '是否启用 Service Worker 离线兜底', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('sw_offline_html', '', 'business', 0, '离线联系页自定义 HTML,空则使用内置默认', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP) -ON CONFLICT (key) DO NOTHING; - --- +goose Down -DELETE FROM w_system_configs WHERE key IN ( - 'sw_offline_enabled', - 'sw_offline_html' -); diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202608070002_add_sw_offline_domains.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202608070002_add_sw_offline_domains.sql deleted file mode 100644 index 505f73b9..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202608070002_add_sw_offline_domains.sql +++ /dev/null @@ -1,7 +0,0 @@ --- +goose Up -INSERT INTO w_system_configs (key, value, type, visibility, description, created_at, updated_at) -VALUES ('sw_offline_domains', '[]', 'business', 0, 'SW 离线兜底生效域名列表(JSON 数组,空则仅总开关无效)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP) -ON CONFLICT (key) DO NOTHING; - --- +goose Down -DELETE FROM w_system_configs WHERE key = 'sw_offline_domains'; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202608080001_create_log_tables.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202608080001_create_log_tables.sql deleted file mode 100644 index f4beba46..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202608080001_create_log_tables.sql +++ /dev/null @@ -1,115 +0,0 @@ --- +goose Up --- 节点访问日志:按月 RANGE 分区,复合主键 (id, logged_at) 满足分区键进唯一索引要求。 -CREATE TABLE IF NOT EXISTS of_node_access_logs ( - id BIGINT NOT NULL, - node_id VARCHAR(64) NOT NULL DEFAULT '', - logged_at TIMESTAMPTZ NOT NULL, - remote_addr VARCHAR(128) NOT NULL DEFAULT '', - region VARCHAR(128) NOT NULL DEFAULT '', - host VARCHAR(255) NOT NULL DEFAULT '', - path VARCHAR(2048) NOT NULL DEFAULT '', - user_agent TEXT NOT NULL DEFAULT '', - cache_status VARCHAR(64) NOT NULL DEFAULT '', - status_code INTEGER NOT NULL DEFAULT 0, - bytes_sent BIGINT NOT NULL DEFAULT 0, - request_length BIGINT NOT NULL DEFAULT 0, - request_time_ms INTEGER NOT NULL DEFAULT 0, - created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY (id, logged_at) -) PARTITION BY RANGE (logged_at); - -CREATE INDEX IF NOT EXISTS idx_of_node_access_logs_node_id ON of_node_access_logs (node_id, logged_at DESC); -CREATE INDEX IF NOT EXISTS idx_of_node_access_logs_host ON of_node_access_logs (host, logged_at DESC); -CREATE INDEX IF NOT EXISTS idx_of_node_access_logs_remote_addr ON of_node_access_logs (remote_addr, logged_at DESC); -CREATE INDEX IF NOT EXISTS idx_of_node_access_logs_status_code ON of_node_access_logs (status_code, logged_at DESC); - --- 用户访问日志:按月分区。 -CREATE TABLE IF NOT EXISTS w_user_access_logs ( - id BIGINT NOT NULL, - user_id BIGINT NOT NULL DEFAULT 0, - path VARCHAR(2048) NOT NULL DEFAULT '', - method VARCHAR(16) NOT NULL DEFAULT '', - ip VARCHAR(128) NOT NULL DEFAULT '', - user_agent TEXT NOT NULL DEFAULT '', - headers TEXT NOT NULL DEFAULT '', - status INTEGER NOT NULL DEFAULT 0, - latency BIGINT NOT NULL DEFAULT 0, - created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY (id, created_at) -) PARTITION BY RANGE (created_at); - -CREATE INDEX IF NOT EXISTS idx_w_user_access_logs_user_id ON w_user_access_logs (user_id, created_at DESC); - --- 可观测 4 表:普通表 + (node_id, captured_at DESC) 索引。 -CREATE TABLE IF NOT EXISTS of_node_metric_snapshots ( - id BIGINT NOT NULL PRIMARY KEY, - node_id VARCHAR(64) NOT NULL DEFAULT '', - captured_at TIMESTAMPTZ NOT NULL, - cpu_usage_percent DOUBLE PRECISION NOT NULL DEFAULT 0, - memory_used_bytes BIGINT NOT NULL DEFAULT 0, - memory_total_bytes BIGINT NOT NULL DEFAULT 0, - storage_used_bytes BIGINT NOT NULL DEFAULT 0, - storage_total_bytes BIGINT NOT NULL DEFAULT 0, - disk_read_bytes BIGINT NOT NULL DEFAULT 0, - disk_write_bytes BIGINT NOT NULL DEFAULT 0, - network_rx_bytes BIGINT NOT NULL DEFAULT 0, - network_tx_bytes BIGINT NOT NULL DEFAULT 0, - created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP -); -CREATE INDEX IF NOT EXISTS idx_of_node_metric_snapshots_node ON of_node_metric_snapshots (node_id, captured_at DESC); - -CREATE TABLE IF NOT EXISTS of_node_edge_health ( - id BIGINT NOT NULL PRIMARY KEY, - node_id VARCHAR(64) NOT NULL DEFAULT '', - captured_at TIMESTAMPTZ NOT NULL, - status VARCHAR(64) NOT NULL DEFAULT '', - connections BIGINT NOT NULL DEFAULT 0, - created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP -); -CREATE INDEX IF NOT EXISTS idx_of_node_edge_health_node ON of_node_edge_health (node_id, captured_at DESC); - -CREATE TABLE IF NOT EXISTS of_node_obs_frps ( - id BIGINT NOT NULL PRIMARY KEY, - node_id VARCHAR(64) NOT NULL DEFAULT '', - captured_at TIMESTAMPTZ 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 TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP -); -CREATE INDEX IF NOT EXISTS idx_of_node_obs_frps_node ON of_node_obs_frps (node_id, captured_at DESC); - -CREATE TABLE IF NOT EXISTS of_node_obs_frpc ( - id BIGINT NOT NULL PRIMARY KEY, - node_id VARCHAR(64) NOT NULL DEFAULT '', - captured_at TIMESTAMPTZ NOT NULL, - tunnel_status VARCHAR(16) NOT NULL DEFAULT '', - connected_relays_count INTEGER NOT NULL DEFAULT 0, - created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP -); -CREATE INDEX IF NOT EXISTS idx_of_node_obs_frpc_node ON of_node_obs_frpc (node_id, captured_at DESC); - --- 分区预建:创建当月及未来 2 个月分区(共 3 个月)。 --- +goose StatementBegin -DO $$ -DECLARE - d date; -BEGIN - FOR d IN SELECT generate_series(date_trunc('month', now())::date, (date_trunc('month', now()) + interval '2 months')::date, interval '1 month')::date - LOOP - EXECUTE format('CREATE TABLE IF NOT EXISTS of_node_access_logs_%s PARTITION OF of_node_access_logs FOR VALUES FROM (%L) TO (%L)', - to_char(d, 'YYYYMM'), d, d + interval '1 month'); - EXECUTE format('CREATE TABLE IF NOT EXISTS w_user_access_logs_%s PARTITION OF w_user_access_logs FOR VALUES FROM (%L) TO (%L)', - to_char(d, 'YYYYMM'), d, d + interval '1 month'); - END LOOP; -END $$; --- +goose StatementEnd - --- +goose Down -DROP TABLE IF EXISTS w_user_access_logs; -DROP TABLE IF EXISTS of_node_access_logs; -DROP TABLE IF EXISTS of_node_metric_snapshots; -DROP TABLE IF EXISTS of_node_edge_health; -DROP TABLE IF EXISTS of_node_obs_frps; -DROP TABLE IF EXISTS of_node_obs_frpc; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202608080002_log_retention_configs.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202608080002_log_retention_configs.sql deleted file mode 100644 index ae46fced..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202608080002_log_retention_configs.sql +++ /dev/null @@ -1,23 +0,0 @@ --- +goose Up --- 日志保留天数配置(business),替换旧的 database_auto_cleanup_* 键。 --- 默认统一 30 天:不继承旧键值,避免旧配置被静默带入导致日志被过度清理。 -INSERT INTO w_system_configs (key, value, type, visibility, description, created_at, updated_at) -SELECT k, '30', 'business', 0, descr, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP -FROM (VALUES - ('log_retention_days_postgres', 'PostgreSQL 日志保留天数(访问日志与可观测统一)'), - ('log_retention_days_sqlite', 'SQLite 日志保留天数'), - ('log_retention_days_clickhouse', 'ClickHouse 日志保留天数') -) AS v(k, descr) -ON CONFLICT (key) DO NOTHING; - -DELETE FROM w_system_configs WHERE key IN ('database_auto_cleanup_enabled', 'database_auto_cleanup_retention_days'); - --- +goose Down -INSERT INTO w_system_configs (key, value, type, visibility, description, created_at, updated_at) -VALUES - ('database_auto_cleanup_enabled', 'true', 'business', 0, '数据库自动清理开关', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('database_auto_cleanup_retention_days', COALESCE((SELECT value FROM w_system_configs WHERE key = 'log_retention_days_postgres'), '30'), 'business', 0, '数据库保留天数', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP) -ON CONFLICT (key) DO NOTHING; - -DELETE FROM w_system_configs WHERE key IN ('log_retention_days_postgres', 'log_retention_days_sqlite', 'log_retention_days_clickhouse'); - diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202608080003_drop_database_cleanup_schedule.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202608080003_drop_database_cleanup_schedule.sql deleted file mode 100644 index 34663806..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202608080003_drop_database_cleanup_schedule.sql +++ /dev/null @@ -1,19 +0,0 @@ --- +goose Up -CREATE TABLE IF NOT EXISTS w_schedules_backup_of_database_auto_cleanup AS -SELECT * FROM w_schedules WHERE task_type = 'of_database_auto_cleanup'; - -DELETE FROM w_schedules WHERE task_type = 'of_database_auto_cleanup'; - --- +goose Down -INSERT INTO w_schedules (id, name, task_type, cron, payload, is_active, created_at, updated_at) -SELECT id, name, task_type, cron, payload, is_active, created_at, updated_at -FROM w_schedules_backup_of_database_auto_cleanup -ON CONFLICT (id) DO NOTHING; - -INSERT INTO w_schedules (id, name, task_type, cron, payload, is_active, created_at, updated_at) -SELECT 102, 'OpenFlare 可观测数据自动清理', 'of_database_auto_cleanup', '0 3 * * *', '{}', TRUE, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP -WHERE NOT EXISTS (SELECT 1 FROM w_schedules WHERE task_type = 'of_database_auto_cleanup') -ON CONFLICT (id) DO NOTHING; - -DROP TABLE IF EXISTS w_schedules_backup_of_database_auto_cleanup; - diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202608090001_metric_retention_config.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202608090001_metric_retention_config.sql deleted file mode 100644 index 0d3b5912..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202608090001_metric_retention_config.sql +++ /dev/null @@ -1,9 +0,0 @@ --- +goose Up --- 性能指标(CPU/内存/磁盘/网络)保留天数:三库共用、独立短留存(默认 3 天), --- 不随 log_retention_days_*(访问日志保留配置)变化。 -INSERT INTO w_system_configs (key, value, type, visibility, description, created_at, updated_at) -VALUES ('metric_retention_days', '3', 'business', 0, '性能指标(CPU/内存/磁盘/网络)保留天数(三库共用)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP) -ON CONFLICT (key) DO NOTHING; - --- +goose Down -DELETE FROM w_system_configs WHERE key = 'metric_retention_days'; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202608090002_update_system_cleanup_schedule.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202608090002_update_system_cleanup_schedule.sql deleted file mode 100644 index 2896c651..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202608090002_update_system_cleanup_schedule.sql +++ /dev/null @@ -1,13 +0,0 @@ --- +goose Up --- 系统定期垃圾清理改为每日执行一次(凌晨 3 点,Asia/Shanghai)。 --- 此前为每 2 小时(0 */2 * * *)高频扫描,日常清理收益有限,降频减少非必要扫描。 -UPDATE w_schedules -SET cron = '0 3 * * *', - updated_at = CURRENT_TIMESTAMP -WHERE task_type = 'system_cleanup'; - --- +goose Down -UPDATE w_schedules -SET cron = '0 */2 * * *', - updated_at = CURRENT_TIMESTAMP -WHERE task_type = 'system_cleanup'; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202608090003_add_log_indexes.sql b/backend/OpenFlare/plugins/server/migrator/goose/postgres/202608090003_add_log_indexes.sql deleted file mode 100644 index 4e257530..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/postgres/202608090003_add_log_indexes.sql +++ /dev/null @@ -1,9 +0,0 @@ --- +goose Up --- 日志列表默认排序与 retention 清理的时间范围条件:补 logged_at 前导索引。 -CREATE INDEX IF NOT EXISTS idx_of_node_access_logs_logged_at ON of_node_access_logs (logged_at DESC, id DESC); --- hosts 过滤为 lower(trim(host)) IN:补表达式索引,普通 (host,...) 索引无法命中函数表达式。 -CREATE INDEX IF NOT EXISTS idx_of_node_access_logs_host_lower ON of_node_access_logs (lower(trim(host))); - --- +goose Down -DROP INDEX IF EXISTS idx_of_node_access_logs_host_lower; -DROP INDEX IF EXISTS idx_of_node_access_logs_logged_at; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606050001_bridge_legacy.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606050001_bridge_legacy.sql deleted file mode 100644 index 52839fa9..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606050001_bridge_legacy.sql +++ /dev/null @@ -1,7 +0,0 @@ --- +goose Up --- Historical Wavelet→OpenFlare table rename bridge (formerly Go migration). --- Fresh installs and current of_* schemas need no action. -SELECT 1; - --- +goose Down -SELECT 1; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606090001_initial_schema.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606090001_initial_schema.sql deleted file mode 100644 index 2240fb98..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606090001_initial_schema.sql +++ /dev/null @@ -1,184 +0,0 @@ --- +goose Up -CREATE TABLE IF NOT EXISTS 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 -); -CREATE INDEX IF NOT EXISTS idx_users_email ON users (email); -CREATE INDEX IF NOT EXISTS idx_users_is_active ON users (is_active); -CREATE INDEX IF NOT EXISTS idx_users_last_login_at ON users (last_login_at); -CREATE INDEX IF NOT EXISTS idx_users_created_at ON users (created_at); - -CREATE TABLE IF NOT EXISTS 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 -); -CREATE INDEX IF NOT EXISTS idx_auth_sources_is_active ON auth_sources (is_active); - -CREATE TABLE IF NOT EXISTS 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 -); -CREATE INDEX IF NOT EXISTS idx_external_accounts_auth_source_id ON external_accounts (auth_source_id); -CREATE INDEX IF NOT EXISTS idx_external_accounts_user_id ON external_accounts (user_id); -CREATE UNIQUE INDEX IF NOT EXISTS idx_external_accounts_source_external ON external_accounts (auth_source_id, external_id); - -CREATE TABLE IF NOT EXISTS 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 -); - -CREATE TABLE IF NOT EXISTS 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), - storage_driver VARCHAR(50) NOT NULL, - type VARCHAR(50) NOT NULL, - status VARCHAR(20) NOT NULL, - metadata JSON, - created_at DATETIME DEFAULT CURRENT_TIMESTAMP, - updated_at DATETIME DEFAULT CURRENT_TIMESTAMP -); -CREATE INDEX IF NOT EXISTS idx_uploads_user_id ON uploads (user_id); -CREATE INDEX IF NOT EXISTS idx_uploads_file_path ON uploads (file_path); -CREATE INDEX IF NOT EXISTS idx_uploads_hash ON uploads (hash); -CREATE INDEX IF NOT EXISTS idx_uploads_type ON uploads (type); - -CREATE TABLE IF NOT EXISTS 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, - last_used_at DATETIME, - created_at DATETIME DEFAULT CURRENT_TIMESTAMP, - updated_at DATETIME DEFAULT CURRENT_TIMESTAMP -); -CREATE INDEX IF NOT EXISTS idx_access_tokens_user_id ON access_tokens (user_id); - -CREATE TABLE IF NOT EXISTS 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 -); -CREATE INDEX IF NOT EXISTS idx_task_executions_task_type ON task_executions (task_type); -CREATE INDEX IF NOT EXISTS idx_task_executions_status ON task_executions (status); -CREATE INDEX IF NOT EXISTS idx_task_executions_started_at ON task_executions (started_at); -CREATE INDEX IF NOT EXISTS idx_task_executions_created_at ON task_executions (created_at); - -CREATE TABLE IF NOT EXISTS 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 -); -CREATE INDEX IF NOT EXISTS idx_templates_is_system ON templates (is_system); -CREATE INDEX IF NOT EXISTS idx_templates_created_at ON templates (created_at); -CREATE INDEX IF NOT EXISTS idx_templates_updated_at ON templates (updated_at); - -INSERT INTO system_configs (key, value, type, visibility, description, created_at, updated_at) VALUES - ('cap_login_enabled', 'false', 'system', 1, '是否启用登录人机验证(true/false)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('cap_auto_solve', 'true', 'system', 1, '打开页面后是否自动开始计算,关闭则需用户手动点击触发', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('cap_challenge_count', '1', 'system', 0, '客户端需求解的 PoW 难题总数,默认 1,推荐 1~5', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('cap_challenge_size', '32', 'system', 0, '人机验证盐值长度', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('cap_challenge_difficulty', '4', 'system', 0, '人机验证 PoW 难度(目标前缀长度)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('cap_challenge_ttl_seconds', '600', 'system', 0, '人机验证难题有效时间(秒)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('cap_token_ttl_seconds', '1200', 'system', 0, '人机验证兑换凭证有效时间(秒)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('server_address', '', 'system', 0, '服务器地址(用于跨域源控制,不设定则允许任意源)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('smtp_host', '', 'system', 0, 'SMTP 服务器地址(例如 smtp.example.com)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('smtp_port', '587', 'system', 0, 'SMTP 端口(例如 587 或 465)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('smtp_username', '', 'system', 0, 'SMTP 账户(如 sender@example.com)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('smtp_password', '', 'system', 0, 'SMTP 访问凭证(授权码/密码)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('upload_allowed_extensions', 'jpg,png,webp', 'system', 1, '允许上传的图片扩展名(逗号分隔)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('site_name', 'OpenFlare', 'system', 1, '系统平台的展示名称', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('password_login_enabled', 'true', 'system', 1, '是否允许使用账号密码登录', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('registration_enabled', 'false', 'system', 1, '控制普通用户是否可以自主注册(true/false)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('password_register_enabled', 'false', 'system', 1, '是否允许通过密码创建本地账号', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('oidc_login_enabled', 'true', 'system', 1, '是否允许使用第三方 OIDC 认证源登录', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('max_api_keys_per_user', '5', 'business', 1, '限制每个普通用户可以创建的 API Key 最大数量', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('email_login_verification_enabled', 'false', 'system', 1, '是否开启邮箱登录验证(true/false)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('email_register_verification_enabled', 'false', 'system', 1, '是否开启邮箱注册验证(true/false)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('menu_display_config', '{}', 'system', 1, '目录显示配置(JSON 字符串,格式为 {url: enabled})', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('search_engine_indexing_enabled', 'false', 'system', 1, '是否允许搜索引擎爬取/检索该站点(true/false)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('update_upstream_repository', 'Rain-kl/OpenFlare', 'system', 0, 'GitHub Actions Release 上游仓库(owner/repo 或 GitHub 仓库地址)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('storage_config', '{"driver":"local","local":{"root":"."},"s3":{"region":"us-east-1"},"r2":{"region":"auto"},"minio":{"region":"us-east-1","path_style":true},"oss":{},"webdav":{}}', 'system', 0, '文件存储驱动及连接配置(JSON)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP) -ON CONFLICT (key) DO NOTHING; - -INSERT INTO users (id, username, password, nickname, avatar_url, is_active, is_admin, last_login_at, created_at, updated_at) -VALUES (1, 'admin', '12345678', 'Administrator', '', TRUE, TRUE, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP) -ON CONFLICT (username) DO NOTHING; - -INSERT INTO templates (key, name, type, subject, content, description, is_system, created_at, updated_at) VALUES - ('login_email', '登录验证码邮件', 'email', 'OpenFlare 登录验证码', '

OpenFlare 登录验证

您的登录验证码为:{{.Code}},5分钟内有效,请勿将验证码泄露给他人。

', '用户密码登录时发送的验证码邮件模板,支持变量:{{.Code}}', TRUE, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('register_email', '注册验证码邮件', 'email', 'OpenFlare 注册验证码', '

OpenFlare 注册验证

您的注册验证码为:{{.Code}},5分钟内有效,请勿泄露给他人。

', '用户注册时发送的验证码邮件模板,支持变量:{{.Code}}', TRUE, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP) -ON CONFLICT (key) DO NOTHING; - --- +goose Down -DROP TABLE IF EXISTS templates; -DROP TABLE IF EXISTS task_executions; -DROP TABLE IF EXISTS access_tokens; -DROP TABLE IF EXISTS uploads; -DROP TABLE IF EXISTS system_configs; -DROP TABLE IF EXISTS external_accounts; -DROP TABLE IF EXISTS auth_sources; -DROP TABLE IF EXISTS users; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606100001_create_schedules.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606100001_create_schedules.sql deleted file mode 100644 index 0ee0df13..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606100001_create_schedules.sql +++ /dev/null @@ -1,20 +0,0 @@ --- +goose Up -CREATE TABLE IF NOT EXISTS schedules ( - id BIGINT PRIMARY KEY, - 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 -); -CREATE INDEX IF NOT EXISTS idx_schedules_is_active ON schedules (is_active); - --- Seed initial cleanup task -INSERT INTO schedules (id, name, task_type, cron, payload, is_active, created_at, updated_at) -VALUES (1, '清理未使用上传', 'cleanup_unused_uploads', '0 */2 * * *', '{}', TRUE, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP) -ON CONFLICT (id) DO NOTHING; - --- +goose Down -DROP TABLE IF EXISTS schedules; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606100002_access_token_is_admin.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606100002_access_token_is_admin.sql deleted file mode 100644 index 73f5d7ce..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606100002_access_token_is_admin.sql +++ /dev/null @@ -1,5 +0,0 @@ --- +goose Up -ALTER TABLE access_tokens ADD COLUMN is_admin BOOLEAN NOT NULL DEFAULT 0; - --- +goose Down -ALTER TABLE access_tokens DROP COLUMN is_admin; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606110001_remove_access_token_last_used_at.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606110001_remove_access_token_last_used_at.sql deleted file mode 100644 index 1b2c38c7..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606110001_remove_access_token_last_used_at.sql +++ /dev/null @@ -1,9 +0,0 @@ --- +goose Up --- +goose StatementBegin -ALTER TABLE access_tokens DROP COLUMN last_used_at; --- +goose StatementEnd - --- +goose Down --- +goose StatementBegin -ALTER TABLE access_tokens ADD COLUMN last_used_at DATETIME; --- +goose StatementEnd diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606110002_alter_schedules_id_auto_increment.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606110002_alter_schedules_id_auto_increment.sql deleted file mode 100644 index 4f338526..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606110002_alter_schedules_id_auto_increment.sql +++ /dev/null @@ -1,32 +0,0 @@ --- +goose Up --- +goose StatementBegin --- 1. Rename existing schedules table -ALTER TABLE schedules RENAME TO schedules_old; - --- 2. Create new schedules table with AUTOINCREMENT -CREATE TABLE 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 -); - --- 3. Copy existing data -INSERT INTO schedules (id, name, task_type, cron, payload, is_active, created_at, updated_at) -SELECT id, name, task_type, cron, payload, is_active, created_at, updated_at FROM schedules_old; - --- 4. Drop the old table -DROP TABLE schedules_old; - --- 5. Recreate index -CREATE INDEX IF NOT EXISTS idx_schedules_is_active ON schedules (is_active); --- +goose StatementEnd - --- +goose Down --- +goose StatementBegin --- Re-creating table with AUTOINCREMENT cannot be undone simply without recreating table again. --- +goose StatementEnd diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606110003_rename_tables_to_w_prefix.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606110003_rename_tables_to_w_prefix.sql deleted file mode 100644 index 184e17e9..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606110003_rename_tables_to_w_prefix.sql +++ /dev/null @@ -1,123 +0,0 @@ --- +goose Up -ALTER TABLE users RENAME TO w_users; -ALTER TABLE auth_sources RENAME TO w_auth_sources; -ALTER TABLE external_accounts RENAME TO w_external_accounts; -ALTER TABLE system_configs RENAME TO w_system_configs; -ALTER TABLE uploads RENAME TO w_uploads; -ALTER TABLE access_tokens RENAME TO w_access_tokens; -ALTER TABLE task_executions RENAME TO w_task_executions; -ALTER TABLE templates RENAME TO w_templates; -ALTER TABLE schedules RENAME TO w_schedules; - --- Drop and Recreate SQLite indexes -DROP INDEX IF EXISTS idx_users_email; -CREATE INDEX IF NOT EXISTS idx_w_users_email ON w_users (email); -DROP INDEX IF EXISTS idx_users_is_active; -CREATE INDEX IF NOT EXISTS idx_w_users_is_active ON w_users (is_active); -DROP INDEX IF EXISTS idx_users_last_login_at; -CREATE INDEX IF NOT EXISTS idx_w_users_last_login_at ON w_users (last_login_at); -DROP INDEX IF EXISTS idx_users_created_at; -CREATE INDEX IF NOT EXISTS idx_w_users_created_at ON w_users (created_at); - -DROP INDEX IF EXISTS idx_auth_sources_is_active; -CREATE INDEX IF NOT EXISTS idx_w_auth_sources_is_active ON w_auth_sources (is_active); - -DROP INDEX IF EXISTS idx_external_accounts_auth_source_id; -CREATE INDEX IF NOT EXISTS idx_w_external_accounts_auth_source_id ON w_external_accounts (auth_source_id); -DROP INDEX IF EXISTS idx_external_accounts_user_id; -CREATE INDEX IF NOT EXISTS idx_w_external_accounts_user_id ON w_external_accounts (user_id); -DROP INDEX IF EXISTS idx_external_accounts_source_external; -CREATE UNIQUE INDEX IF NOT EXISTS idx_w_external_accounts_source_external ON w_external_accounts (auth_source_id, external_id); - -DROP INDEX IF EXISTS idx_uploads_user_id; -CREATE INDEX IF NOT EXISTS idx_w_uploads_user_id ON w_uploads (user_id); -DROP INDEX IF EXISTS idx_uploads_file_path; -CREATE INDEX IF NOT EXISTS idx_w_uploads_file_path ON w_uploads (file_path); -DROP INDEX IF EXISTS idx_uploads_hash; -CREATE INDEX IF NOT EXISTS idx_w_uploads_hash ON w_uploads (hash); -DROP INDEX IF EXISTS idx_uploads_type; -CREATE INDEX IF NOT EXISTS idx_w_uploads_type ON w_uploads (type); - -DROP INDEX IF EXISTS idx_access_tokens_user_id; -CREATE INDEX IF NOT EXISTS idx_w_access_tokens_user_id ON w_access_tokens (user_id); - -DROP INDEX IF EXISTS idx_task_executions_task_type; -CREATE INDEX IF NOT EXISTS idx_w_task_executions_task_type ON w_task_executions (task_type); -DROP INDEX IF EXISTS idx_task_executions_status; -CREATE INDEX IF NOT EXISTS idx_w_task_executions_status ON w_task_executions (status); -DROP INDEX IF EXISTS idx_task_executions_started_at; -CREATE INDEX IF NOT EXISTS idx_w_task_executions_started_at ON w_task_executions (started_at); -DROP INDEX IF EXISTS idx_task_executions_created_at; -CREATE INDEX IF NOT EXISTS idx_w_task_executions_created_at ON w_task_executions (created_at); - -DROP INDEX IF EXISTS idx_templates_is_system; -CREATE INDEX IF NOT EXISTS idx_w_templates_is_system ON w_templates (is_system); -DROP INDEX IF EXISTS idx_templates_created_at; -CREATE INDEX IF NOT EXISTS idx_w_templates_created_at ON w_templates (created_at); -DROP INDEX IF EXISTS idx_templates_updated_at; -CREATE INDEX IF NOT EXISTS idx_w_templates_updated_at ON w_templates (updated_at); - -DROP INDEX IF EXISTS idx_schedules_is_active; -CREATE INDEX IF NOT EXISTS idx_w_schedules_is_active ON w_schedules (is_active); - --- +goose Down -ALTER TABLE w_schedules RENAME TO schedules; -ALTER TABLE w_templates RENAME TO templates; -ALTER TABLE w_task_executions RENAME TO task_executions; -ALTER TABLE w_access_tokens RENAME TO access_tokens; -ALTER TABLE w_uploads RENAME TO uploads; -ALTER TABLE w_system_configs RENAME TO system_configs; -ALTER TABLE w_external_accounts RENAME TO external_accounts; -ALTER TABLE w_auth_sources RENAME TO auth_sources; -ALTER TABLE w_users RENAME TO users; - --- Revert indexes -DROP INDEX IF EXISTS idx_w_users_email; -CREATE INDEX IF NOT EXISTS idx_users_email ON users (email); -DROP INDEX IF EXISTS idx_w_users_is_active; -CREATE INDEX IF NOT EXISTS idx_users_is_active ON users (is_active); -DROP INDEX IF EXISTS idx_w_users_last_login_at; -CREATE INDEX IF NOT EXISTS idx_users_last_login_at ON users (last_login_at); -DROP INDEX IF EXISTS idx_w_users_created_at; -CREATE INDEX IF NOT EXISTS idx_users_created_at ON users (created_at); - -DROP INDEX IF EXISTS idx_w_auth_sources_is_active; -CREATE INDEX IF NOT EXISTS idx_auth_sources_is_active ON auth_sources (is_active); - -DROP INDEX IF EXISTS idx_w_external_accounts_auth_source_id; -CREATE INDEX IF NOT EXISTS idx_external_accounts_auth_source_id ON external_accounts (auth_source_id); -DROP INDEX IF EXISTS idx_w_external_accounts_user_id; -CREATE INDEX IF NOT EXISTS idx_external_accounts_user_id ON external_accounts (user_id); -DROP INDEX IF EXISTS idx_w_external_accounts_source_external; -CREATE UNIQUE INDEX IF NOT EXISTS idx_external_accounts_source_external ON external_accounts (auth_source_id, external_id); - -DROP INDEX IF EXISTS idx_w_uploads_user_id; -CREATE INDEX IF NOT EXISTS idx_uploads_user_id ON uploads (user_id); -DROP INDEX IF EXISTS idx_w_uploads_file_path; -CREATE INDEX IF NOT EXISTS idx_uploads_file_path ON uploads (file_path); -DROP INDEX IF EXISTS idx_w_uploads_hash; -CREATE INDEX IF NOT EXISTS idx_uploads_hash ON uploads (hash); -DROP INDEX IF EXISTS idx_w_uploads_type; -CREATE INDEX IF NOT EXISTS idx_uploads_type ON uploads (type); - -DROP INDEX IF EXISTS idx_w_access_tokens_user_id; -CREATE INDEX IF NOT EXISTS idx_access_tokens_user_id ON access_tokens (user_id); - -DROP INDEX IF EXISTS idx_w_task_executions_task_type; -CREATE INDEX IF NOT EXISTS idx_task_executions_task_type ON task_executions (task_type); -DROP INDEX IF EXISTS idx_w_task_executions_status; -CREATE INDEX IF NOT EXISTS idx_task_executions_status ON task_executions (status); -DROP INDEX IF EXISTS idx_w_task_executions_started_at; -CREATE INDEX IF NOT EXISTS idx_task_executions_started_at ON task_executions (started_at); -DROP INDEX IF EXISTS idx_w_task_executions_created_at; -CREATE INDEX IF NOT EXISTS idx_task_executions_created_at ON task_executions (created_at); - -DROP INDEX IF EXISTS idx_w_templates_is_system; -CREATE INDEX IF NOT EXISTS idx_templates_is_system ON templates (is_system); -DROP INDEX IF EXISTS idx_w_templates_created_at; -CREATE INDEX IF NOT EXISTS idx_templates_created_at ON templates (created_at); -DROP INDEX IF EXISTS idx_w_templates_updated_at; -CREATE INDEX IF NOT EXISTS idx_templates_updated_at ON templates (updated_at); - -DROP INDEX IF EXISTS idx_w_schedules_is_active; -CREATE INDEX IF NOT EXISTS idx_schedules_is_active ON schedules (is_active); diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606110004_add_file_access_whitelist_config.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606110004_add_file_access_whitelist_config.sql deleted file mode 100644 index 20963f50..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606110004_add_file_access_whitelist_config.sql +++ /dev/null @@ -1,7 +0,0 @@ --- +goose Up -INSERT INTO w_system_configs (key, value, type, visibility, description, created_at, updated_at) -VALUES ('file_access_whitelist', '["avatar"]', 'system', 1, '免登录访问的文件业务类型白名单 (JSON 数组格式)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP) -ON CONFLICT (key) DO NOTHING; - --- +goose Down -DELETE FROM w_system_configs WHERE key = 'file_access_whitelist'; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606110005_add_disk_cache_configs.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606110005_add_disk_cache_configs.sql deleted file mode 100644 index 8a27b6a3..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606110005_add_disk_cache_configs.sql +++ /dev/null @@ -1,10 +0,0 @@ --- +goose Up -INSERT INTO w_system_configs (key, value, type, visibility, description, created_at, updated_at) -VALUES - ('disk_cache_max_size_mb', '100', 'system', 0, '磁盘缓存最大空间大小 (MB)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('disk_cache_ttl_minutes', '60', 'system', 0, '磁盘缓存默认有效期 (分钟)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('disk_cache_lru_enabled', 'true', 'system', 0, '是否启用 LRU 淘汰机制', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP) -ON CONFLICT (key) DO NOTHING; - --- +goose Down -DELETE FROM w_system_configs WHERE key IN ('disk_cache_max_size_mb', 'disk_cache_ttl_minutes', 'disk_cache_lru_enabled'); diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606120001_add_login_session_ttl_config.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606120001_add_login_session_ttl_config.sql deleted file mode 100644 index 4300c4c4..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606120001_add_login_session_ttl_config.sql +++ /dev/null @@ -1,8 +0,0 @@ --- +goose Up -INSERT INTO w_system_configs (key, value, type, visibility, description, created_at, updated_at) -VALUES - ('login_session_ttl_hours', '0', 'system', 0, '登录会话过期时间 (小时,0表示浏览器关闭后自动退出,-1表示永不过期)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP) -ON CONFLICT (key) DO NOTHING; - --- +goose Down -DELETE FROM w_system_configs WHERE key = 'login_session_ttl_hours'; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606120002_add_update_upstream_repository_config.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606120002_add_update_upstream_repository_config.sql deleted file mode 100644 index 8ddb1f8c..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606120002_add_update_upstream_repository_config.sql +++ /dev/null @@ -1,7 +0,0 @@ --- +goose Up -INSERT INTO w_system_configs (key, value, type, visibility, description, created_at, updated_at) -VALUES ('update_upstream_repository', 'Rain-kl/OpenFlare', 'system', 0, 'GitHub Actions Release 上游仓库(owner/repo 或 GitHub 仓库地址)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP) -ON CONFLICT (key) DO NOTHING; - --- +goose Down -DELETE FROM w_system_configs WHERE key = 'update_upstream_repository'; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606130001_add_upload_access_mode.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606130001_add_upload_access_mode.sql deleted file mode 100644 index f5f4120a..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606130001_add_upload_access_mode.sql +++ /dev/null @@ -1,6 +0,0 @@ --- +goose Up -ALTER TABLE w_uploads ADD COLUMN access_mode INTEGER NOT NULL DEFAULT 0; -UPDATE w_uploads SET access_mode = 1 WHERE type = 'avatar'; - --- +goose Down -ALTER TABLE w_uploads DROP COLUMN access_mode; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606130002_expand_system_config_value.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606130002_expand_system_config_value.sql deleted file mode 100644 index ac50e2a4..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606130002_expand_system_config_value.sql +++ /dev/null @@ -1,6 +0,0 @@ --- +goose Up --- SQLite stores VARCHAR and TEXT with the same TEXT affinity. -SELECT 1; - --- +goose Down -SELECT 1; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606130003_add_storage_config.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606130003_add_storage_config.sql deleted file mode 100644 index 4d49aa64..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606130003_add_storage_config.sql +++ /dev/null @@ -1,15 +0,0 @@ --- +goose Up -INSERT INTO w_system_configs (key, value, type, visibility, description, created_at, updated_at) -VALUES ( - 'storage_config', - '{"driver":"local","local":{"root":"."},"s3":{"region":"us-east-1"},"r2":{"region":"auto"},"minio":{"region":"us-east-1","path_style":true},"oss":{},"webdav":{}}', - 'system', - 0, - '文件存储驱动及连接配置(JSON)', - CURRENT_TIMESTAMP, - CURRENT_TIMESTAMP -) -ON CONFLICT (key) DO NOTHING; - --- +goose Down -DELETE FROM w_system_configs WHERE key = 'storage_config'; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606140001_create_push_tables.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606140001_create_push_tables.sql deleted file mode 100644 index 128e581f..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606140001_create_push_tables.sql +++ /dev/null @@ -1,34 +0,0 @@ --- +goose Up -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 -); - -CREATE INDEX idx_w_push_events_enabled ON w_push_events(enabled); - -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 -); - -CREATE INDEX idx_w_push_histories_event ON w_push_histories(event_key); -CREATE INDEX idx_w_push_histories_created ON w_push_histories(created_at); - --- +goose Down -DROP TABLE IF EXISTS w_push_histories; -DROP TABLE IF EXISTS w_push_events; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606140003_add_system_user.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606140003_add_system_user.sql deleted file mode 100644 index b593ac76..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606140003_add_system_user.sql +++ /dev/null @@ -1,7 +0,0 @@ --- +goose Up -INSERT INTO w_users (id, username, password, nickname, avatar_url, is_active, is_admin, last_login_at, created_at, updated_at) -VALUES (999, 'system', '*', '系统', '', TRUE, FALSE, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP) -ON CONFLICT (username) DO NOTHING; - --- +goose Down -DELETE FROM w_users WHERE username = 'system'; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606140004_create_push_channels.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606140004_create_push_channels.sql deleted file mode 100644 index b58ccb50..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606140004_create_push_channels.sql +++ /dev/null @@ -1,19 +0,0 @@ --- +goose Up -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 -); - -CREATE INDEX idx_w_push_channels_name ON w_push_channels(name); -CREATE INDEX idx_w_push_channels_enabled ON w_push_channels(enabled); - --- +goose Down -DROP TABLE IF EXISTS w_push_channels; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606140005_update_system_cleanup_schedule.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606140005_update_system_cleanup_schedule.sql deleted file mode 100644 index f7965f22..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606140005_update_system_cleanup_schedule.sql +++ /dev/null @@ -1,11 +0,0 @@ --- +goose Up -UPDATE w_schedules -SET name = '系统定期垃圾清理', - task_type = 'system_cleanup' -WHERE id = 1; - --- +goose Down -UPDATE w_schedules -SET name = '清理未使用上传', - task_type = 'cleanup_unused_uploads' -WHERE id = 1; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606150001_add_task_type_to_push_events.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606150001_add_task_type_to_push_events.sql deleted file mode 100644 index 77f5dbd9..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606150001_add_task_type_to_push_events.sql +++ /dev/null @@ -1,9 +0,0 @@ --- +goose Up -ALTER TABLE w_push_events ADD COLUMN task_type VARCHAR(100) NOT NULL DEFAULT ''; -CREATE INDEX idx_w_push_events_task_type ON w_push_events(task_type); - --- +goose Down -DROP INDEX IF EXISTS idx_w_push_events_task_type; --- SQLite does not support DROP COLUMN in older versions easily, but standard ALTER TABLE DROP COLUMN works in SQLite 3.35.0+. --- We can write standard DROP COLUMN. -ALTER TABLE w_push_events DROP COLUMN task_type; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606160001_remove_push_config.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606160001_remove_push_config.sql deleted file mode 100644 index d3214a00..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606160001_remove_push_config.sql +++ /dev/null @@ -1,6 +0,0 @@ --- +goose Up -DELETE FROM w_system_configs WHERE key = 'push_config'; -DELETE FROM w_push_events WHERE event_key = 'admin_login'; -DELETE FROM w_system_configs WHERE key = 'push_global_token'; - --- +goose Down diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606170001_add_upload_composite_indexes.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606170001_add_upload_composite_indexes.sql deleted file mode 100644 index 7d2f0e7d..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606170001_add_upload_composite_indexes.sql +++ /dev/null @@ -1,9 +0,0 @@ --- +goose Up -CREATE INDEX IF NOT EXISTS idx_w_uploads_status_created_at ON w_uploads (status, created_at); -CREATE INDEX IF NOT EXISTS idx_w_uploads_storage_driver_status ON w_uploads (storage_driver, status); -CREATE INDEX IF NOT EXISTS idx_w_uploads_hash_file_size_status ON w_uploads (hash, file_size, status); - --- +goose Down -DROP INDEX IF EXISTS idx_w_uploads_hash_file_size_status; -DROP INDEX IF EXISTS idx_w_uploads_storage_driver_status; -DROP INDEX IF EXISTS idx_w_uploads_status_created_at; \ No newline at end of file diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606170002_create_upload_stats_table.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606170002_create_upload_stats_table.sql deleted file mode 100644 index ab6b7b6c..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606170002_create_upload_stats_table.sql +++ /dev/null @@ -1,12 +0,0 @@ --- +goose Up -CREATE TABLE IF NOT EXISTS 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) -); - --- +goose Down -DROP TABLE IF EXISTS w_upload_stats; \ No newline at end of file diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606170003_backfill_upload_stats.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606170003_backfill_upload_stats.sql deleted file mode 100644 index 2ebbd8c4..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606170003_backfill_upload_stats.sql +++ /dev/null @@ -1,67 +0,0 @@ --- +goose Up -INSERT INTO w_upload_stats (dimension, stat_key, file_count, file_size) -SELECT 'total', '', COUNT(*), COALESCE(SUM(file_size), 0) -FROM w_uploads -WHERE status != 'deleted' -ON CONFLICT (dimension, stat_key) DO UPDATE SET - file_count = excluded.file_count, - file_size = excluded.file_size, - updated_at = CURRENT_TIMESTAMP; - -INSERT INTO w_upload_stats (dimension, stat_key, file_count, file_size) -SELECT - 'type', - COALESCE(NULLIF(type, ''), 'generic'), - COUNT(*), - COALESCE(SUM(file_size), 0) -FROM w_uploads -WHERE status != 'deleted' -GROUP BY COALESCE(NULLIF(type, ''), 'generic') -ON CONFLICT (dimension, stat_key) DO UPDATE SET - file_count = excluded.file_count, - file_size = excluded.file_size, - updated_at = CURRENT_TIMESTAMP; - -INSERT INTO w_upload_stats (dimension, stat_key, file_count, file_size) -SELECT - 'category', - CASE - WHEN LOWER(mime_type) LIKE 'image/%' - OR LOWER(extension) IN ('jpg', 'jpeg', 'png', 'webp', 'gif') THEN '图片' - WHEN LOWER(mime_type) LIKE 'video/%' THEN '视频' - WHEN LOWER(mime_type) LIKE 'audio/%' THEN '音频' - WHEN LOWER(extension) IN ('zip', 'rar', '7z', 'tar', 'gz', 'tgz', 'bz2', 'xz') - OR LOWER(mime_type) LIKE '%zip%' - OR LOWER(mime_type) LIKE '%tar%' - OR LOWER(mime_type) LIKE '%gzip%' THEN '压缩包' - WHEN LOWER(extension) IN ('pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'txt', 'md', 'csv', 'json', 'yaml', 'yml', 'xml') - OR LOWER(mime_type) LIKE 'text/%' - OR LOWER(mime_type) = 'application/pdf' THEN '文档' - ELSE '其他' - END, - COUNT(*), - COALESCE(SUM(file_size), 0) -FROM w_uploads -WHERE status != 'deleted' -GROUP BY 2 -ON CONFLICT (dimension, stat_key) DO UPDATE SET - file_count = excluded.file_count, - file_size = excluded.file_size, - updated_at = CURRENT_TIMESTAMP; - -INSERT INTO w_upload_stats (dimension, stat_key, file_count, file_size) -SELECT - 'trend', - STRFTIME('%Y-%m-%d', created_at), - COUNT(*), - COALESCE(SUM(file_size), 0) -FROM w_uploads -WHERE status != 'deleted' -GROUP BY STRFTIME('%Y-%m-%d', created_at) -ON CONFLICT (dimension, stat_key) DO UPDATE SET - file_count = excluded.file_count, - file_size = excluded.file_size, - updated_at = CURRENT_TIMESTAMP; - --- +goose Down -DELETE FROM w_upload_stats; \ No newline at end of file diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606180001_drop_upload_storage_driver.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606180001_drop_upload_storage_driver.sql deleted file mode 100644 index aa66dcdc..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606180001_drop_upload_storage_driver.sql +++ /dev/null @@ -1,8 +0,0 @@ --- +goose Up -DROP INDEX IF EXISTS idx_w_uploads_storage_driver_status; --- SQLite lacks DROP COLUMN IF EXISTS; goose runs this only after initial schema created the column. -ALTER TABLE w_uploads DROP COLUMN storage_driver; - --- +goose Down -ALTER TABLE w_uploads ADD COLUMN storage_driver VARCHAR(50) NOT NULL DEFAULT 'local'; -CREATE INDEX IF NOT EXISTS idx_w_uploads_storage_driver_status ON w_uploads (storage_driver, status); \ No newline at end of file diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190001_create_of_options.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190001_create_of_options.sql deleted file mode 100644 index 65cb6198..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190001_create_of_options.sql +++ /dev/null @@ -1,66 +0,0 @@ --- +goose Up -CREATE TABLE IF NOT EXISTS of_options ( - key TEXT PRIMARY KEY, - value TEXT NOT NULL DEFAULT '' -); - -INSERT OR IGNORE INTO of_options (key, value) VALUES - ('PasswordLoginEnabled', 'true'), - ('CapLoginEnabled', 'true'), - ('PasswordRegisterEnabled', 'false'), - ('EmailVerificationEnabled', 'false'), - ('GitHubOAuthEnabled', 'false'), - ('WeChatAuthEnabled', 'false'), - ('SMTPPort', '587'), - ('SystemName', 'OpenFlare'), - ('AgentHeartbeatInterval', '10000'), - ('AgentWebsocketUpgradeEnabled', 'true'), - ('NodeOfflineThreshold', '120000'), - ('AgentUpdateRepo', 'Rain-kl/OpenFlare'), - ('GeoIPProvider', 'ipinfo'), - ('DatabaseAutoCleanupEnabled', 'false'), - ('DatabaseAutoCleanupRetentionDays', '30'), - ('UptimeKumaEnabled', 'false'), - ('UptimeKumaMonitorScope', 'all'), - ('UptimeKumaSyncInterval', '5'), - ('UptimeKumaInterval', '60'), - ('UptimeKumaRetry', '0'), - ('UptimeKumaRetryInterval', '60'), - ('UptimeKumaTimeout', '48'), - ('OpenRestyDefaultServerReturnStatus', '421'), - ('OpenRestyWorkerProcesses', 'auto'), - ('OpenRestyWorkerConnections', '4096'), - ('OpenRestyWorkerRlimitNofile', '65535'), - ('OpenRestyEventsUse', 'epoll'), - ('OpenRestyEventsMultiAcceptEnabled', 'true'), - ('OpenRestyKeepaliveTimeout', '20'), - ('OpenRestyKeepaliveRequests', '1000'), - ('OpenRestyClientHeaderTimeout', '15'), - ('OpenRestyClientBodyTimeout', '15'), - ('OpenRestyClientMaxBodySize', '64m'), - ('OpenRestyLargeClientHeaderBuffers', '4 16k'), - ('OpenRestySendTimeout', '30'), - ('OpenRestyProxyConnectTimeout', '3'), - ('OpenRestyProxySendTimeout', '60'), - ('OpenRestyProxyReadTimeout', '60'), - ('OpenRestyWebsocketEnabled', 'true'), - ('OpenRestyHTTP3Enabled', 'true'), - ('OpenRestyProxyRequestBufferingEnabled', 'false'), - ('OpenRestyProxyBufferingEnabled', 'true'), - ('OpenRestyProxyBuffers', '16 16k'), - ('OpenRestyProxyBufferSize', '8k'), - ('OpenRestyProxyBusyBuffersSize', '64k'), - ('OpenRestyGzipEnabled', 'true'), - ('OpenRestyGzipMinLength', '1024'), - ('OpenRestyGzipCompLevel', '5'), - ('OpenRestyCacheEnabled', 'false'), - ('OpenRestyCacheLevels', '1:2'), - ('OpenRestyCacheInactive', '30m'), - ('OpenRestyCacheMaxSize', '1g'), - ('OpenRestyCacheKeyTemplate', '$scheme$host$request_uri'), - ('OpenRestyCacheLockEnabled', 'true'), - ('OpenRestyCacheLockTimeout', '5s'), - ('OpenRestyCacheUseStale', 'error timeout updating http_500 http_502 http_503 http_504'); - --- +goose Down -DROP TABLE IF EXISTS of_options; \ No newline at end of file diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190002_create_of_origins.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190002_create_of_origins.sql deleted file mode 100644 index e21c04a7..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190002_create_of_origins.sql +++ /dev/null @@ -1,13 +0,0 @@ --- +goose Up -CREATE TABLE IF NOT EXISTS 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 -); -CREATE UNIQUE INDEX IF NOT EXISTS idx_of_origins_address ON of_origins (address); - --- +goose Down -DROP TABLE IF EXISTS of_origins; \ No newline at end of file diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190003_create_of_apply_logs.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190003_create_of_apply_logs.sql deleted file mode 100644 index 31ebd6e8..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190003_create_of_apply_logs.sql +++ /dev/null @@ -1,19 +0,0 @@ --- +goose Up -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 -); - -CREATE INDEX idx_of_apply_logs_node_id ON of_apply_logs(node_id); -CREATE INDEX idx_of_apply_logs_created_at ON of_apply_logs(created_at); - --- +goose Down -DROP TABLE IF EXISTS of_apply_logs; \ No newline at end of file diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190004_create_of_proxy_routes.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190004_create_of_proxy_routes.sql deleted file mode 100644 index 2108c1ff..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190004_create_of_proxy_routes.sql +++ /dev/null @@ -1,43 +0,0 @@ --- +goose Up -CREATE TABLE IF NOT EXISTS of_proxy_routes ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - site_name TEXT NOT NULL DEFAULT '', - domain TEXT NOT NULL, - domains 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, - cert_id INTEGER, - cert_ids TEXT NOT NULL DEFAULT '[]', - domain_cert_ids TEXT NOT NULL DEFAULT '[]', - 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 '', - remark 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 -); -CREATE UNIQUE INDEX IF NOT EXISTS idx_of_proxy_routes_domain ON of_proxy_routes (domain); -CREATE UNIQUE INDEX IF NOT EXISTS idx_of_proxy_routes_site_name ON of_proxy_routes (site_name); -CREATE INDEX IF NOT EXISTS idx_of_proxy_routes_origin_id ON of_proxy_routes (origin_id); -CREATE INDEX IF NOT EXISTS idx_of_proxy_routes_tunnel_node_id ON of_proxy_routes (tunnel_node_id); -CREATE INDEX IF NOT EXISTS idx_of_proxy_routes_pages_project_id ON of_proxy_routes (pages_project_id); - --- +goose Down -DROP TABLE IF EXISTS of_proxy_routes; \ No newline at end of file diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190005_create_of_nodes.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190005_create_of_nodes.sql deleted file mode 100644 index 23d04e69..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190005_create_of_nodes.sql +++ /dev/null @@ -1,44 +0,0 @@ --- +goose Up -CREATE TABLE IF NOT EXISTS 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 -); - -CREATE UNIQUE INDEX IF NOT EXISTS idx_of_nodes_node_id ON of_nodes (node_id); -CREATE INDEX IF NOT EXISTS idx_of_nodes_access_token ON of_nodes (access_token); - --- +goose Down -DROP TABLE IF EXISTS of_nodes; \ No newline at end of file diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190006_create_of_waf_tables.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190006_create_of_waf_tables.sql deleted file mode 100644 index e73a602b..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190006_create_of_waf_tables.sql +++ /dev/null @@ -1,60 +0,0 @@ --- +goose Up -CREATE TABLE IF NOT EXISTS 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, - block_status_code INTEGER NOT NULL DEFAULT 418, - block_response_body TEXT NOT NULL DEFAULT '', - ip_whitelist TEXT NOT NULL DEFAULT '[]', - ip_blacklist TEXT NOT NULL DEFAULT '[]', - ip_whitelist_groups TEXT NOT NULL DEFAULT '[]', - ip_blacklist_groups TEXT NOT NULL DEFAULT '[]', - country_whitelist TEXT NOT NULL DEFAULT '[]', - country_blacklist TEXT NOT NULL DEFAULT '[]', - region_whitelist TEXT NOT NULL DEFAULT '[]', - region_blacklist TEXT NOT NULL DEFAULT '[]', - pow_enabled BOOLEAN NOT NULL DEFAULT FALSE, - pow_config TEXT NOT NULL DEFAULT '{}', - remark TEXT NOT NULL DEFAULT '', - created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP -); -CREATE INDEX IF NOT EXISTS idx_of_waf_rule_groups_is_global ON of_waf_rule_groups (is_global); - -CREATE TABLE IF NOT EXISTS 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 '', - remark TEXT NOT NULL DEFAULT '', - created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP -); -CREATE INDEX IF NOT EXISTS idx_of_waf_ip_groups_type ON of_waf_ip_groups (type); -CREATE INDEX IF NOT EXISTS idx_of_waf_ip_groups_next_sync_at ON of_waf_ip_groups (next_sync_at); - -CREATE TABLE IF NOT EXISTS 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 -); -CREATE UNIQUE INDEX IF NOT EXISTS idx_of_waf_group_route ON of_waf_rule_group_bindings (rule_group_id, proxy_route_id); -CREATE INDEX IF NOT EXISTS idx_of_waf_rule_group_bindings_proxy_route_id ON of_waf_rule_group_bindings (proxy_route_id); - --- +goose Down -DROP TABLE IF EXISTS of_waf_rule_group_bindings; -DROP TABLE IF EXISTS of_waf_ip_groups; -DROP TABLE IF EXISTS of_waf_rule_groups; \ No newline at end of file diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190007_create_of_tls_tables.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190007_create_of_tls_tables.sql deleted file mode 100644 index cf723e2e..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190007_create_of_tls_tables.sql +++ /dev/null @@ -1,61 +0,0 @@ --- +goose Up -CREATE TABLE IF NOT EXISTS 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 -); -CREATE UNIQUE INDEX IF NOT EXISTS idx_of_tls_certificates_name ON of_tls_certificates (name); - -CREATE TABLE IF NOT EXISTS of_managed_domains ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - domain TEXT NOT NULL, - cert_id INTEGER, - enabled INTEGER NOT NULL DEFAULT 1, - remark TEXT NOT NULL DEFAULT '', - created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP -); -CREATE UNIQUE INDEX IF NOT EXISTS idx_of_managed_domains_domain ON of_managed_domains (domain); - -CREATE TABLE IF NOT EXISTS 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 -); - -CREATE TABLE IF NOT EXISTS 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 -); - --- +goose Down -DROP TABLE IF EXISTS of_managed_domains; -DROP TABLE IF EXISTS of_tls_certificates; -DROP TABLE IF EXISTS of_dns_accounts; -DROP TABLE IF EXISTS of_acme_accounts; \ No newline at end of file diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190008_create_of_config_versions.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190008_create_of_config_versions.sql deleted file mode 100644 index 9d98ab94..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190008_create_of_config_versions.sql +++ /dev/null @@ -1,18 +0,0 @@ --- +goose Up -CREATE TABLE IF NOT EXISTS of_config_versions ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - version TEXT NOT NULL, - snapshot_json TEXT NOT NULL, - main_config TEXT NOT NULL DEFAULT '', - rendered_config TEXT NOT NULL, - support_files_json TEXT NOT NULL DEFAULT '[]', - checksum TEXT NOT NULL, - is_active INTEGER NOT NULL DEFAULT 0, - created_by TEXT NOT NULL, - created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP -); -CREATE UNIQUE INDEX IF NOT EXISTS idx_of_config_versions_version ON of_config_versions (version); -CREATE INDEX IF NOT EXISTS idx_of_config_versions_is_active ON of_config_versions (is_active); - --- +goose Down -DROP TABLE IF EXISTS of_config_versions; \ No newline at end of file diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190009_create_of_pages_tables.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190009_create_of_pages_tables.sql deleted file mode 100644 index 4b05564f..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190009_create_of_pages_tables.sql +++ /dev/null @@ -1,53 +0,0 @@ --- +goose Up -CREATE TABLE IF NOT EXISTS 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 -); -CREATE UNIQUE INDEX IF NOT EXISTS idx_of_pages_projects_slug ON of_pages_projects (slug); -CREATE INDEX IF NOT EXISTS idx_of_pages_projects_active_deployment_id ON of_pages_projects (active_deployment_id); - -CREATE TABLE IF NOT EXISTS 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 -); -CREATE INDEX IF NOT EXISTS idx_of_pages_deployments_project_id ON of_pages_deployments (project_id); -CREATE INDEX IF NOT EXISTS idx_of_pages_deployments_checksum ON of_pages_deployments (checksum); -CREATE INDEX IF NOT EXISTS idx_of_pages_deployments_status ON of_pages_deployments (status); - -CREATE TABLE IF NOT EXISTS 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 -); -CREATE INDEX IF NOT EXISTS idx_of_pages_deployment_files_deployment_id ON of_pages_deployment_files (deployment_id); - --- +goose Down -DROP TABLE IF EXISTS of_pages_deployment_files; -DROP TABLE IF EXISTS of_pages_deployments; -DROP TABLE IF EXISTS of_pages_projects; \ No newline at end of file diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190010_create_of_observability_tables.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190010_create_of_observability_tables.sql deleted file mode 100644 index bedc07de..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190010_create_of_observability_tables.sql +++ /dev/null @@ -1,136 +0,0 @@ --- +goose Up -CREATE TABLE IF NOT EXISTS 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 -); - -CREATE UNIQUE INDEX IF NOT EXISTS idx_of_node_system_profiles_node_id ON of_node_system_profiles (node_id); -CREATE INDEX IF NOT EXISTS idx_of_node_system_profiles_reported_at ON of_node_system_profiles (reported_at); - -CREATE TABLE IF NOT EXISTS of_node_metric_snapshots ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - node_id TEXT NOT NULL, - 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 -); - -CREATE INDEX IF NOT EXISTS idx_of_node_metric_snapshots_node_id ON of_node_metric_snapshots (node_id); -CREATE INDEX IF NOT EXISTS idx_of_node_metric_snapshots_captured_at ON of_node_metric_snapshots (captured_at); - -CREATE TABLE IF NOT EXISTS of_node_request_reports ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - node_id TEXT NOT NULL, - window_started_at DATETIME NOT NULL, - window_ended_at DATETIME NOT NULL, - request_count INTEGER NOT NULL DEFAULT 0, - error_count INTEGER NOT NULL DEFAULT 0, - unique_visitor_count INTEGER NOT NULL DEFAULT 0, - status_codes_json TEXT, - top_domains_json TEXT, - source_countries_json TEXT, - created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP -); - -CREATE INDEX IF NOT EXISTS idx_of_node_request_reports_node_id ON of_node_request_reports (node_id); -CREATE INDEX IF NOT EXISTS idx_of_node_request_reports_window_started_at ON of_node_request_reports (window_started_at); -CREATE INDEX IF NOT EXISTS idx_of_node_request_reports_window_ended_at ON of_node_request_reports (window_ended_at); - -CREATE TABLE IF NOT EXISTS 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 -); - -CREATE INDEX IF NOT EXISTS idx_of_node_health_events_node_id ON of_node_health_events (node_id); -CREATE INDEX IF NOT EXISTS idx_of_node_health_events_event_type ON of_node_health_events (event_type); -CREATE INDEX IF NOT EXISTS idx_of_node_health_events_status ON of_node_health_events (status); -CREATE INDEX IF NOT EXISTS idx_of_node_health_events_first_triggered_at ON of_node_health_events (first_triggered_at); -CREATE INDEX IF NOT EXISTS idx_of_node_health_events_last_triggered_at ON of_node_health_events (last_triggered_at); -CREATE INDEX IF NOT EXISTS idx_of_node_health_events_reported_at ON of_node_health_events (reported_at); -CREATE INDEX IF NOT EXISTS idx_of_node_health_events_resolved_at ON of_node_health_events (resolved_at); - -CREATE TABLE IF NOT EXISTS of_node_obs_openresty ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - node_id TEXT NOT NULL, - captured_at DATETIME NOT NULL, - openresty_rx_bytes INTEGER NOT NULL DEFAULT 0, - openresty_tx_bytes INTEGER NOT NULL DEFAULT 0, - openresty_connections INTEGER NOT NULL DEFAULT 0, - created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP -); - -CREATE INDEX IF NOT EXISTS idx_of_node_obs_openresty_node_id ON of_node_obs_openresty (node_id); -CREATE INDEX IF NOT EXISTS idx_of_node_obs_openresty_captured_at ON of_node_obs_openresty (captured_at); - -CREATE TABLE IF NOT EXISTS of_node_obs_frps ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - node_id TEXT NOT NULL, - 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, - created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP -); - -CREATE INDEX IF NOT EXISTS idx_of_node_obs_frps_node_id ON of_node_obs_frps (node_id); -CREATE INDEX IF NOT EXISTS idx_of_node_obs_frps_captured_at ON of_node_obs_frps (captured_at); - -CREATE TABLE IF NOT EXISTS of_node_access_logs ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - node_id TEXT NOT NULL, - 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 '', - status_code INTEGER NOT NULL DEFAULT 0, - created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP -); - -CREATE INDEX IF NOT EXISTS idx_of_node_access_logs_node_id ON of_node_access_logs (node_id); -CREATE INDEX IF NOT EXISTS idx_of_node_access_logs_logged_at ON of_node_access_logs (logged_at); -CREATE INDEX IF NOT EXISTS idx_of_node_access_logs_remote_addr ON of_node_access_logs (remote_addr); -CREATE INDEX IF NOT EXISTS idx_of_node_access_logs_host ON of_node_access_logs (host); -CREATE INDEX IF NOT EXISTS idx_of_node_access_logs_status_code ON of_node_access_logs (status_code); - --- +goose Down -DROP TABLE IF EXISTS of_node_access_logs; -DROP TABLE IF EXISTS of_node_obs_frps; -DROP TABLE IF EXISTS of_node_obs_openresty; -DROP TABLE IF EXISTS of_node_health_events; -DROP TABLE IF EXISTS of_node_request_reports; -DROP TABLE IF EXISTS of_node_metric_snapshots; -DROP TABLE IF EXISTS of_node_system_profiles; \ No newline at end of file diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190011_add_of_node_access_logs_composite_index.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190011_add_of_node_access_logs_composite_index.sql deleted file mode 100644 index a478ae9d..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190011_add_of_node_access_logs_composite_index.sql +++ /dev/null @@ -1,5 +0,0 @@ --- +goose Up -CREATE INDEX IF NOT EXISTS idx_of_node_access_logs_node_id_logged_at ON of_node_access_logs (node_id, logged_at); - --- +goose Down -DROP INDEX IF EXISTS idx_of_node_access_logs_node_id_logged_at; \ No newline at end of file diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190012_create_of_node_obs_frpc.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190012_create_of_node_obs_frpc.sql deleted file mode 100644 index 033e6f59..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190012_create_of_node_obs_frpc.sql +++ /dev/null @@ -1,15 +0,0 @@ --- +goose Up -CREATE TABLE IF NOT EXISTS of_node_obs_frpc ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - node_id TEXT NOT NULL, - 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 -); - -CREATE INDEX IF NOT EXISTS idx_of_node_obs_frpc_node_id ON of_node_obs_frpc (node_id); -CREATE INDEX IF NOT EXISTS idx_of_node_obs_frpc_captured_at ON of_node_obs_frpc (captured_at); - --- +goose Down -DROP TABLE IF EXISTS of_node_obs_frpc; \ No newline at end of file diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190013_seed_openflare_schedules.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190013_seed_openflare_schedules.sql deleted file mode 100644 index 6434f3c1..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190013_seed_openflare_schedules.sql +++ /dev/null @@ -1,11 +0,0 @@ --- +goose Up -INSERT INTO w_schedules (id, name, task_type, cron, payload, is_active, created_at, updated_at) -VALUES - (101, 'OpenFlare SSL 自动续期', 'of_ssl_renew', '0 0 * * *', '{}', 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - (102, 'OpenFlare 可观测数据自动清理', 'of_database_auto_cleanup', '0 3 * * *', '{}', 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - (103, 'OpenFlare WAF IP 组同步', 'of_waf_ip_group_sync', '*/5 * * * *', '{}', 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - (104, 'OpenFlare Uptime Kuma 同步', 'of_uptime_kuma_sync', '* * * * *', '{}', 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP) -ON CONFLICT (id) DO NOTHING; - --- +goose Down -DELETE FROM w_schedules WHERE id IN (101, 102, 103, 104); \ No newline at end of file diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190014_add_pages_deployment_upload_id.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190014_add_pages_deployment_upload_id.sql deleted file mode 100644 index 6804478c..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606190014_add_pages_deployment_upload_id.sql +++ /dev/null @@ -1,10 +0,0 @@ --- +goose Up -ALTER TABLE of_pages_deployments - ADD COLUMN upload_id INTEGER NOT NULL DEFAULT 0; - -CREATE INDEX IF NOT EXISTS idx_of_pages_deployments_upload_id ON of_pages_deployments (upload_id); - --- +goose Down -DROP INDEX IF EXISTS idx_of_pages_deployments_upload_id; - --- SQLite cannot drop columns without table rebuild; keep upload_id on rollback. \ No newline at end of file diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606200001_rebrand_openflare_defaults.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606200001_rebrand_openflare_defaults.sql deleted file mode 100644 index 1de73272..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606200001_rebrand_openflare_defaults.sql +++ /dev/null @@ -1,31 +0,0 @@ --- +goose Up -UPDATE w_system_configs -SET value = 'OpenFlare', updated_at = CURRENT_TIMESTAMP -WHERE key = 'site_name' AND value = 'Wavelet'; - -UPDATE w_system_configs -SET value = 'Rain-kl/OpenFlare', updated_at = CURRENT_TIMESTAMP -WHERE key = 'update_upstream_repository' AND value = 'Rain-kl/Wavelet'; - -UPDATE w_templates -SET - subject = REPLACE(subject, 'Wavelet', 'OpenFlare'), - content = REPLACE(content, 'Wavelet', 'OpenFlare'), - updated_at = CURRENT_TIMESTAMP -WHERE key IN ('login_email', 'register_email'); - --- +goose Down -UPDATE w_system_configs -SET value = 'Wavelet', updated_at = CURRENT_TIMESTAMP -WHERE key = 'site_name' AND value = 'OpenFlare'; - -UPDATE w_system_configs -SET value = 'Rain-kl/Wavelet', updated_at = CURRENT_TIMESTAMP -WHERE key = 'update_upstream_repository' AND value = 'Rain-kl/OpenFlare'; - -UPDATE w_templates -SET - subject = REPLACE(subject, 'OpenFlare', 'Wavelet'), - content = REPLACE(content, 'OpenFlare', 'Wavelet'), - updated_at = CURRENT_TIMESTAMP -WHERE key IN ('login_email', 'register_email'); \ No newline at end of file diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606200002_update_security_defaults.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606200002_update_security_defaults.sql deleted file mode 100644 index 68484a8b..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606200002_update_security_defaults.sql +++ /dev/null @@ -1,17 +0,0 @@ --- +goose Up -UPDATE w_system_configs -SET value = 'false', updated_at = CURRENT_TIMESTAMP -WHERE key = 'registration_enabled' AND value = 'true'; - -UPDATE w_system_configs -SET value = 'false', updated_at = CURRENT_TIMESTAMP -WHERE key = 'password_register_enabled' AND value = 'true'; - --- +goose Down -UPDATE w_system_configs -SET value = 'true', updated_at = CURRENT_TIMESTAMP -WHERE key = 'registration_enabled' AND value = 'false'; - -UPDATE w_system_configs -SET value = 'true', updated_at = CURRENT_TIMESTAMP -WHERE key = 'password_register_enabled' AND value = 'false'; \ No newline at end of file diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606200003_remove_legacy_rate_limit_options.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606200003_remove_legacy_rate_limit_options.sql deleted file mode 100644 index 8215213f..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606200003_remove_legacy_rate_limit_options.sql +++ /dev/null @@ -1,19 +0,0 @@ --- +goose Up -DELETE FROM of_options -WHERE key IN ( - 'GlobalApiRateLimitNum', - 'GlobalApiRateLimitDuration', - 'GlobalWebRateLimitNum', - 'GlobalWebRateLimitDuration', - 'CriticalRateLimitNum', - 'CriticalRateLimitDuration' -); - --- +goose Down -INSERT OR IGNORE INTO of_options (key, value) VALUES - ('GlobalApiRateLimitNum', '300'), - ('GlobalApiRateLimitDuration', '180'), - ('GlobalWebRateLimitNum', '300'), - ('GlobalWebRateLimitDuration', '180'), - ('CriticalRateLimitNum', '100'), - ('CriticalRateLimitDuration', '1200'); \ No newline at end of file diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606200004_drop_of_node_access_logs.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606200004_drop_of_node_access_logs.sql deleted file mode 100644 index 06fe18f2..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606200004_drop_of_node_access_logs.sql +++ /dev/null @@ -1,28 +0,0 @@ --- +goose Up -DROP INDEX IF EXISTS idx_of_node_access_logs_node_id_logged_at; -DROP INDEX IF EXISTS idx_of_node_access_logs_status_code; -DROP INDEX IF EXISTS idx_of_node_access_logs_host; -DROP INDEX IF EXISTS idx_of_node_access_logs_remote_addr; -DROP INDEX IF EXISTS idx_of_node_access_logs_logged_at; -DROP INDEX IF EXISTS idx_of_node_access_logs_node_id; -DROP TABLE IF EXISTS of_node_access_logs; - --- +goose Down -CREATE TABLE of_node_access_logs ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - node_id TEXT NOT NULL, - 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 '', - status_code INTEGER NOT NULL DEFAULT 0, - created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP -); - -CREATE INDEX idx_of_node_access_logs_node_id ON of_node_access_logs (node_id); -CREATE INDEX idx_of_node_access_logs_logged_at ON of_node_access_logs (logged_at); -CREATE INDEX idx_of_node_access_logs_remote_addr ON of_node_access_logs (remote_addr); -CREATE INDEX idx_of_node_access_logs_host ON of_node_access_logs (host); -CREATE INDEX idx_of_node_access_logs_status_code ON of_node_access_logs (status_code); -CREATE INDEX idx_of_node_access_logs_node_id_logged_at ON of_node_access_logs (node_id, logged_at); \ No newline at end of file diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606200005_drop_of_node_observability_timeseries.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606200005_drop_of_node_observability_timeseries.sql deleted file mode 100644 index 6aa7fe7b..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606200005_drop_of_node_observability_timeseries.sql +++ /dev/null @@ -1,98 +0,0 @@ --- +goose Up -DROP INDEX IF EXISTS idx_of_node_obs_frpc_captured_at; -DROP INDEX IF EXISTS idx_of_node_obs_frpc_node_id; -DROP TABLE IF EXISTS of_node_obs_frpc; - -DROP INDEX IF EXISTS idx_of_node_obs_frps_captured_at; -DROP INDEX IF EXISTS idx_of_node_obs_frps_node_id; -DROP TABLE IF EXISTS of_node_obs_frps; - -DROP INDEX IF EXISTS idx_of_node_obs_openresty_captured_at; -DROP INDEX IF EXISTS idx_of_node_obs_openresty_node_id; -DROP TABLE IF EXISTS of_node_obs_openresty; - -DROP INDEX IF EXISTS idx_of_node_request_reports_window_ended_at; -DROP INDEX IF EXISTS idx_of_node_request_reports_window_started_at; -DROP INDEX IF EXISTS idx_of_node_request_reports_node_id; -DROP TABLE IF EXISTS of_node_request_reports; - -DROP INDEX IF EXISTS idx_of_node_metric_snapshots_captured_at; -DROP INDEX IF EXISTS idx_of_node_metric_snapshots_node_id; -DROP TABLE IF EXISTS of_node_metric_snapshots; - --- +goose Down -CREATE TABLE IF NOT EXISTS of_node_metric_snapshots ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - node_id TEXT NOT NULL, - 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 -); - -CREATE INDEX IF NOT EXISTS idx_of_node_metric_snapshots_node_id ON of_node_metric_snapshots (node_id); -CREATE INDEX IF NOT EXISTS idx_of_node_metric_snapshots_captured_at ON of_node_metric_snapshots (captured_at); - -CREATE TABLE IF NOT EXISTS of_node_request_reports ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - node_id TEXT NOT NULL, - window_started_at DATETIME NOT NULL, - window_ended_at DATETIME NOT NULL, - request_count INTEGER NOT NULL DEFAULT 0, - error_count INTEGER NOT NULL DEFAULT 0, - unique_visitor_count INTEGER NOT NULL DEFAULT 0, - status_codes_json TEXT, - top_domains_json TEXT, - source_countries_json TEXT, - created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP -); - -CREATE INDEX IF NOT EXISTS idx_of_node_request_reports_node_id ON of_node_request_reports (node_id); -CREATE INDEX IF NOT EXISTS idx_of_node_request_reports_window_started_at ON of_node_request_reports (window_started_at); -CREATE INDEX IF NOT EXISTS idx_of_node_request_reports_window_ended_at ON of_node_request_reports (window_ended_at); - -CREATE TABLE IF NOT EXISTS of_node_obs_openresty ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - node_id TEXT NOT NULL, - captured_at DATETIME NOT NULL, - openresty_rx_bytes INTEGER NOT NULL DEFAULT 0, - openresty_tx_bytes INTEGER NOT NULL DEFAULT 0, - openresty_connections INTEGER NOT NULL DEFAULT 0, - created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP -); - -CREATE INDEX IF NOT EXISTS idx_of_node_obs_openresty_node_id ON of_node_obs_openresty (node_id); -CREATE INDEX IF NOT EXISTS idx_of_node_obs_openresty_captured_at ON of_node_obs_openresty (captured_at); - -CREATE TABLE IF NOT EXISTS of_node_obs_frps ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - node_id TEXT NOT NULL, - 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, - created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP -); - -CREATE INDEX IF NOT EXISTS idx_of_node_obs_frps_node_id ON of_node_obs_frps (node_id); -CREATE INDEX IF NOT EXISTS idx_of_node_obs_frps_captured_at ON of_node_obs_frps (captured_at); - -CREATE TABLE IF NOT EXISTS of_node_obs_frpc ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - node_id TEXT NOT NULL, - 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 -); - -CREATE INDEX IF NOT EXISTS idx_of_node_obs_frpc_node_id ON of_node_obs_frpc (node_id); -CREATE INDEX IF NOT EXISTS idx_of_node_obs_frpc_captured_at ON of_node_obs_frpc (captured_at); \ No newline at end of file diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606200006_migrate_legacy_data.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606200006_migrate_legacy_data.sql deleted file mode 100644 index 9840f6cd..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606200006_migrate_legacy_data.sql +++ /dev/null @@ -1,7 +0,0 @@ --- +goose Up --- Historical copy from legacy_* tables into of_* / w_* (formerly Go migration). --- Already-applied environments keep their data; new installs have no legacy_* sources. -SELECT 1; - --- +goose Down -SELECT 1; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606200007_sync_of_waf_binding_sequence.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606200007_sync_of_waf_binding_sequence.sql deleted file mode 100644 index 4fa75e57..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606200007_sync_of_waf_binding_sequence.sql +++ /dev/null @@ -1,5 +0,0 @@ --- +goose Up -SELECT 1; - --- +goose Down -SELECT 1; \ No newline at end of file diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606220001_remove_legacy_auth_options.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606220001_remove_legacy_auth_options.sql deleted file mode 100644 index 8e1c3e8c..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606220001_remove_legacy_auth_options.sql +++ /dev/null @@ -1,21 +0,0 @@ --- +goose Up -DELETE FROM of_options -WHERE key IN ( - 'GitHubOAuthEnabled', - 'GitHubClientId', - 'GitHubClientSecret', - 'WeChatAuthEnabled', - 'WeChatServerAddress', - 'WeChatServerToken', - 'WeChatAccountQRCodeImageURL' -); - --- +goose Down -INSERT OR IGNORE INTO of_options (key, value) VALUES - ('GitHubOAuthEnabled', 'false'), - ('GitHubClientId', ''), - ('GitHubClientSecret', ''), - ('WeChatAuthEnabled', 'false'), - ('WeChatServerAddress', ''), - ('WeChatServerToken', ''), - ('WeChatAccountQRCodeImageURL', ''); diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606220002_remove_notice_option.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606220002_remove_notice_option.sql deleted file mode 100644 index 8ac27973..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606220002_remove_notice_option.sql +++ /dev/null @@ -1,5 +0,0 @@ --- +goose Up -DELETE FROM of_options WHERE key = 'Notice'; - --- +goose Down -INSERT OR IGNORE INTO of_options (key, value) VALUES ('Notice', ''); diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606220003_add_frps_web_ui_config.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606220003_add_frps_web_ui_config.sql deleted file mode 100644 index e4b2db58..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606220003_add_frps_web_ui_config.sql +++ /dev/null @@ -1,9 +0,0 @@ --- +goose Up -INSERT INTO w_system_configs (key, value, type, visibility, description, created_at, updated_at) -VALUES - ('relay_frps_web_ui_enabled', 'false', 'business', 0, '是否启用 FRPS 内置 Web 管理界面', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('relay_frps_web_ui_port', '17500', 'business', 0, 'FRPS 内置 Web 管理界面端口', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP) -ON CONFLICT (key) DO NOTHING; - --- +goose Down -DELETE FROM w_system_configs WHERE key IN ('relay_frps_web_ui_enabled', 'relay_frps_web_ui_port'); diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606220004_migrate_of_options_to_system_configs.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606220004_migrate_of_options_to_system_configs.sql deleted file mode 100644 index 655568c4..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606220004_migrate_of_options_to_system_configs.sql +++ /dev/null @@ -1,291 +0,0 @@ --- +goose Up --- 将 of_options 配置迁移到 w_system_configs(仅迁移新配置,已存在的不重复) - --- Agent 相关配置 (business, visibility=0) -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'agent_discovery_token', COALESCE(value, ''), 'business', 0, 'Agent 发现令牌' -FROM of_options WHERE key = 'AgentDiscoveryToken'; - -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'agent_heartbeat_interval', value, 'business', 0, 'Agent 心跳间隔(毫秒)' -FROM of_options WHERE key = 'AgentHeartbeatInterval'; - -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'agent_websocket_upgrade_enabled', value, 'business', 0, 'Agent WebSocket 升级开关' -FROM of_options WHERE key = 'AgentWebsocketUpgradeEnabled'; - -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'node_offline_threshold', value, 'business', 0, '节点离线阈值(毫秒)' -FROM of_options WHERE key = 'NodeOfflineThreshold'; - -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'agent_update_repo', value, 'business', 0, 'Agent 更新仓库' -FROM of_options WHERE key = 'AgentUpdateRepo'; - --- 系统功能配置 (business, visibility=0) -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'geoip_provider', value, 'business', 0, 'GeoIP 服务商' -FROM of_options WHERE key = 'GeoIPProvider'; - -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'database_auto_cleanup_enabled', value, 'business', 0, '数据库自动清理开关' -FROM of_options WHERE key = 'DatabaseAutoCleanupEnabled'; - -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'database_auto_cleanup_retention_days', value, 'business', 0, '数据库保留天数' -FROM of_options WHERE key = 'DatabaseAutoCleanupRetentionDays'; - --- UptimeKuma 集成配置 (business, visibility=0) -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'uptime_kuma_enabled', value, 'business', 0, 'UptimeKuma 集成开关' -FROM of_options WHERE key = 'UptimeKumaEnabled'; - -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'uptime_kuma_url', COALESCE(value, ''), 'business', 0, 'UptimeKuma URL' -FROM of_options WHERE key = 'UptimeKumaUrl'; - -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'uptime_kuma_username', COALESCE(value, ''), 'business', 0, 'UptimeKuma 用户名' -FROM of_options WHERE key = 'UptimeKumaUsername'; - -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'uptime_kuma_password', COALESCE(value, ''), 'business', 0, 'UptimeKuma 密码' -FROM of_options WHERE key = 'UptimeKumaPassword'; - -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'uptime_kuma_monitor_scope', value, 'business', 0, 'UptimeKuma 监控范围' -FROM of_options WHERE key = 'UptimeKumaMonitorScope'; - -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'uptime_kuma_selected_sites', COALESCE(value, ''), 'business', 0, 'UptimeKuma 选定站点' -FROM of_options WHERE key = 'UptimeKumaSelectedSites'; - -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'uptime_kuma_sync_interval', value, 'business', 0, 'UptimeKuma 同步间隔(分钟)' -FROM of_options WHERE key = 'UptimeKumaSyncInterval'; - -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'uptime_kuma_interval', value, 'business', 0, 'UptimeKuma 监控间隔(秒)' -FROM of_options WHERE key = 'UptimeKumaInterval'; - -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'uptime_kuma_retry', value, 'business', 0, 'UptimeKuma 重试次数' -FROM of_options WHERE key = 'UptimeKumaRetry'; - -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'uptime_kuma_retry_interval', value, 'business', 0, 'UptimeKuma 重试间隔(秒)' -FROM of_options WHERE key = 'UptimeKumaRetryInterval'; - -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'uptime_kuma_timeout', value, 'business', 0, 'UptimeKuma 超时(秒)' -FROM of_options WHERE key = 'UptimeKumaTimeout'; - --- OpenResty 配置(全部 business 类型,visibility=0) -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_default_server_return_status', value, 'business', 0, '默认服务器返回状态码' -FROM of_options WHERE key = 'OpenRestyDefaultServerReturnStatus'; - -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_worker_processes', value, 'business', 0, 'Worker 进程数' -FROM of_options WHERE key = 'OpenRestyWorkerProcesses'; - -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_worker_connections', value, 'business', 0, 'Worker 连接数' -FROM of_options WHERE key = 'OpenRestyWorkerConnections'; - -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_worker_rlimit_nofile', value, 'business', 0, 'Worker 文件描述符限制' -FROM of_options WHERE key = 'OpenRestyWorkerRlimitNofile'; - -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_events_use', value, 'business', 0, '事件模型' -FROM of_options WHERE key = 'OpenRestyEventsUse'; - -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_events_multi_accept_enabled', value, 'business', 0, '多路接受开关' -FROM of_options WHERE key = 'OpenRestyEventsMultiAcceptEnabled'; - -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_keepalive_timeout', value, 'business', 0, 'Keepalive 超时(秒)' -FROM of_options WHERE key = 'OpenRestyKeepaliveTimeout'; - -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_keepalive_requests', value, 'business', 0, 'Keepalive 请求数' -FROM of_options WHERE key = 'OpenRestyKeepaliveRequests'; - -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_client_header_timeout', value, 'business', 0, '客户端头超时(秒)' -FROM of_options WHERE key = 'OpenRestyClientHeaderTimeout'; - -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_client_body_timeout', value, 'business', 0, '客户端体超时(秒)' -FROM of_options WHERE key = 'OpenRestyClientBodyTimeout'; - -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_client_max_body_size', value, 'business', 0, '客户端最大体大小' -FROM of_options WHERE key = 'OpenRestyClientMaxBodySize'; - -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_large_client_header_buffers', value, 'business', 0, '大客户端头缓冲区' -FROM of_options WHERE key = 'OpenRestyLargeClientHeaderBuffers'; - -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_send_timeout', value, 'business', 0, '发送超时(秒)' -FROM of_options WHERE key = 'OpenRestySendTimeout'; - -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_resolvers', COALESCE(value, ''), 'business', 0, 'DNS 解析器' -FROM of_options WHERE key = 'OpenRestyResolvers'; - -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_proxy_connect_timeout', value, 'business', 0, '代理连接超时(秒)' -FROM of_options WHERE key = 'OpenRestyProxyConnectTimeout'; - -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_proxy_send_timeout', value, 'business', 0, '代理发送超时(秒)' -FROM of_options WHERE key = 'OpenRestyProxySendTimeout'; - -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_proxy_read_timeout', value, 'business', 0, '代理读取超时(秒)' -FROM of_options WHERE key = 'OpenRestyProxyReadTimeout'; - -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_websocket_enabled', value, 'business', 0, 'WebSocket 支持开关' -FROM of_options WHERE key = 'OpenRestyWebsocketEnabled'; - -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_http3_enabled', value, 'business', 0, 'HTTP/3 支持开关' -FROM of_options WHERE key = 'OpenRestyHTTP3Enabled'; - -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_proxy_request_buffering_enabled', value, 'business', 0, '代理请求缓冲开关' -FROM of_options WHERE key = 'OpenRestyProxyRequestBufferingEnabled'; - -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_proxy_buffering_enabled', value, 'business', 0, '代理响应缓冲开关' -FROM of_options WHERE key = 'OpenRestyProxyBufferingEnabled'; - -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_proxy_buffers', value, 'business', 0, '代理缓冲区' -FROM of_options WHERE key = 'OpenRestyProxyBuffers'; - -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_proxy_buffer_size', value, 'business', 0, '代理缓冲区大小' -FROM of_options WHERE key = 'OpenRestyProxyBufferSize'; - -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_proxy_busy_buffers_size', value, 'business', 0, '代理繁忙缓冲区大小' -FROM of_options WHERE key = 'OpenRestyProxyBusyBuffersSize'; - -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_gzip_enabled', value, 'business', 0, 'Gzip 压缩开关' -FROM of_options WHERE key = 'OpenRestyGzipEnabled'; - -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_gzip_min_length', value, 'business', 0, 'Gzip 最小长度' -FROM of_options WHERE key = 'OpenRestyGzipMinLength'; - -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_gzip_comp_level', value, 'business', 0, 'Gzip 压缩级别' -FROM of_options WHERE key = 'OpenRestyGzipCompLevel'; - -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_cache_enabled', value, 'business', 0, '缓存开关' -FROM of_options WHERE key = 'OpenRestyCacheEnabled'; - -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_cache_path', COALESCE(value, ''), 'business', 0, '缓存路径' -FROM of_options WHERE key = 'OpenRestyCachePath'; - -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_cache_levels', value, 'business', 0, '缓存层级' -FROM of_options WHERE key = 'OpenRestyCacheLevels'; - -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_cache_inactive', value, 'business', 0, '缓存不活跃时间' -FROM of_options WHERE key = 'OpenRestyCacheInactive'; - -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_cache_max_size', value, 'business', 0, '缓存最大大小' -FROM of_options WHERE key = 'OpenRestyCacheMaxSize'; - -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_cache_key_template', value, 'business', 0, '缓存键模板' -FROM of_options WHERE key = 'OpenRestyCacheKeyTemplate'; - -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_cache_lock_enabled', value, 'business', 0, '缓存锁开关' -FROM of_options WHERE key = 'OpenRestyCacheLockEnabled'; - -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_cache_lock_timeout', value, 'business', 0, '缓存锁超时' -FROM of_options WHERE key = 'OpenRestyCacheLockTimeout'; - -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_cache_use_stale', value, 'business', 0, '缓存失效策略' -FROM of_options WHERE key = 'OpenRestyCacheUseStale'; - -INSERT OR REPLACE INTO w_system_configs (key, value, type, visibility, description) -SELECT 'openresty_main_config_template', value, 'business', 0, '主配置模板' -FROM of_options WHERE key = 'OpenRestyMainConfigTemplate'; - --- +goose Down --- 回滚时删除所有迁移的配置项 -DELETE FROM w_system_configs WHERE key IN ( - 'agent_discovery_token', - 'agent_heartbeat_interval', - 'agent_websocket_upgrade_enabled', - 'node_offline_threshold', - 'agent_update_repo', - 'geoip_provider', - 'database_auto_cleanup_enabled', - 'database_auto_cleanup_retention_days', - 'uptime_kuma_enabled', - 'uptime_kuma_url', - 'uptime_kuma_username', - 'uptime_kuma_password', - 'uptime_kuma_monitor_scope', - 'uptime_kuma_selected_sites', - 'uptime_kuma_sync_interval', - 'uptime_kuma_interval', - 'uptime_kuma_retry', - 'uptime_kuma_retry_interval', - 'uptime_kuma_timeout', - 'openresty_default_server_return_status', - 'openresty_worker_processes', - 'openresty_worker_connections', - 'openresty_worker_rlimit_nofile', - 'openresty_events_use', - 'openresty_events_multi_accept_enabled', - 'openresty_keepalive_timeout', - 'openresty_keepalive_requests', - 'openresty_client_header_timeout', - 'openresty_client_body_timeout', - 'openresty_client_max_body_size', - 'openresty_large_client_header_buffers', - 'openresty_send_timeout', - 'openresty_resolvers', - 'openresty_proxy_connect_timeout', - 'openresty_proxy_send_timeout', - 'openresty_proxy_read_timeout', - 'openresty_websocket_enabled', - 'openresty_http3_enabled', - 'openresty_proxy_request_buffering_enabled', - 'openresty_proxy_buffering_enabled', - 'openresty_proxy_buffers', - 'openresty_proxy_buffer_size', - 'openresty_proxy_busy_buffers_size', - 'openresty_gzip_enabled', - 'openresty_gzip_min_length', - 'openresty_gzip_comp_level', - 'openresty_cache_enabled', - 'openresty_cache_path', - 'openresty_cache_levels', - 'openresty_cache_inactive', - 'openresty_cache_max_size', - 'openresty_cache_key_template', - 'openresty_cache_lock_enabled', - 'openresty_cache_lock_timeout', - 'openresty_cache_use_stale', - 'openresty_main_config_template' -); diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606220005_drop_of_options.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606220005_drop_of_options.sql deleted file mode 100644 index ded21037..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606220005_drop_of_options.sql +++ /dev/null @@ -1,10 +0,0 @@ --- +goose Up --- of_options 配置已于 202606220004 迁移至 w_system_configs,删除遗留表。 -DROP TABLE IF EXISTS of_options; - --- +goose Down --- 回滚时重建空表结构(数据无法恢复,迁移来源已为 w_system_configs)。 -CREATE TABLE IF NOT EXISTS of_options ( - key TEXT PRIMARY KEY, - value TEXT NOT NULL DEFAULT '' -); diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606270001_make_version_primary_key.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606270001_make_version_primary_key.sql deleted file mode 100644 index 6507e759..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606270001_make_version_primary_key.sql +++ /dev/null @@ -1,46 +0,0 @@ --- +goose Up --- SQLite table reconstruction to set version as primary key and drop id column - --- 1. 创建临时新表 -CREATE TABLE of_config_versions_new ( - 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 -); - --- 2. 拷贝数据 -INSERT INTO of_config_versions_new (version, snapshot_json, main_config, rendered_config, support_files_json, checksum, is_active, created_by, created_at) -SELECT version, snapshot_json, main_config, rendered_config, support_files_json, checksum, is_active, created_by, created_at -FROM of_config_versions; - --- 3. 删除旧表 -DROP TABLE of_config_versions; - --- 4. 重命名新表 -ALTER TABLE of_config_versions_new RENAME TO of_config_versions; - --- 5. 重建索引(is_active 索引) -CREATE INDEX IF NOT EXISTS idx_of_config_versions_is_active ON of_config_versions (is_active); - --- +goose Down -DROP TABLE IF EXISTS of_config_versions; -CREATE TABLE of_config_versions ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - version VARCHAR(32) NOT NULL, - 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 -); -CREATE UNIQUE INDEX IF NOT EXISTS idx_of_config_versions_version ON of_config_versions (version); -CREATE INDEX IF NOT EXISTS idx_of_config_versions_is_active ON of_config_versions (is_active); diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606300001_sync_all_legacy_sequences.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606300001_sync_all_legacy_sequences.sql deleted file mode 100644 index 013e54ae..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202606300001_sync_all_legacy_sequences.sql +++ /dev/null @@ -1,5 +0,0 @@ --- +goose Up -SELECT 1; - --- +goose Down -SELECT 1; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202607120001_create_zone_domain_tables.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202607120001_create_zone_domain_tables.sql deleted file mode 100644 index 637fe80e..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202607120001_create_zone_domain_tables.sql +++ /dev/null @@ -1,28 +0,0 @@ --- +goose Up -CREATE TABLE IF NOT EXISTS of_zones ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - domain TEXT NOT NULL, - remark TEXT NOT NULL DEFAULT '', - created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP -); -CREATE UNIQUE INDEX IF NOT EXISTS idx_of_zones_domain ON of_zones (domain); - -CREATE TABLE IF NOT EXISTS of_zone_domains ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - zone_id INTEGER NOT NULL, - proxy_route_id INTEGER, - domain TEXT NOT NULL, - cert_id INTEGER, - remark TEXT NOT NULL DEFAULT '', - created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP -); -CREATE UNIQUE INDEX IF NOT EXISTS idx_of_zone_domains_domain ON of_zone_domains (domain); -CREATE INDEX IF NOT EXISTS idx_of_zone_domains_zone_id ON of_zone_domains (zone_id); -CREATE INDEX IF NOT EXISTS idx_of_zone_domains_proxy_route_id ON of_zone_domains (proxy_route_id); -CREATE INDEX IF NOT EXISTS idx_of_zone_domains_cert_id ON of_zone_domains (cert_id); - --- +goose Down -DROP TABLE IF EXISTS of_zone_domains; -DROP TABLE IF EXISTS of_zones; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202607120002_import_zone_domains.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202607120002_import_zone_domains.sql deleted file mode 100644 index 97890d8c..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202607120002_import_zone_domains.sql +++ /dev/null @@ -1,8 +0,0 @@ --- +goose Up --- Marker: Zone 域名从旧路由列 / of_managed_domains 的导入由 migrator.Migrate() --- 在全部 goose SQL 应用后自动执行(publicsuffix 根域解析无法用纯 SQL 正确完成)。 --- 本文件仅占位版本号,保证升级链路有序:建表 → 导入 → 删旧列。 -SELECT 1; - --- +goose Down -SELECT 1; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202607130001_drop_legacy_route_domain_columns.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202607130001_drop_legacy_route_domain_columns.sql deleted file mode 100644 index 69adac5f..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202607130001_drop_legacy_route_domain_columns.sql +++ /dev/null @@ -1,138 +0,0 @@ --- +goose Up --- 第二阶段:重建 of_proxy_routes(去掉冗余域名/证书列)并删除 of_managed_domains。 - -PRAGMA foreign_keys=OFF; - -CREATE TABLE of_proxy_routes_new ( - 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 '', - remark 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 -); - -INSERT INTO of_proxy_routes_new ( - id, site_name, origin_id, origin_url, origin_host, upstreams, enabled, - enable_https, redirect_http, limit_conn_per_server, limit_conn_per_ip, limit_rate, - cache_enabled, cache_policy, cache_rules, custom_headers, basic_auth_enabled, - basic_auth_username, basic_auth_password, remark, upstream_type, tunnel_node_id, - tunnel_target_addr, tunnel_target_protocol, pages_project_id, created_at, updated_at -) -SELECT - id, site_name, origin_id, origin_url, origin_host, upstreams, enabled, - enable_https, redirect_http, limit_conn_per_server, limit_conn_per_ip, limit_rate, - cache_enabled, cache_policy, cache_rules, custom_headers, basic_auth_enabled, - basic_auth_username, basic_auth_password, remark, upstream_type, tunnel_node_id, - tunnel_target_addr, tunnel_target_protocol, pages_project_id, created_at, updated_at -FROM of_proxy_routes; - -DROP TABLE of_proxy_routes; -ALTER TABLE of_proxy_routes_new RENAME TO of_proxy_routes; - -CREATE UNIQUE INDEX IF NOT EXISTS idx_of_proxy_routes_site_name ON of_proxy_routes (site_name); -CREATE INDEX IF NOT EXISTS idx_of_proxy_routes_origin_id ON of_proxy_routes (origin_id); -CREATE INDEX IF NOT EXISTS idx_of_proxy_routes_tunnel_node_id ON of_proxy_routes (tunnel_node_id); -CREATE INDEX IF NOT EXISTS idx_of_proxy_routes_pages_project_id ON of_proxy_routes (pages_project_id); - -DROP TABLE IF EXISTS of_managed_domains; - -PRAGMA foreign_keys=ON; - --- +goose Down --- 仅恢复开发库结构,不回填历史域名/证书数据。 - -PRAGMA foreign_keys=OFF; - -CREATE TABLE IF NOT EXISTS of_managed_domains ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - domain TEXT NOT NULL, - cert_id INTEGER, - enabled INTEGER NOT NULL DEFAULT 1, - remark TEXT NOT NULL DEFAULT '', - created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP -); -CREATE UNIQUE INDEX IF NOT EXISTS idx_of_managed_domains_domain ON of_managed_domains (domain); - -CREATE TABLE of_proxy_routes_old ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - site_name TEXT NOT NULL DEFAULT '', - domain TEXT NOT NULL DEFAULT '', - domains 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, - cert_id INTEGER, - cert_ids TEXT NOT NULL DEFAULT '[]', - domain_cert_ids TEXT NOT NULL DEFAULT '[]', - 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 '', - remark 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 -); - -INSERT INTO of_proxy_routes_old ( - id, site_name, domain, domains, origin_id, origin_url, origin_host, upstreams, enabled, - enable_https, cert_id, cert_ids, domain_cert_ids, redirect_http, limit_conn_per_server, - limit_conn_per_ip, limit_rate, cache_enabled, cache_policy, cache_rules, custom_headers, - basic_auth_enabled, basic_auth_username, basic_auth_password, remark, upstream_type, - tunnel_node_id, tunnel_target_addr, tunnel_target_protocol, pages_project_id, created_at, updated_at -) -SELECT - id, site_name, '', '[]', origin_id, origin_url, origin_host, upstreams, enabled, - enable_https, NULL, '[]', '[]', redirect_http, limit_conn_per_server, - limit_conn_per_ip, limit_rate, cache_enabled, cache_policy, cache_rules, custom_headers, - basic_auth_enabled, basic_auth_username, basic_auth_password, remark, upstream_type, - tunnel_node_id, tunnel_target_addr, tunnel_target_protocol, pages_project_id, created_at, updated_at -FROM of_proxy_routes; - -DROP TABLE of_proxy_routes; -ALTER TABLE of_proxy_routes_old RENAME TO of_proxy_routes; - -CREATE UNIQUE INDEX IF NOT EXISTS idx_of_proxy_routes_domain ON of_proxy_routes (domain); -CREATE UNIQUE INDEX IF NOT EXISTS idx_of_proxy_routes_site_name ON of_proxy_routes (site_name); -CREATE INDEX IF NOT EXISTS idx_of_proxy_routes_origin_id ON of_proxy_routes (origin_id); -CREATE INDEX IF NOT EXISTS idx_of_proxy_routes_tunnel_node_id ON of_proxy_routes (tunnel_node_id); -CREATE INDEX IF NOT EXISTS idx_of_proxy_routes_pages_project_id ON of_proxy_routes (pages_project_id); - -PRAGMA foreign_keys=ON; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202607140001_drop_unused_remark_columns.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202607140001_drop_unused_remark_columns.sql deleted file mode 100644 index e8dbe3b0..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202607140001_drop_unused_remark_columns.sql +++ /dev/null @@ -1,17 +0,0 @@ --- +goose Up --- 移除业务实体上未再使用的备注列(证书与源站备注保留)。 --- SQLite 3.35+ 支持 DROP COLUMN;goose 仅在列存在的既有库上执行。 - -ALTER TABLE of_zones DROP COLUMN remark; -ALTER TABLE of_zone_domains DROP COLUMN remark; -ALTER TABLE of_proxy_routes DROP COLUMN remark; -ALTER TABLE of_waf_rule_groups DROP COLUMN remark; -ALTER TABLE of_waf_ip_groups DROP COLUMN remark; - --- +goose Down - -ALTER TABLE of_zones ADD COLUMN remark TEXT NOT NULL DEFAULT ''; -ALTER TABLE of_zone_domains ADD COLUMN remark TEXT NOT NULL DEFAULT ''; -ALTER TABLE of_proxy_routes ADD COLUMN remark TEXT NOT NULL DEFAULT ''; -ALTER TABLE of_waf_rule_groups ADD COLUMN remark TEXT NOT NULL DEFAULT ''; -ALTER TABLE of_waf_ip_groups ADD COLUMN remark TEXT NOT NULL DEFAULT ''; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202607150001_orchestrate_waf_rules.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202607150001_orchestrate_waf_rules.sql deleted file mode 100644 index bbe1c700..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202607150001_orchestrate_waf_rules.sql +++ /dev/null @@ -1,10 +0,0 @@ --- +goose Up -ALTER TABLE of_waf_rule_groups - ADD COLUMN graph TEXT NOT NULL DEFAULT ''; -ALTER TABLE of_waf_rule_groups ADD COLUMN revision INTEGER NOT NULL DEFAULT 1; -ALTER TABLE of_waf_rule_group_bindings ADD COLUMN sequence INTEGER NOT NULL DEFAULT 0; - --- +goose Down -ALTER TABLE of_waf_rule_group_bindings DROP COLUMN sequence; -ALTER TABLE of_waf_rule_groups DROP COLUMN revision; -ALTER TABLE of_waf_rule_groups DROP COLUMN graph; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202607150002_reset_waf_rule_graphs.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202607150002_reset_waf_rule_graphs.sql deleted file mode 100644 index ec4c3cee..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202607150002_reset_waf_rule_graphs.sql +++ /dev/null @@ -1,16 +0,0 @@ --- +goose Up -UPDATE of_waf_rule_groups -SET graph = '{"schema_version":1,"nodes":[{"id":"start","type":"start","position":{"x":0,"y":0},"config":{}},{"id":"allow","type":"allow","position":{"x":320,"y":0},"config":{}}],"edges":[{"id":"start-allow","source":"start","source_handle":"next","target":"allow"}]}', - revision = 1; - -UPDATE of_waf_rule_group_bindings -SET sequence = ( - SELECT COUNT(*) - FROM of_waf_rule_group_bindings AS preceding - WHERE preceding.proxy_route_id = of_waf_rule_group_bindings.proxy_route_id - AND preceding.id < of_waf_rule_group_bindings.id -); - --- +goose Down -UPDATE of_waf_rule_group_bindings SET sequence = 0; -UPDATE of_waf_rule_groups SET revision = 1; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202607150003_drop_legacy_waf_rule_fields.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202607150003_drop_legacy_waf_rule_fields.sql deleted file mode 100644 index 164eb190..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202607150003_drop_legacy_waf_rule_fields.sql +++ /dev/null @@ -1,27 +0,0 @@ --- +goose Up -ALTER TABLE of_waf_rule_groups DROP COLUMN block_status_code; -ALTER TABLE of_waf_rule_groups DROP COLUMN block_response_body; -ALTER TABLE of_waf_rule_groups DROP COLUMN ip_whitelist; -ALTER TABLE of_waf_rule_groups DROP COLUMN ip_blacklist; -ALTER TABLE of_waf_rule_groups DROP COLUMN ip_whitelist_groups; -ALTER TABLE of_waf_rule_groups DROP COLUMN ip_blacklist_groups; -ALTER TABLE of_waf_rule_groups DROP COLUMN country_whitelist; -ALTER TABLE of_waf_rule_groups DROP COLUMN country_blacklist; -ALTER TABLE of_waf_rule_groups DROP COLUMN region_whitelist; -ALTER TABLE of_waf_rule_groups DROP COLUMN region_blacklist; -ALTER TABLE of_waf_rule_groups DROP COLUMN pow_enabled; -ALTER TABLE of_waf_rule_groups DROP COLUMN pow_config; - --- +goose Down -ALTER TABLE of_waf_rule_groups ADD COLUMN block_status_code INTEGER NOT NULL DEFAULT 418; -ALTER TABLE of_waf_rule_groups ADD COLUMN block_response_body TEXT NOT NULL DEFAULT ''; -ALTER TABLE of_waf_rule_groups ADD COLUMN ip_whitelist TEXT NOT NULL DEFAULT '[]'; -ALTER TABLE of_waf_rule_groups ADD COLUMN ip_blacklist TEXT NOT NULL DEFAULT '[]'; -ALTER TABLE of_waf_rule_groups ADD COLUMN ip_whitelist_groups TEXT NOT NULL DEFAULT '[]'; -ALTER TABLE of_waf_rule_groups ADD COLUMN ip_blacklist_groups TEXT NOT NULL DEFAULT '[]'; -ALTER TABLE of_waf_rule_groups ADD COLUMN country_whitelist TEXT NOT NULL DEFAULT '[]'; -ALTER TABLE of_waf_rule_groups ADD COLUMN country_blacklist TEXT NOT NULL DEFAULT '[]'; -ALTER TABLE of_waf_rule_groups ADD COLUMN region_whitelist TEXT NOT NULL DEFAULT '[]'; -ALTER TABLE of_waf_rule_groups ADD COLUMN region_blacklist TEXT NOT NULL DEFAULT '[]'; -ALTER TABLE of_waf_rule_groups ADD COLUMN pow_enabled BOOLEAN NOT NULL DEFAULT 0; -ALTER TABLE of_waf_rule_groups ADD COLUMN pow_config TEXT NOT NULL DEFAULT '{}'; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202607170001_add_pages_system_configs.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202607170001_add_pages_system_configs.sql deleted file mode 100644 index fea0b27d..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202607170001_add_pages_system_configs.sql +++ /dev/null @@ -1,9 +0,0 @@ --- +goose Up -INSERT INTO w_system_configs (key, value, type, visibility, description, created_at, updated_at) -VALUES - ('pages_max_package_size_mb', '100', 'business', 0, 'Pages 部署包上传大小上限(MiB)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('pages_max_history_count', '20', 'business', 0, 'Pages 每个项目最大历史部署保留数(0 表示不限制)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP) -ON CONFLICT (key) DO NOTHING; - --- +goose Down -DELETE FROM w_system_configs WHERE key IN ('pages_max_package_size_mb', 'pages_max_history_count'); diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202607180001_update_agent_heartbeat_offline_defaults.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202607180001_update_agent_heartbeat_offline_defaults.sql deleted file mode 100644 index b92a9a19..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202607180001_update_agent_heartbeat_offline_defaults.sql +++ /dev/null @@ -1,27 +0,0 @@ --- +goose Up --- 将仍为历史默认值的心跳/离线配置升级为新默认:心跳 3s、离线 60s。 --- 已由管理员改成其他值的配置不受影响。 -UPDATE w_system_configs -SET value = '3000', - updated_at = CURRENT_TIMESTAMP -WHERE key = 'agent_heartbeat_interval' - AND value = '10000'; - -UPDATE w_system_configs -SET value = '60000', - updated_at = CURRENT_TIMESTAMP -WHERE key = 'node_offline_threshold' - AND value = '120000'; - --- +goose Down -UPDATE w_system_configs -SET value = '10000', - updated_at = CURRENT_TIMESTAMP -WHERE key = 'agent_heartbeat_interval' - AND value = '3000'; - -UPDATE w_system_configs -SET value = '120000', - updated_at = CURRENT_TIMESTAMP -WHERE key = 'node_offline_threshold' - AND value = '60000'; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202607190001_add_openresty_default_rate_limits.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202607190001_add_openresty_default_rate_limits.sql deleted file mode 100644 index ab39b72f..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202607190001_add_openresty_default_rate_limits.sql +++ /dev/null @@ -1,14 +0,0 @@ --- +goose Up -INSERT INTO w_system_configs (key, value, type, visibility, description, created_at, updated_at) -VALUES - ('openresty_default_limit_conn_per_server', '0', 'business', 0, '默认站点并发连接上限(0 关闭)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('openresty_default_limit_conn_per_ip', '0', 'business', 0, '默认单 IP 并发连接上限(0 关闭)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('openresty_default_limit_rate', '', 'business', 0, '默认单请求带宽限速(空关闭)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP) -ON CONFLICT (key) DO NOTHING; - --- +goose Down -DELETE FROM w_system_configs WHERE key IN ( - 'openresty_default_limit_conn_per_server', - 'openresty_default_limit_conn_per_ip', - 'openresty_default_limit_rate' -); diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202607190002_add_pages_source_runtime.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202607190002_add_pages_source_runtime.sql deleted file mode 100644 index d8b1ad1a..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202607190002_add_pages_source_runtime.sql +++ /dev/null @@ -1,151 +0,0 @@ --- +goose Up -ALTER TABLE of_pages_projects - ADD COLUMN content_config_version INTEGER NOT NULL DEFAULT 0; - -ALTER TABLE of_pages_deployments - ADD COLUMN source_type TEXT NOT NULL DEFAULT ''; -ALTER TABLE of_pages_deployments - ADD COLUMN source_identity TEXT; -ALTER TABLE of_pages_deployments - ADD COLUMN source_revision TEXT; -ALTER TABLE of_pages_deployments - ADD COLUMN source_label TEXT NOT NULL DEFAULT ''; -ALTER TABLE of_pages_deployments - ADD COLUMN source_meta TEXT NOT NULL DEFAULT ''; -ALTER TABLE of_pages_deployments - ADD COLUMN trigger_type TEXT NOT NULL DEFAULT ''; - -UPDATE of_pages_deployments -SET source_type = 'manual_upload', - trigger_type = 'manual_upload'; - -CREATE TABLE IF NOT EXISTS 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 -); - -CREATE UNIQUE INDEX IF NOT EXISTS idx_of_pages_project_sources_project_id - ON of_pages_project_sources (project_id); - -CREATE TABLE IF NOT EXISTS 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 -); - -CREATE INDEX IF NOT EXISTS idx_of_pages_project_source_runtime_next_check_at - ON of_pages_project_source_runtime (next_check_at); - -CREATE UNIQUE INDEX IF NOT EXISTS idx_of_pages_deployments_project_number - ON of_pages_deployments (project_id, deployment_number); - -CREATE UNIQUE INDEX IF NOT EXISTS 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; - --- +goose Down -DROP INDEX IF EXISTS idx_of_pages_deployments_source_revision; -DROP INDEX IF EXISTS idx_of_pages_deployments_project_number; -DROP INDEX IF EXISTS idx_of_pages_project_source_runtime_next_check_at; -DROP TABLE IF EXISTS of_pages_project_source_runtime; -DROP INDEX IF EXISTS idx_of_pages_project_sources_project_id; -DROP TABLE IF EXISTS of_pages_project_sources; - --- SQLite 的 Down 必须重建受影响表,完整移除新增列并保留原有数据与索引。 -CREATE TABLE of_pages_deployments_before_source ( - 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', - upload_id INTEGER NOT NULL DEFAULT 0, - 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 -); - -INSERT INTO of_pages_deployments_before_source ( - id, project_id, deployment_number, checksum, status, upload_id, artifact_path, - file_count, total_size, created_by, created_at, activated_at -) -SELECT - id, project_id, deployment_number, checksum, status, upload_id, artifact_path, - file_count, total_size, created_by, created_at, activated_at -FROM of_pages_deployments; - -DROP TABLE of_pages_deployments; -ALTER TABLE of_pages_deployments_before_source RENAME TO of_pages_deployments; - -CREATE INDEX IF NOT EXISTS idx_of_pages_deployments_project_id - ON of_pages_deployments (project_id); -CREATE INDEX IF NOT EXISTS idx_of_pages_deployments_checksum - ON of_pages_deployments (checksum); -CREATE INDEX IF NOT EXISTS idx_of_pages_deployments_status - ON of_pages_deployments (status); -CREATE INDEX IF NOT EXISTS idx_of_pages_deployments_upload_id - ON of_pages_deployments (upload_id); - -CREATE TABLE of_pages_projects_before_source ( - 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 -); - -INSERT INTO of_pages_projects_before_source ( - id, name, slug, description, enabled, spa_fallback_enabled, spa_fallback_path, - api_proxy_enabled, api_proxy_path, api_proxy_pass, api_proxy_rewrite, - active_deployment_id, root_dir, entry_file, created_at, updated_at -) -SELECT - id, name, slug, description, enabled, spa_fallback_enabled, spa_fallback_path, - api_proxy_enabled, api_proxy_path, api_proxy_pass, api_proxy_rewrite, - active_deployment_id, root_dir, entry_file, created_at, updated_at -FROM of_pages_projects; - -DROP TABLE of_pages_projects; -ALTER TABLE of_pages_projects_before_source RENAME TO of_pages_projects; - -CREATE UNIQUE INDEX IF NOT EXISTS idx_of_pages_projects_slug - ON of_pages_projects (slug); -CREATE INDEX IF NOT EXISTS idx_of_pages_projects_active_deployment_id - ON of_pages_projects (active_deployment_id); diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202607190003_seed_pages_source_scan.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202607190003_seed_pages_source_scan.sql deleted file mode 100644 index d9364c20..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202607190003_seed_pages_source_scan.sql +++ /dev/null @@ -1,21 +0,0 @@ --- +goose Up -INSERT INTO w_schedules (name, task_type, cron, payload, is_active, created_at, updated_at) -SELECT - 'OpenFlare Pages 部署源扫描', - 'of_pages_source_scan', - '0 0 * * *', - '{}', - 1, - CURRENT_TIMESTAMP, - CURRENT_TIMESTAMP -WHERE NOT EXISTS ( - SELECT 1 FROM w_schedules WHERE task_type = 'of_pages_source_scan' -); - --- +goose Down -DELETE FROM w_schedules -WHERE task_type = 'of_pages_source_scan' - AND name = 'OpenFlare Pages 部署源扫描' - AND cron = '0 0 * * *' - AND payload = '{}' - AND is_active = 1; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202607200001_add_openresty_default_limit_req_per_ip.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202607200001_add_openresty_default_limit_req_per_ip.sql deleted file mode 100644 index 5755eea6..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202607200001_add_openresty_default_limit_req_per_ip.sql +++ /dev/null @@ -1,12 +0,0 @@ --- +goose Up -INSERT INTO w_system_configs (key, value, type, visibility, description, created_at, updated_at) -VALUES - ('openresty_default_limit_req_per_ip', '', 'business', 0, '默认单 IP 请求频率限制(空关闭,例如 10r/s、100r/m)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP) -ON CONFLICT (key) DO NOTHING; - -ALTER TABLE of_proxy_routes ADD COLUMN limit_req_per_ip VARCHAR(32) NOT NULL DEFAULT ''; - --- +goose Down -ALTER TABLE of_proxy_routes DROP COLUMN limit_req_per_ip; - -DELETE FROM w_system_configs WHERE key = 'openresty_default_limit_req_per_ip'; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202608040001_create_cloudflare_pointing.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202608040001_create_cloudflare_pointing.sql deleted file mode 100644 index 4013ef8a..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202608040001_create_cloudflare_pointing.sql +++ /dev/null @@ -1,49 +0,0 @@ --- +goose Up -CREATE TABLE IF NOT EXISTS 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 -); -CREATE INDEX IF NOT EXISTS idx_of_cf_connections_dns_account_id ON of_cf_connections (dns_account_id); - -CREATE TABLE IF NOT EXISTS 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 -); -CREATE INDEX IF NOT EXISTS idx_of_cf_pointing_groups_primary_node_id ON of_cf_pointing_groups (primary_node_id); -CREATE INDEX IF NOT EXISTS idx_of_cf_pointing_groups_backup_node_id ON of_cf_pointing_groups (backup_node_id); -CREATE INDEX IF NOT EXISTS idx_of_cf_pointing_groups_active_node_id ON of_cf_pointing_groups (active_node_id); - -CREATE TABLE IF NOT EXISTS 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 -); -CREATE INDEX IF NOT EXISTS idx_of_cf_pointing_members_group_id ON of_cf_pointing_members (group_id); -CREATE UNIQUE INDEX IF NOT EXISTS idx_of_cf_pointing_members_zone_domain_id ON of_cf_pointing_members (zone_domain_id); - --- +goose Down -DROP TABLE IF EXISTS of_cf_pointing_members; -DROP TABLE IF EXISTS of_cf_pointing_groups; -DROP TABLE IF EXISTS of_cf_connections; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202608060001_add_origin_error_page_options.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202608060001_add_origin_error_page_options.sql deleted file mode 100644 index 6646d974..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202608060001_add_origin_error_page_options.sql +++ /dev/null @@ -1,14 +0,0 @@ --- +goose Up -INSERT INTO w_system_configs (key, value, type, visibility, description, created_at, updated_at) -VALUES - ('origin_error_page_enabled', 'true', 'business', 0, '是否启用源站错误页', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('origin_error_page_status_codes', '["500-599"]', 'business', 0, '源站错误页触发状态码标签 JSON 数组', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('origin_error_page_html', '', 'business', 0, '源站错误页自定义 HTML,空则使用内置默认', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP) -ON CONFLICT (key) DO NOTHING; - --- +goose Down -DELETE FROM w_system_configs WHERE key IN ( - 'origin_error_page_enabled', - 'origin_error_page_status_codes', - 'origin_error_page_html' -); diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202608060002_add_origin_error_page_get_only.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202608060002_add_origin_error_page_get_only.sql deleted file mode 100644 index d6fe39aa..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202608060002_add_origin_error_page_get_only.sql +++ /dev/null @@ -1,8 +0,0 @@ --- +goose Up -INSERT INTO w_system_configs (key, value, type, visibility, description, created_at, updated_at) -VALUES - ('origin_error_page_get_only', 'false', 'business', 0, '源站错误页是否仅对 GET 请求生效(其它方法透传)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP) -ON CONFLICT (key) DO NOTHING; - --- +goose Down -DELETE FROM w_system_configs WHERE key = 'origin_error_page_get_only'; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202608070001_add_sw_offline_options.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202608070001_add_sw_offline_options.sql deleted file mode 100644 index f92b4d3e..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202608070001_add_sw_offline_options.sql +++ /dev/null @@ -1,12 +0,0 @@ --- +goose Up -INSERT INTO w_system_configs (key, value, type, visibility, description, created_at, updated_at) -VALUES - ('sw_offline_enabled', 'false', 'business', 0, '是否启用 Service Worker 离线兜底', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP), - ('sw_offline_html', '', 'business', 0, '离线联系页自定义 HTML,空则使用内置默认', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP) -ON CONFLICT (key) DO NOTHING; - --- +goose Down -DELETE FROM w_system_configs WHERE key IN ( - 'sw_offline_enabled', - 'sw_offline_html' -); diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202608070002_add_sw_offline_domains.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202608070002_add_sw_offline_domains.sql deleted file mode 100644 index 505f73b9..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202608070002_add_sw_offline_domains.sql +++ /dev/null @@ -1,7 +0,0 @@ --- +goose Up -INSERT INTO w_system_configs (key, value, type, visibility, description, created_at, updated_at) -VALUES ('sw_offline_domains', '[]', 'business', 0, 'SW 离线兜底生效域名列表(JSON 数组,空则仅总开关无效)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP) -ON CONFLICT (key) DO NOTHING; - --- +goose Down -DELETE FROM w_system_configs WHERE key = 'sw_offline_domains'; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202608080001_create_log_tables.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202608080001_create_log_tables.sql deleted file mode 100644 index b7b191b4..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202608080001_create_log_tables.sql +++ /dev/null @@ -1,93 +0,0 @@ --- +goose Up --- 节点访问日志:普通表(同 PG 语义,索引名保持一致)。 -CREATE TABLE IF NOT EXISTS 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 -); -CREATE INDEX IF NOT EXISTS idx_of_node_access_logs_node_id ON of_node_access_logs (node_id, logged_at DESC); -CREATE INDEX IF NOT EXISTS idx_of_node_access_logs_host ON of_node_access_logs (host, logged_at DESC); -CREATE INDEX IF NOT EXISTS idx_of_node_access_logs_remote_addr ON of_node_access_logs (remote_addr, logged_at DESC); -CREATE INDEX IF NOT EXISTS idx_of_node_access_logs_status_code ON of_node_access_logs (status_code, logged_at DESC); - -CREATE TABLE IF NOT EXISTS 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 -); -CREATE INDEX IF NOT EXISTS idx_w_user_access_logs_user_id ON w_user_access_logs (user_id, created_at DESC); - -CREATE TABLE IF NOT EXISTS 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 -); -CREATE INDEX IF NOT EXISTS idx_of_node_metric_snapshots_node ON of_node_metric_snapshots (node_id, captured_at DESC); - -CREATE TABLE IF NOT EXISTS 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 -); -CREATE INDEX IF NOT EXISTS idx_of_node_edge_health_node ON of_node_edge_health (node_id, captured_at DESC); - -CREATE TABLE IF NOT EXISTS 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 -); -CREATE INDEX IF NOT EXISTS idx_of_node_obs_frps_node ON of_node_obs_frps (node_id, captured_at DESC); - -CREATE TABLE IF NOT EXISTS 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 -); -CREATE INDEX IF NOT EXISTS idx_of_node_obs_frpc_node ON of_node_obs_frpc (node_id, captured_at DESC); - --- +goose Down -DROP TABLE IF EXISTS of_node_obs_frpc; -DROP TABLE IF EXISTS of_node_obs_frps; -DROP TABLE IF EXISTS of_node_edge_health; -DROP TABLE IF EXISTS of_node_metric_snapshots; -DROP TABLE IF EXISTS w_user_access_logs; -DROP TABLE IF EXISTS of_node_access_logs; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202608080002_log_retention_configs.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202608080002_log_retention_configs.sql deleted file mode 100644 index 7d191ed0..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202608080002_log_retention_configs.sql +++ /dev/null @@ -1,20 +0,0 @@ --- +goose Up --- 日志保留天数配置(business),替换旧的 database_auto_cleanup_* 键。 --- 默认统一 30 天:不继承旧键值,避免旧配置被静默带入导致日志被过度清理。 -INSERT OR IGNORE INTO w_system_configs (key, value, type, visibility, description, created_at, updated_at) -SELECT 'log_retention_days_postgres', '30', 'business', 0, 'PostgreSQL 日志保留天数(访问日志与可观测统一)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP -UNION ALL -SELECT 'log_retention_days_sqlite', '30', 'business', 0, 'SQLite 日志保留天数', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP -UNION ALL -SELECT 'log_retention_days_clickhouse', '30', 'business', 0, 'ClickHouse 日志保留天数', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP; - -DELETE FROM w_system_configs WHERE key IN ('database_auto_cleanup_enabled', 'database_auto_cleanup_retention_days'); - --- +goose Down -INSERT OR IGNORE INTO w_system_configs (key, value, type, visibility, description, created_at, updated_at) -SELECT 'database_auto_cleanup_enabled', 'true', 'business', 0, '数据库自动清理开关', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP -UNION ALL -SELECT 'database_auto_cleanup_retention_days', COALESCE((SELECT value FROM w_system_configs WHERE key = 'log_retention_days_sqlite'), '30'), 'business', 0, '数据库保留天数', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP; - -DELETE FROM w_system_configs WHERE key IN ('log_retention_days_postgres', 'log_retention_days_sqlite', 'log_retention_days_clickhouse'); - diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202608080003_drop_database_cleanup_schedule.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202608080003_drop_database_cleanup_schedule.sql deleted file mode 100644 index e8880951..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202608080003_drop_database_cleanup_schedule.sql +++ /dev/null @@ -1,17 +0,0 @@ --- +goose Up -CREATE TABLE IF NOT EXISTS w_schedules_backup_of_database_auto_cleanup AS -SELECT * FROM w_schedules WHERE task_type = 'of_database_auto_cleanup'; - -DELETE FROM w_schedules WHERE task_type = 'of_database_auto_cleanup'; - --- +goose Down -INSERT OR IGNORE INTO w_schedules (id, name, task_type, cron, payload, is_active, created_at, updated_at) -SELECT id, name, task_type, cron, payload, is_active, created_at, updated_at -FROM w_schedules_backup_of_database_auto_cleanup; - -INSERT OR IGNORE INTO w_schedules (id, name, task_type, cron, payload, is_active, created_at, updated_at) -SELECT 102, 'OpenFlare 可观测数据自动清理', 'of_database_auto_cleanup', '0 3 * * *', '{}', 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP -WHERE NOT EXISTS (SELECT 1 FROM w_schedules WHERE task_type = 'of_database_auto_cleanup'); - -DROP TABLE IF EXISTS w_schedules_backup_of_database_auto_cleanup; - diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202608090001_metric_retention_config.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202608090001_metric_retention_config.sql deleted file mode 100644 index 7c1b6d32..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202608090001_metric_retention_config.sql +++ /dev/null @@ -1,8 +0,0 @@ --- +goose Up --- 性能指标(CPU/内存/磁盘/网络)保留天数:三库共用、独立短留存(默认 3 天), --- 不随 log_retention_days_*(访问日志保留配置)变化。 -INSERT OR IGNORE INTO w_system_configs (key, value, type, visibility, description, created_at, updated_at) -VALUES ('metric_retention_days', '3', 'business', 0, '性能指标(CPU/内存/磁盘/网络)保留天数(三库共用)', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); - --- +goose Down -DELETE FROM w_system_configs WHERE key = 'metric_retention_days'; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202608090002_update_system_cleanup_schedule.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202608090002_update_system_cleanup_schedule.sql deleted file mode 100644 index 2896c651..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202608090002_update_system_cleanup_schedule.sql +++ /dev/null @@ -1,13 +0,0 @@ --- +goose Up --- 系统定期垃圾清理改为每日执行一次(凌晨 3 点,Asia/Shanghai)。 --- 此前为每 2 小时(0 */2 * * *)高频扫描,日常清理收益有限,降频减少非必要扫描。 -UPDATE w_schedules -SET cron = '0 3 * * *', - updated_at = CURRENT_TIMESTAMP -WHERE task_type = 'system_cleanup'; - --- +goose Down -UPDATE w_schedules -SET cron = '0 */2 * * *', - updated_at = CURRENT_TIMESTAMP -WHERE task_type = 'system_cleanup'; diff --git a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202608090003_add_log_indexes.sql b/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202608090003_add_log_indexes.sql deleted file mode 100644 index 4e257530..00000000 --- a/backend/OpenFlare/plugins/server/migrator/goose/sqlite/202608090003_add_log_indexes.sql +++ /dev/null @@ -1,9 +0,0 @@ --- +goose Up --- 日志列表默认排序与 retention 清理的时间范围条件:补 logged_at 前导索引。 -CREATE INDEX IF NOT EXISTS idx_of_node_access_logs_logged_at ON of_node_access_logs (logged_at DESC, id DESC); --- hosts 过滤为 lower(trim(host)) IN:补表达式索引,普通 (host,...) 索引无法命中函数表达式。 -CREATE INDEX IF NOT EXISTS idx_of_node_access_logs_host_lower ON of_node_access_logs (lower(trim(host))); - --- +goose Down -DROP INDEX IF EXISTS idx_of_node_access_logs_host_lower; -DROP INDEX IF EXISTS idx_of_node_access_logs_logged_at; diff --git a/backend/OpenFlare/plugins/server/plugin.go b/backend/OpenFlare/plugins/server/plugin.go index d7b4cbec..8eb7ae78 100644 --- a/backend/OpenFlare/plugins/server/plugin.go +++ b/backend/OpenFlare/plugins/server/plugin.go @@ -7,7 +7,7 @@ package server import ( - "Wavelet/OpenFlare/plugins/server/chmigrate" + "Wavelet/OpenFlare/plugins/server/migrate" "Wavelet/OpenFlare/plugins/server/ofevents" "Wavelet/OpenFlare/plugins/server/openflare/chwriter" ofgeoip "Wavelet/OpenFlare/plugins/server/openflare/geoip" @@ -30,13 +30,14 @@ import ( _ "Wavelet/docs" adminservice "Wavelet/plugins/domain/admin/service" + "net/http" + "github.com/gin-gonic/gin" swaggerFiles "github.com/swaggo/files" ginSwagger "github.com/swaggo/gin-swagger" - "net/http" ) -//go:embed migrations/*/*.sql +//go:embed migrate/postgres/*.sql migrate/sqlite/*.sql var serverMigrations embed.FS // Plugin 实现 core.Plugin,是 OpenFlare 控制面的装载入口。 @@ -72,7 +73,7 @@ func (p *Plugin) Apply(ctx *core.Context) error { credential.SetSessionSecret(runtimeconfig.SessionSecret()) ctx.Migrations().Register("server", serverMigrations) - if err := chmigrate.Up(); err != nil { + if err := migrate.UpClickHouse(); err != nil { return err } diff --git a/backend/OpenFlare/plugins/server/repository/logstore/imports_test.go b/backend/OpenFlare/plugins/server/repository/logstore/imports_test.go index 1b5e2c46..033c647e 100644 --- a/backend/OpenFlare/plugins/server/repository/logstore/imports_test.go +++ b/backend/OpenFlare/plugins/server/repository/logstore/imports_test.go @@ -37,7 +37,7 @@ var allowedInfraPersistence = []string{ // domainScopes 是 server 插件内的业务域包(等价于改造前的 internal/apps/...)。 // 持久化与基础设施层(repository/infra/model/…)不受本门禁约束。 var domainScopes = []string{ - "openflare", "admin", + "openflare", "updater", } func TestDomainsMustNotImportLogBackendDirectly(t *testing.T) { diff --git a/backend/OpenFlare/plugins/server/repository/openflare_waf_graph_test.go b/backend/OpenFlare/plugins/server/repository/openflare_waf_graph_test.go index 50bab81a..9b6efef6 100644 --- a/backend/OpenFlare/plugins/server/repository/openflare_waf_graph_test.go +++ b/backend/OpenFlare/plugins/server/repository/openflare_waf_graph_test.go @@ -5,19 +5,13 @@ package repository import ( "context" - "io/fs" - "os" - "path/filepath" - "runtime" "testing" - "testing/fstest" "Wavelet/OpenFlare/plugins/server/model" db "Wavelet/plugins/infra/database" "github.com/glebarez/sqlite" - "github.com/pressly/goose/v3" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "gorm.io/gorm" @@ -25,63 +19,6 @@ import ( const defaultWAFRuleGraph = `{"schema_version":1,"nodes":[{"id":"start","type":"start","position":{"x":0,"y":0},"config":{}},{"id":"allow","type":"allow","position":{"x":320,"y":0},"config":{}}],"edges":[{"id":"start-allow","source":"start","source_handle":"next","target":"allow"}]}` -func wafMigrationFS(t *testing.T) fs.FS { - t.Helper() - _, filename, _, ok := runtime.Caller(0) - require.True(t, ok) - dir := filepath.Join(filepath.Dir(filename), "..", "migrator", "goose", "sqlite") - migrations := fstest.MapFS{} - for _, name := range []string{ - "202607150001_orchestrate_waf_rules.sql", - "202607150002_reset_waf_rule_graphs.sql", - "202607150003_drop_legacy_waf_rule_fields.sql", - } { - contents, err := os.ReadFile(filepath.Join(dir, name)) - require.NoError(t, err) - migrations[name] = &fstest.MapFile{Data: contents} - } - return migrations -} - -func TestOpenFlareWAFGraphMigrationResetsGraphsAndOrdersBindings(t *testing.T) { - conn, err := gorm.Open(sqlite.Open(":memory:"), &gorm.Config{}) - require.NoError(t, err) - sqlDB, err := conn.DB() - require.NoError(t, err) - - require.NoError(t, conn.Exec(`CREATE TABLE of_waf_rule_groups (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, block_status_code INTEGER NOT NULL DEFAULT 418, block_response_body TEXT NOT NULL DEFAULT '', ip_whitelist TEXT NOT NULL DEFAULT '[]', ip_blacklist TEXT NOT NULL DEFAULT '[]', ip_whitelist_groups TEXT NOT NULL DEFAULT '[]', ip_blacklist_groups TEXT NOT NULL DEFAULT '[]', country_whitelist TEXT NOT NULL DEFAULT '[]', country_blacklist TEXT NOT NULL DEFAULT '[]', region_whitelist TEXT NOT NULL DEFAULT '[]', region_blacklist TEXT NOT NULL DEFAULT '[]', pow_enabled BOOLEAN NOT NULL DEFAULT 0, pow_config TEXT NOT NULL DEFAULT '{}')`).Error) - require.NoError(t, conn.Exec(`CREATE TABLE of_waf_rule_group_bindings (id INTEGER PRIMARY KEY AUTOINCREMENT, rule_group_id INTEGER NOT NULL, proxy_route_id INTEGER NOT NULL)`).Error) - require.NoError(t, conn.Exec(`INSERT INTO of_waf_rule_groups (id, name) VALUES (1, 'one'), (2, 'two')`).Error) - require.NoError(t, conn.Exec(`INSERT INTO of_waf_rule_group_bindings (id, rule_group_id, proxy_route_id) VALUES (20, 2, 7), (10, 1, 7)`).Error) - - goose.SetBaseFS(wafMigrationFS(t)) - require.NoError(t, goose.SetDialect("sqlite3")) - require.NoError(t, goose.Up(sqlDB, ".")) - - var groups []model.OpenFlareWAFRuleGroup - require.NoError(t, conn.Order("id asc").Find(&groups).Error) - require.Len(t, groups, 2) - for _, group := range groups { - require.JSONEq(t, defaultWAFRuleGraph, group.Graph) - assert.Equal(t, uint64(1), group.Revision) - } - for _, column := range []string{"block_status_code", "ip_whitelist", "pow_enabled"} { - assert.False(t, conn.Migrator().HasColumn("of_waf_rule_groups", column)) - } - - require.NoError(t, conn.Exec(`INSERT INTO of_waf_rule_groups (name) VALUES ('new')`).Error) - var newGroup model.OpenFlareWAFRuleGroup - require.NoError(t, conn.First(&newGroup, 3).Error) - assert.Empty(t, newGroup.Graph) - assert.Equal(t, uint64(1), newGroup.Revision) - - var bindings []model.OpenFlareWAFRuleGroupBinding - require.NoError(t, conn.Where("proxy_route_id = ?", 7).Order("sequence asc").Order("id asc").Find(&bindings).Error) - require.Len(t, bindings, 2) - assert.Equal(t, []int{0, 1}, []int{bindings[0].Sequence, bindings[1].Sequence}) - assert.Equal(t, []uint{10, 20}, []uint{bindings[0].ID, bindings[1].ID}) -} - func TestOpenFlareWAFGraphOptimisticUpdate(t *testing.T) { conn, err := gorm.Open(sqlite.Open(":memory:"), &gorm.Config{}) require.NoError(t, err) diff --git a/backend/OpenFlare/plugins/server/router/root/frontend_static.go b/backend/OpenFlare/plugins/server/router/root/frontend_static.go deleted file mode 100644 index 25f6b2d1..00000000 --- a/backend/OpenFlare/plugins/server/router/root/frontend_static.go +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2026 Arctel.net -// SPDX-License-Identifier: Apache-2.0 - -package root - -import ( - "io/fs" - "strings" -) - -//nolint:unused // Used by frontend.go in embed_frontend builds; default lint runs without that tag. -func resolveNextExportDynamicFallback(subFS fs.FS, cleanPath string) (string, bool) { - parts := strings.Split(cleanPath, "/") - if len(parts) < 2 || parts[0] != "websites" || parts[1] == "" { - return "", false - } - - var templatePath string - switch { - case len(parts) == 2 && !strings.Contains(parts[1], "."): - templatePath = "websites/1.html" - case len(parts) == 2 && strings.HasSuffix(parts[1], ".txt"): - templatePath = "websites/1.txt" - case len(parts) == 3 && parts[2] != "" && strings.HasPrefix(parts[2], "__next.") && strings.HasSuffix(parts[2], ".txt"): - templatePath = "websites/1/" + parts[2] - default: - return "", false - } - - if _, err := fs.Stat(subFS, templatePath); err != nil { - return "", false - } - return templatePath, true -} diff --git a/backend/OpenFlare/plugins/server/router/root/frontend_static_test.go b/backend/OpenFlare/plugins/server/router/root/frontend_static_test.go deleted file mode 100644 index 97b5a3d5..00000000 --- a/backend/OpenFlare/plugins/server/router/root/frontend_static_test.go +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2026 Arctel.net -// SPDX-License-Identifier: Apache-2.0 - -package root - -import ( - "testing" - "testing/fstest" -) - -func TestResolveNextExportDynamicFallbackUsesZoneTemplate(t *testing.T) { - subFS := fstest.MapFS{ - "index.html": &fstest.MapFile{Data: []byte("dashboard")}, - "websites/1.html": &fstest.MapFile{Data: []byte("zone detail")}, - "websites/1.txt": &fstest.MapFile{Data: []byte("zone flight")}, - "websites/1/__next.!KG1haW4p.websites.$d$zoneId.__PAGE__.txt": &fstest.MapFile{Data: []byte("zone segment")}, - } - - tests := []struct { - name string - input string - want string - }{ - {name: "html", input: "websites/3", want: "websites/1.html"}, - {name: "route payload", input: "websites/3.txt", want: "websites/1.txt"}, - { - name: "segment payload", - input: "websites/3/__next.!KG1haW4p.websites.$d$zoneId.__PAGE__.txt", - want: "websites/1/__next.!KG1haW4p.websites.$d$zoneId.__PAGE__.txt", - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - got, ok := resolveNextExportDynamicFallback(subFS, tt.input) - if !ok { - t.Fatal("expected dynamic websites route fallback") - } - if got != tt.want { - t.Fatalf("expected %q fallback, got %q", tt.want, got) - } - }) - } -} - -func TestResolveNextExportDynamicFallbackRejectsNestedOrAssetPath(t *testing.T) { - subFS := fstest.MapFS{ - "websites/1.html": &fstest.MapFile{Data: []byte("zone detail")}, - } - - tests := []string{ - "websites", - "websites/3/settings", - "websites/3.js", - "websites/3/", - "websites/3/missing.txt", - } - for _, tt := range tests { - t.Run(tt, func(t *testing.T) { - if got, ok := resolveNextExportDynamicFallback(subFS, tt); ok { - t.Fatalf("expected no fallback, got %q", got) - } - }) - } -} - -func TestResolveNextExportDynamicFallbackRequiresGeneratedTemplate(t *testing.T) { - subFS := fstest.MapFS{ - "index.html": &fstest.MapFile{Data: []byte("dashboard")}, - } - - if got, ok := resolveNextExportDynamicFallback(subFS, "websites/3"); ok { - t.Fatalf("expected no fallback without generated template, got %q", got) - } -} diff --git a/backend/OpenFlare/plugins/server/router/v1/openflare/register_updater.go b/backend/OpenFlare/plugins/server/router/v1/openflare/register_updater.go index a63d7e48..81ee3346 100644 --- a/backend/OpenFlare/plugins/server/router/v1/openflare/register_updater.go +++ b/backend/OpenFlare/plugins/server/router/v1/openflare/register_updater.go @@ -4,7 +4,7 @@ package openflare import ( - "Wavelet/OpenFlare/plugins/server/admin/updater" + "Wavelet/OpenFlare/plugins/server/updater" "Wavelet/OpenFlare/plugins/server/openflare/apiutil" "Wavelet/core" "Wavelet/core/contracts" diff --git a/backend/OpenFlare/plugins/server/admin/updater/errs.go b/backend/OpenFlare/plugins/server/updater/errs.go similarity index 100% rename from backend/OpenFlare/plugins/server/admin/updater/errs.go rename to backend/OpenFlare/plugins/server/updater/errs.go diff --git a/backend/OpenFlare/plugins/server/admin/updater/export.go b/backend/OpenFlare/plugins/server/updater/export.go similarity index 100% rename from backend/OpenFlare/plugins/server/admin/updater/export.go rename to backend/OpenFlare/plugins/server/updater/export.go diff --git a/backend/OpenFlare/plugins/server/admin/updater/logics.go b/backend/OpenFlare/plugins/server/updater/logics.go similarity index 100% rename from backend/OpenFlare/plugins/server/admin/updater/logics.go rename to backend/OpenFlare/plugins/server/updater/logics.go diff --git a/backend/OpenFlare/plugins/server/admin/updater/logics_test.go b/backend/OpenFlare/plugins/server/updater/logics_test.go similarity index 100% rename from backend/OpenFlare/plugins/server/admin/updater/logics_test.go rename to backend/OpenFlare/plugins/server/updater/logics_test.go diff --git a/backend/OpenFlare/plugins/server/admin/updater/restart_unix.go b/backend/OpenFlare/plugins/server/updater/restart_unix.go similarity index 100% rename from backend/OpenFlare/plugins/server/admin/updater/restart_unix.go rename to backend/OpenFlare/plugins/server/updater/restart_unix.go diff --git a/backend/OpenFlare/plugins/server/admin/updater/restart_windows.go b/backend/OpenFlare/plugins/server/updater/restart_windows.go similarity index 100% rename from backend/OpenFlare/plugins/server/admin/updater/restart_windows.go rename to backend/OpenFlare/plugins/server/updater/restart_windows.go diff --git a/backend/OpenFlare/plugins/server/admin/updater/routers.go b/backend/OpenFlare/plugins/server/updater/routers.go similarity index 100% rename from backend/OpenFlare/plugins/server/admin/updater/routers.go rename to backend/OpenFlare/plugins/server/updater/routers.go diff --git a/backend/cmd/app.go b/backend/cmd/app.go index b0fbd09a..9e9f8952 100644 --- a/backend/cmd/app.go +++ b/backend/cmd/app.go @@ -5,7 +5,7 @@ package cmd import ( ofserver "Wavelet/OpenFlare/plugins/server" - "Wavelet/OpenFlare/plugins/server/stamp" + "Wavelet/OpenFlare/plugins/server/migrate" "Wavelet/core" "Wavelet/core/contracts" "Wavelet/plugins/domain/admin" @@ -80,7 +80,7 @@ func newOpenFlareApp(profile core.Profile, opts ...core.AppOption) *core.App { core.WithProfile(profile), core.WithConfigSource(src), core.WithShutdownTimeout(defaultShutdownTimeout), - core.WithMigrationBaseline(stamp.Legacy), + core.WithMigrationBaseline(migrate.Legacy), } appOpts = append(appOpts, opts...) diff --git a/docs/changelog/index.md b/docs/changelog/index.md index b1836961..d0b34eff 100644 --- a/docs/changelog/index.md +++ b/docs/changelog/index.md @@ -13,6 +13,7 @@ sidebar: false ### 🛠 修复 - 人机验证与健康检查去掉双路径:浏览器只请求 `/api/v1/cap/challenge` 与 `/api/v1/cap/redeem`,探针只保留 `GET /api/healthz`(`{"status":"ok"}`)。旧的 `/api/cap/*`、`/api/health` 与 `/healthz` 不再注册。 +- `server` 插件把 stamp、of_* SQL 与 ClickHouse 迁入单一 `migrate/` 包,updater 提到 `server/updater/`;删除已停用的 76 条历史迁移。全新安装会写入 OpenFlare 定时任务与产品配置默认值,已 stamp 的升级库不重插。 ### 💄 其他/体验