diff --git a/rust/src/api/sync.rs b/rust/src/api/sync.rs index 9230e29..402cf1d 100644 --- a/rust/src/api/sync.rs +++ b/rust/src/api/sync.rs @@ -185,7 +185,6 @@ pub async fn sync_transactions( continue; }; - let move_id_str = move_id.to_string(); let player_id = player.id; // Schema has from_team_id/to_team_id as NOT NULL; use 0 as sentinel for missing teams let from_team_id = data.oldteam.map(|t| t.id).unwrap_or(0); @@ -206,7 +205,7 @@ pub async fn sync_transactions( ) .bind(season) .bind(week) - .bind(move_id_str) + .bind(&move_id) .bind(player_id) .bind(from_team_id) .bind(to_team_id) diff --git a/rust/src/api/types.rs b/rust/src/api/types.rs index ac86422..ab62a23 100644 --- a/rust/src/api/types.rs +++ b/rust/src/api/types.rs @@ -147,9 +147,9 @@ pub struct TransactionsResponse { #[derive(Debug, Deserialize)] pub struct TransactionData { - /// Transaction move ID — API field is "moveid". + /// Transaction move ID — API field is "moveid" (string like "Season-013-Week-11-1772073335"). #[serde(rename = "moveid", default)] - pub move_id: Option, + pub move_id: Option, #[serde(default)] pub week: Option, #[serde(default)] diff --git a/rust/src/db/schema.rs b/rust/src/db/schema.rs index a37164f..7759dab 100644 --- a/rust/src/db/schema.rs +++ b/rust/src/db/schema.rs @@ -7,7 +7,8 @@ pub async fn init_pool(db_path: &Path) -> Result { let db_url = format!("sqlite://{}?mode=rwc", db_path.display()); let options = SqliteConnectOptions::from_str(&db_url)? .create_if_missing(true) - .journal_mode(sqlx::sqlite::SqliteJournalMode::Wal); + .journal_mode(sqlx::sqlite::SqliteJournalMode::Wal) + .foreign_keys(false); let pool = SqlitePoolOptions::new() .max_connections(5) @@ -18,10 +19,6 @@ pub async fn init_pool(db_path: &Path) -> Result { } pub async fn create_tables(pool: &SqlitePool) -> Result<()> { - sqlx::query("PRAGMA foreign_keys = ON") - .execute(pool) - .await?; - // 1. teams — API-provided PKs (no autoincrement) sqlx::query( "CREATE TABLE IF NOT EXISTS teams ( @@ -175,9 +172,9 @@ pub async fn create_tables(pool: &SqlitePool) -> Result<()> { season INTEGER NOT NULL, week INTEGER NOT NULL, move_id TEXT NOT NULL, - player_id INTEGER NOT NULL REFERENCES players(id), - from_team_id INTEGER NOT NULL REFERENCES teams(id), - to_team_id INTEGER NOT NULL REFERENCES teams(id), + player_id INTEGER NOT NULL, + from_team_id INTEGER NOT NULL, + to_team_id INTEGER NOT NULL, cancelled INTEGER DEFAULT 0, frozen INTEGER DEFAULT 0, synced_at TEXT,