feat: Add player_configs feature and migrate user preferences

- Implemented player_configs table to store multiple player configurations per user.
- Migrated existing player settings from user_preferences to player_configs.
- Removed player-related columns from user_preferences.
- Added referral state fields to user for tracking referral rewards.
- Created migration scripts for database changes and data migration.
- Added test cases for app services and usage helpers.
- Introduced video job service interfaces and implementations.
This commit is contained in:
2026-03-24 16:08:36 +00:00
parent 91e5e3542b
commit e7fdd0e1ab
103 changed files with 9540 additions and 8446 deletions

59
run_migration.sh Executable file
View File

@@ -0,0 +1,59 @@
#!/bin/bash
# Migration runner script for stream.api
# Usage: ./run_migration.sh [migration_file.sql]
set -e
# Load environment variables from config if exists
if [ -f "config.yaml" ]; then
echo "Loading configuration from config.yaml..."
fi
# Database connection parameters (adjust these based on your config)
DB_HOST="${DB_HOST:-localhost}"
DB_PORT="${DB_PORT:-5432}"
DB_NAME="${DB_NAME:-stream}"
DB_USER="${DB_USER:-postgres}"
DB_PASSWORD="${DB_PASSWORD:-}"
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
echo -e "${GREEN}=== Stream API Migration Runner ===${NC}"
# Check if psql is available
if ! command -v psql &> /dev/null; then
echo -e "${RED}Error: psql command not found. Please install PostgreSQL client.${NC}"
exit 1
fi
# Build connection string
export PGPASSWORD="$DB_PASSWORD"
# Run specific migration or all migrations
if [ -n "$1" ]; then
MIGRATION_FILE="$1"
if [ ! -f "$MIGRATION_FILE" ]; then
echo -e "${RED}Error: Migration file '$MIGRATION_FILE' not found${NC}"
exit 1
fi
echo -e "${YELLOW}Running migration: $MIGRATION_FILE${NC}"
psql -h "$DB_HOST" -p "$DB_PORT" -U "$DB_USER" -d "$DB_NAME" -f "$MIGRATION_FILE"
echo -e "${GREEN}✓ Migration completed successfully${NC}"
else
# Run all migrations in order
echo -e "${YELLOW}Running all migrations in ./migrations/...${NC}"
for migration in $(ls -1 migrations/*.sql 2>/dev/null | sort); do
echo -e "${YELLOW}Running: $migration${NC}"
psql -h "$DB_HOST" -p "$DB_PORT" -U "$DB_USER" -d "$DB_NAME" -f "$migration"
echo -e "${GREEN}✓ Completed: $migration${NC}"
echo ""
done
echo -e "${GREEN}=== All migrations completed ===${NC}"
fi
unset PGPASSWORD