Files
lionwebsite-backend/scripts/migrate_subscription_accounts.sh

19 lines
530 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
db_path="${1:-LionWebsite.db}"
legacy_key="${2:-}"
if [[ -z "$legacy_key" || ! "$legacy_key" =~ ^[A-Za-z0-9._~-]+$ ]]; then
echo "用法: $0 <LionWebsite.db> <现有共享订阅 upstream key>" >&2
exit 2
fi
if [[ ! -f "$db_path" ]]; then
echo "数据库不存在: $db_path" >&2
exit 2
fi
sqlite3 "$db_path" -cmd ".parameter init" -cmd ".parameter set :legacy_key '$legacy_key'" \
< "$(dirname "$0")/migrate_subscription_accounts.sql"
echo "订阅子账号迁移完成: $db_path"