Premier League Predictor: Django & MySQL — Chapter 2, Exercise 3 ==================================================== TASK Run makemigrations and migrate against a real MySQL 8.0.16+ database yourself, then confirm in a MySQL client (e.g. SHOW CREATE TABLE predictor_fixture;) that the CHECK constraint genuinely appears in the generated table definition. SOLUTION Steps to complete this exercise: 1. Confirm the local MySQL server is genuinely 8.0.16 or later: SELECT VERSION(); 2. From the project root, with predictor/models.py exactly as written in this chapter: python manage.py makemigrations predictor This should generate a new migration file (something like predictor/migrations/0001_initial.py) describing all five models, including the CheckConstraint on Fixture. 3. Apply it against the real pl_predictor database: python manage.py migrate 4. Connect to the database directly with a MySQL client and inspect the generated table: USE pl_predictor; SHOW CREATE TABLE predictor_fixture; 5. Confirm the output includes a real CONSTRAINT clause referencing home_team_id and away_team_id — something structurally equivalent to: CONSTRAINT `ck_fixture_teams_differ` CHECK ((`home_team_id` <> `away_team_id`)) confirming Django's own CheckConstraint definition genuinely compiled down to a real MySQL CHECK clause in the actual table schema, not just something Django tracks internally in its own migration history. One-sentence confirmation: SHOW CREATE TABLE shows the real CHECK constraint present in MySQL's own table definition, confirming the Django model-level constraint was actually translated into and stored as genuine database-level enforcement, given the server is running 8.0.16 or later. WHY THIS WORKS AS AN ANSWER ---------------------------- It walks through the real commands needed to generate and apply the migration, then verifies the result the correct way — by inspecting the database's own real table definition directly with SHOW CREATE TABLE, rather than just trusting that the Django model code implies the constraint actually exists in the database.