mutao f182e97fb9 first commit 1 mēnesi atpakaļ
..
001_init.sql f182e97fb9 first commit 1 mēnesi atpakaļ
002_account_type_migration.sql f182e97fb9 first commit 1 mēnesi atpakaļ
003_subscription.sql f182e97fb9 first commit 1 mēnesi atpakaļ
004_add_redeem_code_notes.sql f182e97fb9 first commit 1 mēnesi atpakaļ
005_schema_parity.sql f182e97fb9 first commit 1 mēnesi atpakaļ
006_add_users_allowed_groups_compat.sql f182e97fb9 first commit 1 mēnesi atpakaļ
006_fix_invalid_subscription_expires_at.sql f182e97fb9 first commit 1 mēnesi atpakaļ
006b_guard_users_allowed_groups.sql f182e97fb9 first commit 1 mēnesi atpakaļ
007_add_user_allowed_groups.sql f182e97fb9 first commit 1 mēnesi atpakaļ
008_seed_default_group.sql f182e97fb9 first commit 1 mēnesi atpakaļ
009_fix_usage_logs_cache_columns.sql f182e97fb9 first commit 1 mēnesi atpakaļ
010_add_usage_logs_aggregated_indexes.sql f182e97fb9 first commit 1 mēnesi atpakaļ
011_remove_duplicate_unique_indexes.sql f182e97fb9 first commit 1 mēnesi atpakaļ
012_add_user_subscription_soft_delete.sql f182e97fb9 first commit 1 mēnesi atpakaļ
013_log_orphan_allowed_groups.sql f182e97fb9 first commit 1 mēnesi atpakaļ
014_drop_legacy_allowed_groups.sql f182e97fb9 first commit 1 mēnesi atpakaļ
015_fix_settings_unique_constraint.sql f182e97fb9 first commit 1 mēnesi atpakaļ
016_soft_delete_partial_unique_indexes.sql f182e97fb9 first commit 1 mēnesi atpakaļ
018_user_attributes.sql f182e97fb9 first commit 1 mēnesi atpakaļ
019_migrate_wechat_to_attributes.sql f182e97fb9 first commit 1 mēnesi atpakaļ
020_add_temp_unschedulable.sql f182e97fb9 first commit 1 mēnesi atpakaļ
024_add_gemini_tier_id.sql f182e97fb9 first commit 1 mēnesi atpakaļ
026_ops_metrics_aggregation_tables.sql f182e97fb9 first commit 1 mēnesi atpakaļ
027_usage_billing_consistency.sql f182e97fb9 first commit 1 mēnesi atpakaļ
028_add_account_notes.sql f182e97fb9 first commit 1 mēnesi atpakaļ
028_add_usage_logs_user_agent.sql f182e97fb9 first commit 1 mēnesi atpakaļ
028_group_image_pricing.sql f182e97fb9 first commit 1 mēnesi atpakaļ
029_add_group_claude_code_restriction.sql f182e97fb9 first commit 1 mēnesi atpakaļ
029_usage_log_image_fields.sql f182e97fb9 first commit 1 mēnesi atpakaļ
030_add_account_expires_at.sql f182e97fb9 first commit 1 mēnesi atpakaļ
031_add_ip_address.sql f182e97fb9 first commit 1 mēnesi atpakaļ
032_add_api_key_ip_restriction.sql f182e97fb9 first commit 1 mēnesi atpakaļ
033_add_promo_codes.sql f182e97fb9 first commit 1 mēnesi atpakaļ
033_ops_monitoring_vnext.sql f182e97fb9 first commit 1 mēnesi atpakaļ
034_ops_upstream_error_events.sql f182e97fb9 first commit 1 mēnesi atpakaļ
034_usage_dashboard_aggregation_tables.sql f182e97fb9 first commit 1 mēnesi atpakaļ
035_usage_logs_partitioning.sql f182e97fb9 first commit 1 mēnesi atpakaļ
036_ops_error_logs_add_is_count_tokens.sql f182e97fb9 first commit 1 mēnesi atpakaļ
036_scheduler_outbox.sql f182e97fb9 first commit 1 mēnesi atpakaļ
037_add_account_rate_multiplier.sql f182e97fb9 first commit 1 mēnesi atpakaļ
037_ops_alert_silences.sql f182e97fb9 first commit 1 mēnesi atpakaļ
038_ops_errors_resolution_retry_results_and_standardize_classification.sql f182e97fb9 first commit 1 mēnesi atpakaļ
039_ops_job_heartbeats_add_last_result.sql f182e97fb9 first commit 1 mēnesi atpakaļ
040_add_group_model_routing.sql f182e97fb9 first commit 1 mēnesi atpakaļ
041_add_model_routing_enabled.sql f182e97fb9 first commit 1 mēnesi atpakaļ
042_add_usage_cleanup_tasks.sql f182e97fb9 first commit 1 mēnesi atpakaļ
042b_add_ops_system_metrics_switch_count.sql f182e97fb9 first commit 1 mēnesi atpakaļ
043_add_usage_cleanup_cancel_audit.sql f182e97fb9 first commit 1 mēnesi atpakaļ
043b_add_group_invalid_request_fallback.sql f182e97fb9 first commit 1 mēnesi atpakaļ
044_add_user_totp.sql f182e97fb9 first commit 1 mēnesi atpakaļ
044b_add_group_mcp_xml_inject.sql f182e97fb9 first commit 1 mēnesi atpakaļ
045_add_accounts_extra_index.sql f182e97fb9 first commit 1 mēnesi atpakaļ
045_add_announcements.sql f182e97fb9 first commit 1 mēnesi atpakaļ
045_add_api_key_quota.sql f182e97fb9 first commit 1 mēnesi atpakaļ
046_add_sora_accounts.sql f182e97fb9 first commit 1 mēnesi atpakaļ
046_add_usage_log_reasoning_effort.sql f182e97fb9 first commit 1 mēnesi atpakaļ
046b_add_group_supported_model_scopes.sql f182e97fb9 first commit 1 mēnesi atpakaļ
047_add_sora_pricing_and_media_type.sql f182e97fb9 first commit 1 mēnesi atpakaļ
047_add_user_group_rate_multipliers.sql f182e97fb9 first commit 1 mēnesi atpakaļ
048_add_error_passthrough_rules.sql f182e97fb9 first commit 1 mēnesi atpakaļ
049_unify_antigravity_model_mapping.sql f182e97fb9 first commit 1 mēnesi atpakaļ
050_map_opus46_to_opus45.sql f182e97fb9 first commit 1 mēnesi atpakaļ
051_migrate_opus45_to_opus46_thinking.sql f182e97fb9 first commit 1 mēnesi atpakaļ
052_add_group_sort_order.sql f182e97fb9 first commit 1 mēnesi atpakaļ
052_migrate_upstream_to_apikey.sql f182e97fb9 first commit 1 mēnesi atpakaļ
053_add_security_secrets.sql f182e97fb9 first commit 1 mēnesi atpakaļ
053_add_skip_monitoring_to_error_passthrough.sql f182e97fb9 first commit 1 mēnesi atpakaļ
054_drop_legacy_cache_columns.sql f182e97fb9 first commit 1 mēnesi atpakaļ
054_ops_system_logs.sql f182e97fb9 first commit 1 mēnesi atpakaļ
055_add_cache_ttl_overridden.sql f182e97fb9 first commit 1 mēnesi atpakaļ
056_add_api_key_last_used_at.sql f182e97fb9 first commit 1 mēnesi atpakaļ
057_add_idempotency_records.sql f182e97fb9 first commit 1 mēnesi atpakaļ
058_add_sonnet46_to_model_mapping.sql f182e97fb9 first commit 1 mēnesi atpakaļ
059_add_gemini31_pro_to_model_mapping.sql f182e97fb9 first commit 1 mēnesi atpakaļ
060_add_gemini31_flash_image_to_model_mapping.sql f182e97fb9 first commit 1 mēnesi atpakaļ
060_add_usage_log_openai_ws_mode.sql f182e97fb9 first commit 1 mēnesi atpakaļ
061_add_usage_log_request_type.sql f182e97fb9 first commit 1 mēnesi atpakaļ
062_add_scheduler_and_usage_composite_indexes_notx.sql f182e97fb9 first commit 1 mēnesi atpakaļ
063_add_sora_client_tables.sql f182e97fb9 first commit 1 mēnesi atpakaļ
064_add_api_key_rate_limits.sql f182e97fb9 first commit 1 mēnesi atpakaļ
065_add_search_trgm_indexes.sql f182e97fb9 first commit 1 mēnesi atpakaļ
066_add_scheduled_test_tables.sql f182e97fb9 first commit 1 mēnesi atpakaļ
067_add_account_load_factor.sql f182e97fb9 first commit 1 mēnesi atpakaļ
068_add_announcement_notify_mode.sql f182e97fb9 first commit 1 mēnesi atpakaļ
069_add_group_messages_dispatch.sql f182e97fb9 first commit 1 mēnesi atpakaļ
070_add_scheduled_test_auto_recover.sql f182e97fb9 first commit 1 mēnesi atpakaļ
070_add_usage_log_service_tier.sql f182e97fb9 first commit 1 mēnesi atpakaļ
071_add_gemini25_flash_image_to_model_mapping.sql f182e97fb9 first commit 1 mēnesi atpakaļ
071_add_usage_billing_dedup.sql f182e97fb9 first commit 1 mēnesi atpakaļ
072_add_usage_billing_dedup_created_at_brin_notx.sql f182e97fb9 first commit 1 mēnesi atpakaļ
073_add_usage_billing_dedup_archive.sql f182e97fb9 first commit 1 mēnesi atpakaļ
074_add_usage_log_endpoints.sql f182e97fb9 first commit 1 mēnesi atpakaļ
075_add_usage_log_upstream_model.sql f182e97fb9 first commit 1 mēnesi atpakaļ
075_map_haiku45_to_sonnet46.sql f182e97fb9 first commit 1 mēnesi atpakaļ
076_add_usage_log_upstream_model_index_notx.sql f182e97fb9 first commit 1 mēnesi atpakaļ
077_add_usage_log_requested_model.sql f182e97fb9 first commit 1 mēnesi atpakaļ
078_add_usage_log_requested_model_index_notx.sql f182e97fb9 first commit 1 mēnesi atpakaļ
079_ops_error_logs_add_endpoint_fields.sql f182e97fb9 first commit 1 mēnesi atpakaļ
080_create_tls_fingerprint_profiles.sql f182e97fb9 first commit 1 mēnesi atpakaļ
081_add_group_account_filter.sql f182e97fb9 first commit 1 mēnesi atpakaļ
081_create_channels.sql f182e97fb9 first commit 1 mēnesi atpakaļ
082_refactor_channel_pricing.sql f182e97fb9 first commit 1 mēnesi atpakaļ
083_channel_model_mapping.sql f182e97fb9 first commit 1 mēnesi atpakaļ
084_channel_billing_model_source.sql f182e97fb9 first commit 1 mēnesi atpakaļ
085_channel_restrict_and_per_request_price.sql f182e97fb9 first commit 1 mēnesi atpakaļ
086_channel_platform_pricing.sql f182e97fb9 first commit 1 mēnesi atpakaļ
087_usage_log_billing_mode.sql f182e97fb9 first commit 1 mēnesi atpakaļ
088_channel_billing_model_source_channel_mapped.sql f182e97fb9 first commit 1 mēnesi atpakaļ
089_usage_log_image_output_tokens.sql f182e97fb9 first commit 1 mēnesi atpakaļ
090_drop_sora.sql f182e97fb9 first commit 1 mēnesi atpakaļ
091_add_group_messages_dispatch_model_config.sql f182e97fb9 first commit 1 mēnesi atpakaļ
092_payment_orders.sql f182e97fb9 first commit 1 mēnesi atpakaļ
093_payment_audit_logs.sql f182e97fb9 first commit 1 mēnesi atpakaļ
094_removed_payment_channels.sql f182e97fb9 first commit 1 mēnesi atpakaļ
095_channel_features.sql f182e97fb9 first commit 1 mēnesi atpakaļ
095_subscription_plans.sql f182e97fb9 first commit 1 mēnesi atpakaļ
096_payment_provider_instances.sql f182e97fb9 first commit 1 mēnesi atpakaļ
097_fix_settings_updated_at_default.sql f182e97fb9 first commit 1 mēnesi atpakaļ
098_migrate_purchase_subscription_to_custom_menu.sql f182e97fb9 first commit 1 mēnesi atpakaļ
099_fix_migrated_purchase_menu_label_icon.sql f182e97fb9 first commit 1 mēnesi atpakaļ
100_remove_easypay_from_enabled_payment_types.sql f182e97fb9 first commit 1 mēnesi atpakaļ
101_add_account_stats_pricing.sql f182e97fb9 first commit 1 mēnesi atpakaļ
101_add_balance_notify_fields.sql f182e97fb9 first commit 1 mēnesi atpakaļ
101_add_channel_features_config.sql f182e97fb9 first commit 1 mēnesi atpakaļ
101_add_payment_mode.sql f182e97fb9 first commit 1 mēnesi atpakaļ
102_add_balance_notify_threshold_type.sql f182e97fb9 first commit 1 mēnesi atpakaļ
102_add_out_trade_no_to_payment_orders.sql f182e97fb9 first commit 1 mēnesi atpakaļ
103_add_allow_user_refund.sql f182e97fb9 first commit 1 mēnesi atpakaļ
104_migrate_notify_emails_to_struct.sql f182e97fb9 first commit 1 mēnesi atpakaļ
105_migrate_websearch_emulation_to_tristate.sql f182e97fb9 first commit 1 mēnesi atpakaļ
106_add_account_stats_pricing_intervals.sql f182e97fb9 first commit 1 mēnesi atpakaļ
107_add_account_cost_to_dashboard_tables.sql f182e97fb9 first commit 1 mēnesi atpakaļ
108_auth_identity_foundation_core.sql f182e97fb9 first commit 1 mēnesi atpakaļ
108a_widen_auth_identity_migration_report_type.sql f182e97fb9 first commit 1 mēnesi atpakaļ
109_auth_identity_compat_backfill.sql f182e97fb9 first commit 1 mēnesi atpakaļ
110_pending_auth_and_provider_default_grants.sql f182e97fb9 first commit 1 mēnesi atpakaļ
111_payment_routing_and_scheduler_flags.sql f182e97fb9 first commit 1 mēnesi atpakaļ
112_add_payment_order_provider_key_snapshot.sql f182e97fb9 first commit 1 mēnesi atpakaļ
113_normalize_legacy_wechat_provider_key.sql f182e97fb9 first commit 1 mēnesi atpakaļ
114_auth_identity_migration_report_resolution.sql f182e97fb9 first commit 1 mēnesi atpakaļ
115_auth_identity_legacy_external_backfill.sql f182e97fb9 first commit 1 mēnesi atpakaļ
116_auth_identity_legacy_external_safety_reports.sql f182e97fb9 first commit 1 mēnesi atpakaļ
117_add_payment_order_provider_snapshot.sql f182e97fb9 first commit 1 mēnesi atpakaļ
118_wechat_dual_mode_and_auth_source_defaults.sql f182e97fb9 first commit 1 mēnesi atpakaļ
119_enforce_payment_orders_out_trade_no_unique.sql f182e97fb9 first commit 1 mēnesi atpakaļ
120_enforce_payment_orders_out_trade_no_unique_notx.sql f182e97fb9 first commit 1 mēnesi atpakaļ
120a_align_payment_orders_out_trade_no_index_name.sql f182e97fb9 first commit 1 mēnesi atpakaļ
121_auth_identity_migration_report_type_widen.sql f182e97fb9 first commit 1 mēnesi atpakaļ
122_pending_auth_completion_token_cleanup.sql f182e97fb9 first commit 1 mēnesi atpakaļ
123_fix_legacy_auth_source_grant_on_signup_defaults.sql f182e97fb9 first commit 1 mēnesi atpakaļ
124_backfill_legacy_oidc_security_flags.sql f182e97fb9 first commit 1 mēnesi atpakaļ
125_add_channel_monitors.sql f182e97fb9 first commit 1 mēnesi atpakaļ
125_add_group_rpm_limit.sql f182e97fb9 first commit 1 mēnesi atpakaļ
126_add_channel_monitor_aggregation.sql f182e97fb9 first commit 1 mēnesi atpakaļ
126_add_user_rpm_limit.sql f182e97fb9 first commit 1 mēnesi atpakaļ
127_add_user_group_rpm_override.sql f182e97fb9 first commit 1 mēnesi atpakaļ
127_drop_channel_monitor_deleted_at.sql f182e97fb9 first commit 1 mēnesi atpakaļ
128_add_channel_monitor_request_templates.sql f182e97fb9 first commit 1 mēnesi atpakaļ
129_seed_claude_code_template.sql f182e97fb9 first commit 1 mēnesi atpakaļ
130_add_user_affiliates.sql f182e97fb9 first commit 1 mēnesi atpakaļ
131_affiliate_rebate_hardening.sql f182e97fb9 first commit 1 mēnesi atpakaļ
132_affiliate_custom_settings.sql f182e97fb9 first commit 1 mēnesi atpakaļ
133_affiliate_rebate_freeze.sql f182e97fb9 first commit 1 mēnesi atpakaļ
134_affiliate_ledger_audit_snapshots.sql f182e97fb9 first commit 1 mēnesi atpakaļ
134_image_generation_group_controls.sql f182e97fb9 first commit 1 mēnesi atpakaļ
135_allow_email_oauth_provider_types.sql f182e97fb9 first commit 1 mēnesi atpakaļ
135_content_moderation.sql f182e97fb9 first commit 1 mēnesi atpakaļ
136_add_dingtalk_provider_type.sql f182e97fb9 first commit 1 mēnesi atpakaļ
136_remove_ops_retry_replay.sql f182e97fb9 first commit 1 mēnesi atpakaļ
136_usage_log_image_size_metadata.sql f182e97fb9 first commit 1 mēnesi atpakaļ
137_redeem_code_expires_at.sql f182e97fb9 first commit 1 mēnesi atpakaļ
138_channel_monitor_openai_api_mode.sql f182e97fb9 first commit 1 mēnesi atpakaļ
139_seed_openai_monitor_templates.sql f182e97fb9 first commit 1 mēnesi atpakaļ
140_extend_user_provider_default_grants_check.sql f182e97fb9 first commit 1 mēnesi atpakaļ
141_subscription_expiry_notify_enabled.sql f182e97fb9 first commit 1 mēnesi atpakaļ
142_user_platform_quotas.sql f182e97fb9 first commit 1 mēnesi atpakaļ
143_group_models_list_config.sql f182e97fb9 first commit 1 mēnesi atpakaļ
144_add_opus48_to_model_mapping.sql f182e97fb9 first commit 1 mēnesi atpakaļ
145_deleted_api_key_audit.sql f182e97fb9 first commit 1 mēnesi atpakaļ
145_ops_metrics_ttft_sample_count.sql f182e97fb9 first commit 1 mēnesi atpakaļ
147_ops_error_log_api_key_prefix.sql f182e97fb9 first commit 1 mēnesi atpakaļ
148_add_ops_error_logs_user_time_index_notx.sql f182e97fb9 first commit 1 mēnesi atpakaļ
149_proxy_expiry_fallback.sql f182e97fb9 first commit 1 mēnesi atpakaļ
150_account_group_scheduler_indexes_notx.sql f182e97fb9 first commit 1 mēnesi atpakaļ
151_account_autopause_expiry_index_notx.sql f182e97fb9 first commit 1 mēnesi atpakaļ
151_channel_monitor_jitter.sql f182e97fb9 first commit 1 mēnesi atpakaļ
152_scheduler_outbox_dedup_key.sql f182e97fb9 first commit 1 mēnesi atpakaļ
153_scheduler_outbox_pending_dedup_key_index_notx.sql f182e97fb9 first commit 1 mēnesi atpakaļ
154_account_spark_shadow.sql f182e97fb9 first commit 1 mēnesi atpakaļ
154_add_ops_system_logs_api_key_id.sql f182e97fb9 first commit 1 mēnesi atpakaļ
154a_account_spark_shadow_indexes_notx.sql f182e97fb9 first commit 1 mēnesi atpakaļ
155_add_ops_system_logs_api_key_id_index_notx.sql f182e97fb9 first commit 1 mēnesi atpakaļ
156_content_moderation_matched_keyword.sql f182e97fb9 first commit 1 mēnesi atpakaļ
157_user_platform_quotas_add_grok.sql f182e97fb9 first commit 1 mēnesi atpakaļ
158_add_group_peak_rate_multiplier.sql f182e97fb9 first commit 1 mēnesi atpakaļ
158_enable_grok_media_generation_groups.sql f182e97fb9 first commit 1 mēnesi atpakaļ
159_batch_image_foundation.sql f182e97fb9 first commit 1 mēnesi atpakaļ
160_add_user_frozen_balance.sql f182e97fb9 first commit 1 mēnesi atpakaļ
160_batch_image_provider_refs.sql f182e97fb9 first commit 1 mēnesi atpakaļ
161_batch_image_pricing_snapshot.sql f182e97fb9 first commit 1 mēnesi atpakaļ
162_add_group_batch_image_generation_gate.sql f182e97fb9 first commit 1 mēnesi atpakaļ
163_batch_image_default_discount_and_hold_ratio.sql f182e97fb9 first commit 1 mēnesi atpakaļ
164_batch_image_download_and_user_delete.sql f182e97fb9 first commit 1 mēnesi atpakaļ
165_hide_pre_upstream_batch_image_failures.sql f182e97fb9 first commit 1 mēnesi atpakaļ
166_batch_image_task_name.sql f182e97fb9 first commit 1 mēnesi atpakaļ
167_clear_auto_batch_image_task_names.sql f182e97fb9 first commit 1 mēnesi atpakaļ
168_restore_empty_batch_image_task_names.sql f182e97fb9 first commit 1 mēnesi atpakaļ
169_batch_image_parent_batch.sql f182e97fb9 first commit 1 mēnesi atpakaļ
170_add_grok_video_pricing_controls.sql f182e97fb9 first commit 1 mēnesi atpakaļ
171_allow_video_usage_without_image_size.sql f182e97fb9 first commit 1 mēnesi atpakaļ
172_composite_model_routes.sql f182e97fb9 first commit 1 mēnesi atpakaļ
172_video_per_second_billing_metadata.sql f182e97fb9 first commit 1 mēnesi atpakaļ
173_allow_cyber_blocked_usage_request_type.sql f182e97fb9 first commit 1 mēnesi atpakaļ
174_add_usage_log_long_context_billing.sql f182e97fb9 first commit 1 mēnesi atpakaļ
174_add_usage_logs_api_key_latest_ip_index_notx.sql f182e97fb9 first commit 1 mēnesi atpakaļ
174_group_web_search_price_per_call.sql f182e97fb9 first commit 1 mēnesi atpakaļ
175_add_ops_system_logs_host.sql f182e97fb9 first commit 1 mēnesi atpakaļ
175_default_openai_long_context_billing.sql f182e97fb9 first commit 1 mēnesi atpakaļ
175a_add_ops_system_logs_host_index_notx.sql f182e97fb9 first commit 1 mēnesi atpakaļ
176_channel_monitor_grok_provider.sql f182e97fb9 first commit 1 mēnesi atpakaļ
177_add_subscription_plan_currency.sql f182e97fb9 first commit 1 mēnesi atpakaļ
178_channel_image_input_price.sql f182e97fb9 first commit 1 mēnesi atpakaļ
179_usage_log_image_input_tokens.sql f182e97fb9 first commit 1 mēnesi atpakaļ
180_audit_logs.sql f182e97fb9 first commit 1 mēnesi atpakaļ
181_group_duplicate_operation_id.sql f182e97fb9 first commit 1 mēnesi atpakaļ
181_prompt_audit.sql f182e97fb9 first commit 1 mēnesi atpakaļ
182_prompt_audit_full_prompt.sql f182e97fb9 first commit 1 mēnesi atpakaļ
183_ops_ingress_reject_aggregates.sql f182e97fb9 first commit 1 mēnesi atpakaļ
184_auth_cache_invalidation_outbox.sql f182e97fb9 first commit 1 mēnesi atpakaļ
185_group_reasoning_effort_policy.sql f182e97fb9 first commit 1 mēnesi atpakaļ
186_alipay_mobile_precreate_deep_link.sql f182e97fb9 first commit 1 mēnesi atpakaļ
186_group_auth_cache_image_generation.sql f182e97fb9 first commit 1 mēnesi atpakaļ
187_add_usage_log_session_id.sql f182e97fb9 first commit 1 mēnesi atpakaļ
188_allow_live_usage_request_type.sql f182e97fb9 first commit 1 mēnesi atpakaļ
189_add_group_allow_live.sql f182e97fb9 first commit 1 mēnesi atpakaļ
190_add_users_email_alias_dedup_index_notx.sql f182e97fb9 first commit 1 mēnesi atpakaļ
191_passkey_credentials.sql f182e97fb9 first commit 1 mēnesi atpakaļ
192_group_profit_control.sql f182e97fb9 first commit 1 mēnesi atpakaļ
193_group_profit_control_auth_cache_invalidation.sql f182e97fb9 first commit 1 mēnesi atpakaļ
194_add_usage_log_upstream_response_model.sql f182e97fb9 first commit 1 mēnesi atpakaļ
194_channel_monitor_v2.sql f182e97fb9 first commit 1 mēnesi atpakaļ
195_add_usage_log_upstream_model_mismatch_index_notx.sql f182e97fb9 first commit 1 mēnesi atpakaļ
195_channel_monitor_mode.sql f182e97fb9 first commit 1 mēnesi atpakaļ
196_channel_monitor_v2_ignored_error_categories.sql f182e97fb9 first commit 1 mēnesi atpakaļ
197_channel_monitor_v2_seed_popular_models.sql f182e97fb9 first commit 1 mēnesi atpakaļ
198_channel_monitor_v2_health_thresholds.sql f182e97fb9 first commit 1 mēnesi atpakaļ
199_channel_monitor_v2_fixed_rollups.sql f182e97fb9 first commit 1 mēnesi atpakaļ
200_channel_monitor_v2_rollup_permissions.sql f182e97fb9 first commit 1 mēnesi atpakaļ
201_channel_monitor_v2_refresh_5m.sql f182e97fb9 first commit 1 mēnesi atpakaļ
202_channel_monitor_v2_full_table_permissions.sql f182e97fb9 first commit 1 mēnesi atpakaļ
203_channel_monitor_v2_default_ignore_and_cache.sql f182e97fb9 first commit 1 mēnesi atpakaļ
204_channel_monitor_hide_throughput.sql f182e97fb9 first commit 1 mēnesi atpakaļ
205_channel_monitor_v2_reset_factory_cache_thresholds.sql f182e97fb9 first commit 1 mēnesi atpakaļ
206_channel_monitor_v2_privacy_defaults.sql f182e97fb9 first commit 1 mēnesi atpakaļ
217_group_video_model_prices.sql f182e97fb9 first commit 1 mēnesi atpakaļ
218_group_audio_voice_pricing.sql f182e97fb9 first commit 1 mēnesi atpakaļ
219_group_search_price_per_1k.sql f182e97fb9 first commit 1 mēnesi atpakaļ
220_clear_non_grok_video_generation_config.sql f182e97fb9 first commit 1 mēnesi atpakaļ
221_group_model_pricing.sql f182e97fb9 first commit 1 mēnesi atpakaļ
222_group_usage_daily_rollups.sql f182e97fb9 first commit 1 mēnesi atpakaļ
223_group_usage_rollup_timezone.sql f182e97fb9 first commit 1 mēnesi atpakaļ
224_user_platform_quotas_add_cn_providers.sql f182e97fb9 first commit 1 mēnesi atpakaļ
225_backfill_codex_fingerprint_seed.sql f182e97fb9 first commit 1 mēnesi atpakaļ
225_channel_model_time_pricing.sql f182e97fb9 first commit 1 mēnesi atpakaļ
226_add_usage_log_effective_model_indexes_notx.sql f182e97fb9 first commit 1 mēnesi atpakaļ
226_channel_monitor_quota_mode.sql f182e97fb9 first commit 1 mēnesi atpakaļ
227_composite_routes_add_cn_providers.sql f182e97fb9 first commit 1 mēnesi atpakaļ
228_channel_pricing_multipliers.sql f182e97fb9 first commit 1 mēnesi atpakaļ
229_plugins.sql f182e97fb9 first commit 1 mēnesi atpakaļ
230_plugin_artifacts.sql f182e97fb9 first commit 1 mēnesi atpakaļ
231_add_usage_log_native_compaction_v2.sql f182e97fb9 first commit 1 mēnesi atpakaļ
231_add_usage_log_requested_reasoning_effort.sql f182e97fb9 first commit 1 mēnesi atpakaļ
231_user_restrict_public_groups.sql f182e97fb9 first commit 1 mēnesi atpakaļ
232_add_usage_log_upstream_request_id.sql f182e97fb9 first commit 1 mēnesi atpakaļ
232_channel_cache_write_1h_pricing.sql f182e97fb9 first commit 1 mēnesi atpakaļ
232_group_force_openai_fast.sql f182e97fb9 first commit 1 mēnesi atpakaļ
232_group_reasoning_effort_over_limit.sql f182e97fb9 first commit 1 mēnesi atpakaļ
233_add_usage_log_upstream_request_id_index_notx.sql f182e97fb9 first commit 1 mēnesi atpakaļ
233_group_free_openai_fast.sql f182e97fb9 first commit 1 mēnesi atpakaļ
234_channel_max_reasoning_effort_multiplier.sql f182e97fb9 first commit 1 mēnesi atpakaļ
234_group_codex_models_manifest_config.sql f182e97fb9 first commit 1 mēnesi atpakaļ
235_account_proxy_mode_check.sql f182e97fb9 first commit 1 mēnesi atpakaļ
235_group_model_allowlist.sql f182e97fb9 first commit 1 mēnesi atpakaļ
236_group_model_allowlist_repair.sql f182e97fb9 first commit 1 mēnesi atpakaļ
237_add_minimax_platform.sql f182e97fb9 first commit 1 mēnesi atpakaļ
237_group_security_policy.sql f182e97fb9 first commit 1 mēnesi atpakaļ
238_content_moderation_overturned.sql f182e97fb9 first commit 1 mēnesi atpakaļ
241_security_policy_keyword_deleted_at_index.sql f182e97fb9 first commit 1 mēnesi atpakaļ
242_global_model_pricing.sql f182e97fb9 first commit 1 mēnesi atpakaļ
243_support_tickets.sql f182e97fb9 first commit 1 mēnesi atpakaļ
244_legacy_api_key_read_compat.sql f182e97fb9 first commit 1 mēnesi atpakaļ
245_user_cleanup.sql f182e97fb9 first commit 1 mēnesi atpakaļ
246_account_protection_roles.sql f182e97fb9 first commit 1 mēnesi atpakaļ
247_intelligent_tests.sql f182e97fb9 first commit 1 mēnesi atpakaļ
248_intelligent_assessment_v2.sql f182e97fb9 first commit 1 mēnesi atpakaļ
README.md f182e97fb9 first commit 1 mēnesi atpakaļ
account_proxy_mode_check_migration_test.go f182e97fb9 first commit 1 mēnesi atpakaļ
auth_identity_payment_migrations_regression_test.go f182e97fb9 first commit 1 mēnesi atpakaļ
channel_monitor_grok_provider_migration_test.go f182e97fb9 first commit 1 mēnesi atpakaļ
channel_monitor_quota_mode_migration_test.go f182e97fb9 first commit 1 mēnesi atpakaļ
channel_pricing_multipliers_migration_test.go f182e97fb9 first commit 1 mēnesi atpakaļ
composite_routes_cn_providers_migration_test.go f182e97fb9 first commit 1 mēnesi atpakaļ
group_force_openai_fast_migration_test.go f182e97fb9 first commit 1 mēnesi atpakaļ
group_free_openai_fast_migration_test.go f182e97fb9 first commit 1 mēnesi atpakaļ
group_model_allowlist_repair_migration_test.go f182e97fb9 first commit 1 mēnesi atpakaļ
group_usage_rollup_migration_test.go f182e97fb9 first commit 1 mēnesi atpakaļ
latest_api_key_ip_index_test.go f182e97fb9 first commit 1 mēnesi atpakaļ
migrations.go f182e97fb9 first commit 1 mēnesi atpakaļ
minimax_platform_migration_test.go f182e97fb9 first commit 1 mēnesi atpakaļ
openai_long_context_billing_migration_test.go f182e97fb9 first commit 1 mēnesi atpakaļ
plugins_migration_test.go f182e97fb9 first commit 1 mēnesi atpakaļ
usage_log_effective_model_index_test.go f182e97fb9 first commit 1 mēnesi atpakaļ
user_platform_quota_cn_providers_migration_test.go f182e97fb9 first commit 1 mēnesi atpakaļ

README.md

Database Migrations

Overview

This directory contains SQL migration files for database schema changes. The migration system uses SHA256 checksums to ensure migration immutability and consistency across environments.

Migration File Naming

Format: NNN_description.sql

  • NNN: Sequential number (e.g., 001, 002, 003)
  • description: Brief description in snake_case

Example: 017_add_gemini_tier_id.sql

_notx.sql 命名与执行语义(并发索引专用)

当迁移包含 CREATE INDEX CONCURRENTLY 或 DROP INDEX CONCURRENTLY 时,必须使用 _notx.sql 后缀,例如:

  • 062_add_accounts_priority_indexes_notx.sql
  • 063_drop_legacy_indexes_notx.sql

运行规则:

  1. *.sql(不带 _notx)按事务执行。
  2. *_notx.sql 按非事务执行,不会包裹在 BEGIN/COMMIT 中。
  3. *_notx.sql 仅允许并发索引语句,不允许混入事务控制语句或其他 DDL/DML。

幂等要求(必须):

  • 创建索引:CREATE INDEX CONCURRENTLY IF NOT EXISTS ...
  • 删除索引:DROP INDEX CONCURRENTLY IF EXISTS ...

这样可以保证灾备重放、重复执行时不会因对象已存在/不存在而失败。

Migration File Structure

This project uses a custom migration runner (internal/repository/migrations_runner.go) that executes the full SQL file content as-is.

  • Regular migrations (*.sql): executed in a transaction.
  • Non-transactional migrations (*_notx.sql): split by statement and executed without transaction (for CONCURRENTLY).

    -- Forward-only migration (recommended)
    ALTER TABLE usage_logs ADD COLUMN IF NOT EXISTS example_column VARCHAR(100);
    

⚠️ Do not place executable "Down" SQL in the same file. The runner does not parse goose Up/Down sections and will execute all SQL statements in the file.

Important Rules

⚠️ Immutability Principle

Once a migration is applied to ANY environment (dev, staging, production), it MUST NOT be modified.

Why?

  • Each migration has a SHA256 checksum stored in the schema_migrations table
  • Modifying an applied migration causes checksum mismatch errors
  • Different environments would have inconsistent database states
  • Breaks audit trail and reproducibility

✅ Correct Workflow

  1. Create new migration

    # Create new file with next sequential number
    touch migrations/018_your_change.sql
    
  2. Write forward-only migration SQL

    • Put only the intended schema change in the file
    • If rollback is needed, create a new migration file to revert
  3. Test locally

    # Apply migration
    make migrate-up
    
    # Test rollback
    make migrate-down
    
  4. Commit and deploy

    git add migrations/018_your_change.sql
    git commit -m "feat(db): add your change"
    

❌ What NOT to Do

  • ❌ Modify an already-applied migration file
  • ❌ Delete migration files
  • ❌ Change migration file names
  • ❌ Reorder migration numbers

🔧 If You Accidentally Modified an Applied Migration

Error message:

migration 017_add_gemini_tier_id.sql checksum mismatch (db=abc123... file=def456...)

Solution:

# 1. Find the original version
git log --oneline -- migrations/017_add_gemini_tier_id.sql

# 2. Revert to the commit when it was first applied
git checkout <commit-hash> -- migrations/017_add_gemini_tier_id.sql

# 3. Create a NEW migration for your changes
touch migrations/018_your_new_change.sql

Migration System Details

  • Checksum Algorithm: SHA256 of trimmed file content
  • Tracking Table: schema_migrations (filename, checksum, applied_at)
  • Runner: internal/repository/migrations_runner.go
  • Auto-run: Migrations run automatically on service startup

Best Practices

  1. Keep migrations small and focused

    • One logical change per migration
    • Easier to review and rollback
  2. Write reversible migrations

    • Always provide a working Down migration
    • Test rollback before committing
  3. Use transactions

    • Wrap DDL statements in transactions when possible
    • Ensures atomicity
  4. Add comments

    • Explain WHY the change is needed
    • Document any special considerations
  5. Test in development first

    • Apply migration locally
    • Verify data integrity
    • Test rollback

Example Migration

-- Add tier_id field to Gemini OAuth accounts for quota tracking
UPDATE accounts
SET credentials = jsonb_set(
    credentials,
    '{tier_id}',
    '"LEGACY"',
    true
)
WHERE platform = 'gemini'
  AND type = 'oauth'
  AND credentials->>'tier_id' IS NULL;

Troubleshooting

Checksum Mismatch

See "If You Accidentally Modified an Applied Migration" above.

Migration Failed

# Check migration status
psql -d sub2api -c "SELECT * FROM schema_migrations ORDER BY applied_at DESC;"

# Manually rollback if needed (use with caution)
# Better to fix the migration and create a new one

Need to Skip a Migration (Emergency Only)

-- DANGEROUS: Only use in development or with extreme caution
INSERT INTO schema_migrations (filename, checksum, applied_at)
VALUES ('NNN_migration.sql', 'calculated_checksum', NOW());

References