Merge branch 'main' into postgres-migration
This commit is contained in:
commit
fbe8623eb4
175
.env
Normal file
175
.env
Normal file
@ -0,0 +1,175 @@
|
||||
# Paper Dynasty Database API - Environment Configuration
|
||||
# Copy this file to .env and update with your actual values
|
||||
# DO NOT commit .env to version control!
|
||||
|
||||
# =============================================================================
|
||||
# DATABASE CONFIGURATION
|
||||
# =============================================================================
|
||||
|
||||
# Database type: 'sqlite' or 'postgresql'
|
||||
# Default: sqlite
|
||||
DATABASE_TYPE=postgresql
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# SQLite Configuration (used when DATABASE_TYPE=sqlite)
|
||||
# -----------------------------------------------------------------------------
|
||||
# SQLite uses the file: storage/pd_master.db
|
||||
# No additional configuration needed for SQLite
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# PostgreSQL Configuration (used when DATABASE_TYPE=postgresql)
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# PostgreSQL host (hostname or IP address)
|
||||
# Default: localhost
|
||||
POSTGRES_HOST=sba_postgres
|
||||
|
||||
# PostgreSQL port
|
||||
# Default: 5432
|
||||
POSTGRES_PORT=5432
|
||||
|
||||
# PostgreSQL database name
|
||||
# Default: pd_master
|
||||
POSTGRES_DB=paperdynasty_dev
|
||||
|
||||
# PostgreSQL username
|
||||
# Default: pd_admin
|
||||
POSTGRES_USER=sba_admin
|
||||
|
||||
# PostgreSQL password (REQUIRED for PostgreSQL, no default)
|
||||
POSTGRES_PASSWORD=your_production_password
|
||||
|
||||
# =============================================================================
|
||||
# APPLICATION CONFIGURATION
|
||||
# =============================================================================
|
||||
|
||||
# Logging level: 'INFO' or 'WARN'
|
||||
# Default: WARN
|
||||
# Set to INFO for detailed logging during development
|
||||
LOG_LEVEL=INFO
|
||||
|
||||
# API authentication token
|
||||
# Used for Bearer token authentication on protected endpoints
|
||||
# Generate a secure random token for production
|
||||
API_TOKEN=Tp3aO3jhYve5NJF1IqOmJTmk
|
||||
|
||||
# Include private endpoints in OpenAPI schema
|
||||
# Set to any non-empty value to include private endpoints in /docs
|
||||
# Leave empty or omit to exclude private endpoints
|
||||
# PRIVATE_IN_SCHEMA=true
|
||||
|
||||
# Testing mode
|
||||
# Set to 'False' to use development database URL (pddev.manticorum.com)
|
||||
# Leave unset or set to any other value for production
|
||||
TESTING=TRUE
|
||||
|
||||
# =============================================================================
|
||||
# EXAMPLE CONFIGURATIONS
|
||||
# =============================================================================
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Example 1: Local Development with SQLite (Default)
|
||||
# -----------------------------------------------------------------------------
|
||||
# DATABASE_TYPE=sqlite
|
||||
# LOG_LEVEL=INFO
|
||||
# API_TOKEN=dev_token_12345
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Example 2: Local Development with PostgreSQL
|
||||
# -----------------------------------------------------------------------------
|
||||
# DATABASE_TYPE=postgresql
|
||||
# POSTGRES_HOST=localhost
|
||||
# POSTGRES_PORT=5432
|
||||
# POSTGRES_DB=pd_master_dev
|
||||
# POSTGRES_USER=pd_admin
|
||||
# POSTGRES_PASSWORD=dev_password_123
|
||||
# LOG_LEVEL=INFO
|
||||
# API_TOKEN=dev_token_12345
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Example 3: Production with PostgreSQL
|
||||
# -----------------------------------------------------------------------------
|
||||
# DATABASE_TYPE=postgresql
|
||||
# POSTGRES_HOST=db.example.com
|
||||
# POSTGRES_PORT=5432
|
||||
# POSTGRES_DB=pd_master_prod
|
||||
# POSTGRES_USER=pd_prod_user
|
||||
# POSTGRES_PASSWORD=strong_random_password_here
|
||||
# LOG_LEVEL=WARN
|
||||
# API_TOKEN=prod_secure_token_here
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Example 4: Docker Development with PostgreSQL
|
||||
# -----------------------------------------------------------------------------
|
||||
# DATABASE_TYPE=postgresql
|
||||
# POSTGRES_HOST=postgres # Docker service name
|
||||
# POSTGRES_PORT=5432
|
||||
# POSTGRES_DB=pd_master
|
||||
# POSTGRES_USER=pd_admin
|
||||
# POSTGRES_PASSWORD=docker_dev_password
|
||||
# LOG_LEVEL=INFO
|
||||
# API_TOKEN=docker_dev_token
|
||||
|
||||
# =============================================================================
|
||||
# SECURITY NOTES
|
||||
# =============================================================================
|
||||
#
|
||||
# 1. NEVER commit .env files to version control
|
||||
# - .env is already in .gitignore
|
||||
# - Only commit .env.example (this file)
|
||||
#
|
||||
# 2. Use strong passwords in production
|
||||
# - Generate random passwords: openssl rand -base64 32
|
||||
# - Minimum 20 characters for PostgreSQL password
|
||||
#
|
||||
# 3. Rotate API tokens regularly
|
||||
# - Generate secure tokens: python -c "import secrets; print(secrets.token_urlsafe(32))"
|
||||
#
|
||||
# 4. Restrict database access
|
||||
# - Use firewall rules to limit PostgreSQL access
|
||||
# - Create separate database users for different environments
|
||||
# - Grant only necessary privileges
|
||||
#
|
||||
# 5. Use environment-specific configurations
|
||||
# - Development: Relaxed settings, verbose logging
|
||||
# - Staging: Production-like settings, moderate logging
|
||||
# - Production: Strict settings, minimal logging
|
||||
#
|
||||
# =============================================================================
|
||||
# MIGRATION NOTES
|
||||
# =============================================================================
|
||||
#
|
||||
# When migrating from SQLite to PostgreSQL:
|
||||
#
|
||||
# 1. Keep SQLite running during migration
|
||||
# - Set DATABASE_TYPE=sqlite
|
||||
# - Application continues to work normally
|
||||
#
|
||||
# 2. Set up PostgreSQL
|
||||
# - Install PostgreSQL server
|
||||
# - Create database and user
|
||||
# - Grant privileges
|
||||
#
|
||||
# 3. Test PostgreSQL connection
|
||||
# - Set DATABASE_TYPE=postgresql
|
||||
# - Set POSTGRES_* variables
|
||||
# - Test: python -c "from app.db_engine import db; db.connect(); print('✓ Connected'); db.close()"
|
||||
#
|
||||
# 4. Run data migration script
|
||||
# - Use scripts/migrate_sqlite_to_postgres.py
|
||||
# - Verify data integrity
|
||||
# - Compare record counts
|
||||
#
|
||||
# 5. Switch to PostgreSQL
|
||||
# - Update .env: DATABASE_TYPE=postgresql
|
||||
# - Restart application
|
||||
# - Monitor logs for errors
|
||||
#
|
||||
# 6. Rollback plan (if needed)
|
||||
# - Update .env: DATABASE_TYPE=sqlite
|
||||
# - Restart application
|
||||
# - SQLite backup: storage/pd_master_backup_YYYYMMDD.db
|
||||
#
|
||||
# See POSTGRES_MIGRATION_PLAN.md for detailed migration instructions
|
||||
#
|
||||
# =============================================================================
|
||||
@ -35,7 +35,7 @@ WORKDIR /usr/src/app
|
||||
|
||||
COPY requirements.txt ./
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
RUN playwright install
|
||||
RUN playwright install-deps
|
||||
RUN playwright install chromium
|
||||
RUN playwright install-deps chromium
|
||||
|
||||
COPY ./app /app/app
|
||||
@ -45,22 +45,22 @@ logging.basicConfig(
|
||||
level=log_level
|
||||
)
|
||||
|
||||
# 2024, 2018
|
||||
ranked_cardsets = [24, 25, 26, 20, 21, 22]
|
||||
LIVE_CARDSET_ID = 24
|
||||
LIVE_PROMO_CARDSET_ID = 25
|
||||
# 2025, 2005
|
||||
ranked_cardsets = [24, 25, 26, 27, 28, 29]
|
||||
LIVE_CARDSET_ID = 27
|
||||
LIVE_PROMO_CARDSET_ID = 28
|
||||
CARDSETS = {
|
||||
'ranked': {
|
||||
'primary': ranked_cardsets,
|
||||
'human': ranked_cardsets
|
||||
},
|
||||
'minor-league': {
|
||||
'primary': [24, 8], # 2025, Mario
|
||||
'secondary': [17], # 2024
|
||||
'primary': [27, 8], # 2005, Mario
|
||||
'secondary': [24], # 2025
|
||||
'human': [x for x in range(1, 30)]
|
||||
},
|
||||
'major-league': {
|
||||
'primary': [20, 21, 24, 25, 13, 9, 8], # 1998, 1998 Promos, 2025, 25 Promos, 2018, 2023, Mario
|
||||
'primary': [27, 28, 24, 25, 13, 14, 6, 8], # 2005 + Promos, 2025 + Promos, 2018 + Promos, 2012, Mario
|
||||
'secondary': [5, 3], # 2019, 2022
|
||||
'human': ranked_cardsets
|
||||
},
|
||||
@ -69,9 +69,9 @@ CARDSETS = {
|
||||
'human': ranked_cardsets
|
||||
},
|
||||
'flashback': {
|
||||
'primary': [5, 1, 3, 9, 8], # 2019, 2021, 2022, 2023, Mario
|
||||
'secondary': [13, 5], # 2018, 2019
|
||||
'human': [5, 1, 3, 9, 8] # 2019, 2021, 2022, 2023
|
||||
'primary': [13, 5, 1, 3, 8], # 2018, 2019, 2021, 2022, Mario
|
||||
'secondary': [24], # 2025
|
||||
'human': [13, 5, 1, 3, 8] # 2018, 2019, 2021, 2022
|
||||
},
|
||||
'gauntlet-3': {
|
||||
'primary': [13], # 2018
|
||||
@ -102,6 +102,10 @@ CARDSETS = {
|
||||
'primary': [24], # 2025
|
||||
'secondary': [17],
|
||||
'human': [24, 25, 22, 23]
|
||||
},
|
||||
'gauntlet-9': {
|
||||
'primary': [27], # 2005
|
||||
'secondary': [24] # 2025
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -18,6 +18,49 @@ from ..db_engine import db, Player, model_to_dict, fn, chunked, Paperdex, Cardse
|
||||
BattingCardRatings, PitchingCard, PitchingCardRatings, CardPosition, MlbPlayer
|
||||
from ..dependencies import oauth2_scheme, valid_token, LOG_DATA
|
||||
|
||||
# Franchise normalization: Convert city+team names to city-agnostic team names
|
||||
# This enables cross-era player matching (e.g., 'Oakland Athletics' -> 'Athletics')
|
||||
FRANCHISE_NORMALIZE = {
|
||||
'Arizona Diamondbacks': 'Diamondbacks',
|
||||
'Atlanta Braves': 'Braves',
|
||||
'Baltimore Orioles': 'Orioles',
|
||||
'Boston Red Sox': 'Red Sox',
|
||||
'Chicago Cubs': 'Cubs',
|
||||
'Chicago White Sox': 'White Sox',
|
||||
'Cincinnati Reds': 'Reds',
|
||||
'Cleveland Guardians': 'Guardians',
|
||||
'Colorado Rockies': 'Rockies',
|
||||
'Detroit Tigers': 'Tigers',
|
||||
'Houston Astros': 'Astros',
|
||||
'Kansas City Royals': 'Royals',
|
||||
'Los Angeles Angels': 'Angels',
|
||||
'Los Angeles Dodgers': 'Dodgers',
|
||||
'Miami Marlins': 'Marlins',
|
||||
'Milwaukee Brewers': 'Brewers',
|
||||
'Minnesota Twins': 'Twins',
|
||||
'New York Mets': 'Mets',
|
||||
'New York Yankees': 'Yankees',
|
||||
'Oakland Athletics': 'Athletics',
|
||||
'Philadelphia Phillies': 'Phillies',
|
||||
'Pittsburgh Pirates': 'Pirates',
|
||||
'San Diego Padres': 'Padres',
|
||||
'San Francisco Giants': 'Giants',
|
||||
'Seattle Mariners': 'Mariners',
|
||||
'St Louis Cardinals': 'Cardinals',
|
||||
'St. Louis Cardinals': 'Cardinals',
|
||||
'Tampa Bay Rays': 'Rays',
|
||||
'Texas Rangers': 'Rangers',
|
||||
'Toronto Blue Jays': 'Blue Jays',
|
||||
'Washington Nationals': 'Nationals',
|
||||
}
|
||||
|
||||
|
||||
def normalize_franchise(franchise: str) -> str:
|
||||
"""Convert city+team name to team-only (e.g., 'Oakland Athletics' -> 'Athletics')"""
|
||||
titled = franchise.title()
|
||||
return FRANCHISE_NORMALIZE.get(titled, titled)
|
||||
|
||||
|
||||
logging.basicConfig(
|
||||
filename=LOG_DATA['filename'],
|
||||
format=LOG_DATA['format'],
|
||||
@ -736,7 +779,7 @@ async def put_players(players: PlayerModel, token: str = Depends(oauth2_scheme))
|
||||
'image': x.image,
|
||||
'image2': x.image2,
|
||||
'mlbclub': x.mlbclub.title(),
|
||||
'franchise': x.franchise.title(),
|
||||
'franchise': normalize_franchise(x.franchise),
|
||||
'cardset_id': x.cardset_id,
|
||||
'rarity_id': x.rarity_id,
|
||||
'set_num': x.set_num,
|
||||
|
||||
@ -258,7 +258,7 @@ async def get_team_lineup(
|
||||
# all_players = Player.select().where(
|
||||
# (fn.Lower(Player.p_name) != pitcher_name.lower()) & (Player.mlbclub == this_team.lname)
|
||||
# )
|
||||
all_players = Player.select().where(Player.franchise == this_team.lname)
|
||||
all_players = Player.select().where(Player.franchise == this_team.sname)
|
||||
|
||||
if difficulty_name == 'exhibition':
|
||||
logging.info(f'pulling an exhibition lineup')
|
||||
@ -519,7 +519,7 @@ async def get_team_sp(
|
||||
db.close()
|
||||
raise HTTPException(status_code=400, detail=f'Difficulty name {difficulty_name} not a valid check')
|
||||
|
||||
all_players = Player.select().where(Player.franchise == this_team.lname)
|
||||
all_players = Player.select().where(Player.franchise == this_team.sname)
|
||||
|
||||
if difficulty_name == 'exhibition':
|
||||
logging.info(f'pulling an exhibition lineup')
|
||||
@ -619,7 +619,7 @@ async def get_team_rp(
|
||||
raise HTTPException(status_code=400, detail=f'Difficulty name {difficulty_name} not a valid check')
|
||||
|
||||
all_players = Player.select().where(
|
||||
(Player.franchise == this_team.lname) & (Player.player_id.not_in(used_pitcher_ids))
|
||||
(Player.franchise == this_team.sname) & (Player.player_id.not_in(used_pitcher_ids))
|
||||
)
|
||||
|
||||
if difficulty_name == 'exhibition':
|
||||
|
||||
48
main.py
48
main.py
@ -32,6 +32,50 @@ app = FastAPI()
|
||||
|
||||
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token")
|
||||
DEFAULT_SEASON = 5
|
||||
|
||||
# Franchise normalization: Convert city+team names to city-agnostic team names
|
||||
# This enables cross-era player matching (e.g., 'Oakland Athletics' -> 'Athletics')
|
||||
FRANCHISE_NORMALIZE = {
|
||||
'Arizona Diamondbacks': 'Diamondbacks',
|
||||
'Atlanta Braves': 'Braves',
|
||||
'Baltimore Orioles': 'Orioles',
|
||||
'Boston Red Sox': 'Red Sox',
|
||||
'Chicago Cubs': 'Cubs',
|
||||
'Chicago White Sox': 'White Sox',
|
||||
'Cincinnati Reds': 'Reds',
|
||||
'Cleveland Guardians': 'Guardians',
|
||||
'Colorado Rockies': 'Rockies',
|
||||
'Detroit Tigers': 'Tigers',
|
||||
'Houston Astros': 'Astros',
|
||||
'Kansas City Royals': 'Royals',
|
||||
'Los Angeles Angels': 'Angels',
|
||||
'Los Angeles Dodgers': 'Dodgers',
|
||||
'Miami Marlins': 'Marlins',
|
||||
'Milwaukee Brewers': 'Brewers',
|
||||
'Minnesota Twins': 'Twins',
|
||||
'New York Mets': 'Mets',
|
||||
'New York Yankees': 'Yankees',
|
||||
'Oakland Athletics': 'Athletics',
|
||||
'Philadelphia Phillies': 'Phillies',
|
||||
'Pittsburgh Pirates': 'Pirates',
|
||||
'San Diego Padres': 'Padres',
|
||||
'San Francisco Giants': 'Giants',
|
||||
'Seattle Mariners': 'Mariners',
|
||||
'St Louis Cardinals': 'Cardinals',
|
||||
'St. Louis Cardinals': 'Cardinals',
|
||||
'Tampa Bay Rays': 'Rays',
|
||||
'Texas Rangers': 'Rangers',
|
||||
'Toronto Blue Jays': 'Blue Jays',
|
||||
'Washington Nationals': 'Nationals',
|
||||
}
|
||||
|
||||
|
||||
def normalize_franchise(franchise: str) -> str:
|
||||
"""Convert city+team name to team-only (e.g., 'Oakland Athletics' -> 'Athletics')"""
|
||||
titled = franchise.title()
|
||||
return FRANCHISE_NORMALIZE.get(titled, titled)
|
||||
|
||||
|
||||
SHEETS_AUTH = pygsheets.authorize(service_file='storage/paper-dynasty-service-creds.json', retries=1)
|
||||
|
||||
|
||||
@ -1623,7 +1667,7 @@ async def v1_players_put(players: PlayerModel, token: str = Depends(oauth2_schem
|
||||
'image': x.image,
|
||||
'image2': x.image2,
|
||||
'mlbclub': x.mlbclub.title(),
|
||||
'franchise': x.franchise.title(),
|
||||
'franchise': normalize_franchise(x.franchise),
|
||||
'cardset_id': x.cardset_id,
|
||||
'rarity_id': x.rarity_id,
|
||||
'set_num': x.set_num,
|
||||
@ -5109,7 +5153,7 @@ async def v1_stl_fix(token: str = Depends(oauth2_scheme)):
|
||||
detail='You are not authorized to post. This event has been logged.'
|
||||
)
|
||||
|
||||
p_query = Player.update(mlbclub='St Louis Cardinals', franchise='St Louis Cardinals').where(
|
||||
p_query = Player.update(mlbclub='St Louis Cardinals', franchise='Cardinals').where(
|
||||
Player.mlbclub == 'St. Louis Cardinals'
|
||||
).execute()
|
||||
db.close()
|
||||
|
||||
104
migrations/2026-01-07_normalize_franchise.sql
Normal file
104
migrations/2026-01-07_normalize_franchise.sql
Normal file
@ -0,0 +1,104 @@
|
||||
-- Migration: Normalize Player.franchise to city-agnostic values
|
||||
-- Date: 2026-01-07
|
||||
-- Purpose: Enable cross-era player matching for AI rosters by normalizing
|
||||
-- franchise values to match Team.sname (e.g., 'Oakland Athletics' -> 'Athletics')
|
||||
--
|
||||
-- IMPORTANT: Backup database before running!
|
||||
-- Run on dev first, verify with: SELECT DISTINCT franchise FROM player ORDER BY franchise;
|
||||
-- Then run on prod.
|
||||
--
|
||||
-- Rollback: See inverse statements at bottom of file
|
||||
|
||||
-- ============================================
|
||||
-- FORWARD MIGRATION: Normalize franchise values
|
||||
-- ============================================
|
||||
|
||||
-- National League West
|
||||
UPDATE player SET franchise = 'Diamondbacks' WHERE franchise = 'Arizona Diamondbacks';
|
||||
UPDATE player SET franchise = 'Rockies' WHERE franchise = 'Colorado Rockies';
|
||||
UPDATE player SET franchise = 'Dodgers' WHERE franchise = 'Los Angeles Dodgers';
|
||||
UPDATE player SET franchise = 'Padres' WHERE franchise = 'San Diego Padres';
|
||||
UPDATE player SET franchise = 'Giants' WHERE franchise = 'San Francisco Giants';
|
||||
|
||||
-- National League Central
|
||||
UPDATE player SET franchise = 'Cubs' WHERE franchise = 'Chicago Cubs';
|
||||
UPDATE player SET franchise = 'Reds' WHERE franchise = 'Cincinnati Reds';
|
||||
UPDATE player SET franchise = 'Brewers' WHERE franchise = 'Milwaukee Brewers';
|
||||
UPDATE player SET franchise = 'Pirates' WHERE franchise = 'Pittsburgh Pirates';
|
||||
UPDATE player SET franchise = 'Cardinals' WHERE franchise IN ('St Louis Cardinals', 'St. Louis Cardinals');
|
||||
|
||||
-- National League East
|
||||
UPDATE player SET franchise = 'Braves' WHERE franchise = 'Atlanta Braves';
|
||||
UPDATE player SET franchise = 'Marlins' WHERE franchise = 'Miami Marlins';
|
||||
UPDATE player SET franchise = 'Mets' WHERE franchise = 'New York Mets';
|
||||
UPDATE player SET franchise = 'Phillies' WHERE franchise = 'Philadelphia Phillies';
|
||||
UPDATE player SET franchise = 'Nationals' WHERE franchise = 'Washington Nationals';
|
||||
|
||||
-- American League West
|
||||
UPDATE player SET franchise = 'Astros' WHERE franchise = 'Houston Astros';
|
||||
UPDATE player SET franchise = 'Angels' WHERE franchise = 'Los Angeles Angels';
|
||||
UPDATE player SET franchise = 'Athletics' WHERE franchise = 'Oakland Athletics';
|
||||
UPDATE player SET franchise = 'Mariners' WHERE franchise = 'Seattle Mariners';
|
||||
UPDATE player SET franchise = 'Rangers' WHERE franchise = 'Texas Rangers';
|
||||
|
||||
-- American League Central
|
||||
UPDATE player SET franchise = 'White Sox' WHERE franchise = 'Chicago White Sox';
|
||||
UPDATE player SET franchise = 'Guardians' WHERE franchise = 'Cleveland Guardians';
|
||||
UPDATE player SET franchise = 'Tigers' WHERE franchise = 'Detroit Tigers';
|
||||
UPDATE player SET franchise = 'Royals' WHERE franchise = 'Kansas City Royals';
|
||||
UPDATE player SET franchise = 'Twins' WHERE franchise = 'Minnesota Twins';
|
||||
|
||||
-- American League East
|
||||
UPDATE player SET franchise = 'Orioles' WHERE franchise = 'Baltimore Orioles';
|
||||
UPDATE player SET franchise = 'Red Sox' WHERE franchise = 'Boston Red Sox';
|
||||
UPDATE player SET franchise = 'Yankees' WHERE franchise = 'New York Yankees';
|
||||
UPDATE player SET franchise = 'Rays' WHERE franchise = 'Tampa Bay Rays';
|
||||
UPDATE player SET franchise = 'Blue Jays' WHERE franchise = 'Toronto Blue Jays';
|
||||
|
||||
-- ============================================
|
||||
-- VERIFICATION QUERY
|
||||
-- ============================================
|
||||
-- Run after migration to verify all 30 teams have correct values:
|
||||
-- SELECT DISTINCT franchise FROM player ORDER BY franchise;
|
||||
--
|
||||
-- Expected output (30 city-agnostic franchise names):
|
||||
-- Angels, Athletics, Blue Jays, Braves, Brewers, Cardinals, Cubs,
|
||||
-- Diamondbacks, Dodgers, Giants, Guardians, Mariners, Marlins, Mets,
|
||||
-- Nationals, Orioles, Padres, Phillies, Pirates, Rangers, Rays,
|
||||
-- Red Sox, Reds, Rockies, Royals, Tigers, Twins, White Sox, Yankees
|
||||
|
||||
-- ============================================
|
||||
-- ROLLBACK MIGRATION (if needed)
|
||||
-- ============================================
|
||||
-- Use these statements to revert to original values:
|
||||
--
|
||||
-- UPDATE player SET franchise = 'Arizona Diamondbacks' WHERE franchise = 'Diamondbacks' AND mlbclub LIKE '%Arizona%';
|
||||
-- UPDATE player SET franchise = 'Atlanta Braves' WHERE franchise = 'Braves' AND mlbclub LIKE '%Atlanta%';
|
||||
-- UPDATE player SET franchise = 'Baltimore Orioles' WHERE franchise = 'Orioles' AND mlbclub LIKE '%Baltimore%';
|
||||
-- UPDATE player SET franchise = 'Boston Red Sox' WHERE franchise = 'Red Sox' AND mlbclub LIKE '%Boston%';
|
||||
-- UPDATE player SET franchise = 'Chicago Cubs' WHERE franchise = 'Cubs' AND mlbclub LIKE '%Chicago%';
|
||||
-- UPDATE player SET franchise = 'Chicago White Sox' WHERE franchise = 'White Sox' AND mlbclub LIKE '%Chicago%';
|
||||
-- UPDATE player SET franchise = 'Cincinnati Reds' WHERE franchise = 'Reds' AND mlbclub LIKE '%Cincinnati%';
|
||||
-- UPDATE player SET franchise = 'Cleveland Guardians' WHERE franchise = 'Guardians' AND mlbclub LIKE '%Cleveland%';
|
||||
-- UPDATE player SET franchise = 'Colorado Rockies' WHERE franchise = 'Rockies' AND mlbclub LIKE '%Colorado%';
|
||||
-- UPDATE player SET franchise = 'Detroit Tigers' WHERE franchise = 'Tigers' AND mlbclub LIKE '%Detroit%';
|
||||
-- UPDATE player SET franchise = 'Houston Astros' WHERE franchise = 'Astros' AND mlbclub LIKE '%Houston%';
|
||||
-- UPDATE player SET franchise = 'Kansas City Royals' WHERE franchise = 'Royals' AND mlbclub LIKE '%Kansas%';
|
||||
-- UPDATE player SET franchise = 'Los Angeles Angels' WHERE franchise = 'Angels' AND mlbclub LIKE '%Los Angeles%' AND mlbclub NOT LIKE '%Dodgers%';
|
||||
-- UPDATE player SET franchise = 'Los Angeles Dodgers' WHERE franchise = 'Dodgers' AND mlbclub LIKE '%Los Angeles%';
|
||||
-- UPDATE player SET franchise = 'Miami Marlins' WHERE franchise = 'Marlins' AND mlbclub LIKE '%Miami%';
|
||||
-- UPDATE player SET franchise = 'Milwaukee Brewers' WHERE franchise = 'Brewers' AND mlbclub LIKE '%Milwaukee%';
|
||||
-- UPDATE player SET franchise = 'Minnesota Twins' WHERE franchise = 'Twins' AND mlbclub LIKE '%Minnesota%';
|
||||
-- UPDATE player SET franchise = 'New York Mets' WHERE franchise = 'Mets' AND mlbclub LIKE '%New York%';
|
||||
-- UPDATE player SET franchise = 'New York Yankees' WHERE franchise = 'Yankees' AND mlbclub LIKE '%New York%';
|
||||
-- UPDATE player SET franchise = 'Oakland Athletics' WHERE franchise = 'Athletics' AND mlbclub LIKE '%Oakland%';
|
||||
-- UPDATE player SET franchise = 'Philadelphia Phillies' WHERE franchise = 'Phillies' AND mlbclub LIKE '%Philadelphia%';
|
||||
-- UPDATE player SET franchise = 'Pittsburgh Pirates' WHERE franchise = 'Pirates' AND mlbclub LIKE '%Pittsburgh%';
|
||||
-- UPDATE player SET franchise = 'San Diego Padres' WHERE franchise = 'Padres' AND mlbclub LIKE '%San Diego%';
|
||||
-- UPDATE player SET franchise = 'San Francisco Giants' WHERE franchise = 'Giants' AND mlbclub LIKE '%San Francisco%';
|
||||
-- UPDATE player SET franchise = 'Seattle Mariners' WHERE franchise = 'Mariners' AND mlbclub LIKE '%Seattle%';
|
||||
-- UPDATE player SET franchise = 'St Louis Cardinals' WHERE franchise = 'Cardinals' AND mlbclub LIKE '%St%Louis%';
|
||||
-- UPDATE player SET franchise = 'Tampa Bay Rays' WHERE franchise = 'Rays' AND mlbclub LIKE '%Tampa%';
|
||||
-- UPDATE player SET franchise = 'Texas Rangers' WHERE franchise = 'Rangers' AND mlbclub LIKE '%Texas%';
|
||||
-- UPDATE player SET franchise = 'Toronto Blue Jays' WHERE franchise = 'Blue Jays' AND mlbclub LIKE '%Toronto%';
|
||||
-- UPDATE player SET franchise = 'Washington Nationals' WHERE franchise = 'Nationals' AND mlbclub LIKE '%Washington%';
|
||||
@ -4,6 +4,7 @@ uvicorn
|
||||
peewee
|
||||
psycopg2-binary # PostgreSQL adapter for Python
|
||||
python-multipart
|
||||
numpy<2
|
||||
pandas
|
||||
pygsheets
|
||||
pybaseball
|
||||
|
||||
Loading…
Reference in New Issue
Block a user