{
"event": "PreToolUse",
"tool_name": "Bash",
"tool_input": {
"command": "DB_PASSWORD=\"v8mFLmkF2fth_r\" .\/venv\/bin\/python -c \"\nfrom db import db\ndb.connect()\n\n# Check if FK constraint exists\ncursor = db.execute('''\n SELECT CONSTRAINT_NAME \n FROM information_schema.KEY_COLUMN_USAGE \n WHERE TABLE_NAME = \\\"content_critiques\\\" \n AND COLUMN_NAME = \\\"critic_id\\\" \n AND REFERENCED_TABLE_NAME IS NOT NULL\n''')\nfk = cursor.fetchone()\ncursor.close()\nprint(f'Existing FK constraint: {fk}')\n\n# Update critic_ids with mapping\nmapping = {1: 30, 2: 31, 3: 32, 4: 33}\nfor old_id, new_id in mapping.items():\n cursor = db.execute('UPDATE content_critiques SET critic_id = %s WHERE critic_id = %s', (new_id, old_id))\n db.commit()\n print(f'Updated critic_id {old_id} → {new_id}: {cursor.rowcount} rows')\n cursor.close()\n\n# Verify\ncursor = db.execute('SELECT critic_id, COUNT(*) as cnt FROM content_critiques GROUP BY critic_id')\nprint()\nprint('=== Nach Update ===')\nfor row in cursor.fetchall():\n print(f\\\" critic_id={row['critic_id']}: {row['cnt']} Einträge\\\")\ncursor.close()\n\ndb.disconnect()\n\"",
"description": "Update FK references in content_critiques"
}
}