Skip to content

[WIP] Revert initial migration file to resolve deployment error - #187

Closed
gaidheal1 with Copilot wants to merge 1 commit into
stagingfrom
copilot/revert-initial-migration-file
Closed

[WIP] Revert initial migration file to resolve deployment error#187
gaidheal1 with Copilot wants to merge 1 commit into
stagingfrom
copilot/revert-initial-migration-file

Conversation

Copilot AI commented Jan 21, 2026

Copy link
Copy Markdown
Contributor

Thanks for asking me to work on this. I will get started on it and keep this PR's description up to date as I form a plan and make progress.

Original prompt

Problem

The deployment to Heroku is failing with this error:

django.db.migrations.exceptions.InconsistentMigrationHistory: Migration events.0001_initial is applied before its dependency users.0036_rename_profile_to_player on database 'default'.

This happened because events/migrations/0001_initial.py was edited after it had already been applied to the staging database. The file was changed to reference users.0036_rename_profile_to_player and users.player, but the version that was originally applied to the database referenced the old Profile model.

Solution

  1. Revert events/migrations/0001_initial.py to its original state:

    • Change dependency from ("users", "0036_rename_profile_to_player") to ("users", "0035_profile_onboarding_completed")
    • Change the EventContribution field name from player to profile
    • Change the foreign key reference from to="users.player" to to="users.profile"
  2. Create a new migration events/migrations/0002_rename_profile_to_player.py that:

    • Depends on events.0001_initial and users.0036_rename_profile_to_player
    • Renames the profile field to player in the EventContribution model
    • Updates the foreign key to point to users.Player

This approach preserves the migration history and allows the database to migrate cleanly without conflicts.

Files to Modify

events/migrations/0001_initial.py

Change line 12 from:

("users", "0036_rename_profile_to_player"),

to:

("users", "0035_profile_onboarding_completed"),

Change lines 111-116 from:

(
    "player",
    models.ForeignKey(
        on_delete=django.db.models.deletion.CASCADE,
        related_name="contribution",
        to="users.player",
    ),
),

to:

(
    "profile",
    models.ForeignKey(
        on_delete=django.db.models.deletion.CASCADE,
        related_name="contribution",
        to="users.profile",
    ),
),

Create events/migrations/0002_rename_profile_to_player.py

Create a new migration file with the following content:

# Generated migration to rename profile to player in events app

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("events", "0001_initial"),
        ("users", "0036_rename_profile_to_player"),
    ]

    operations = [
        migrations.RenameField(
            model_name="eventcontribution",
            old_name="profile",
            new_name="player",
        ),
        migrations.AlterField(
            model_name="eventcontribution",
            name="player",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name="contribution",
                to="users.player",
            ),
        ),
    ]

Expected Outcome

After merging this PR:

  • The migration history will be consistent with what's already in the database
  • Running python manage.py migrate on Heroku will apply the new 0002_rename_profile_to_player migration successfully
  • No more InconsistentMigrationHistory errors

This pull request was created from Copilot chat.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI requested a review from gaidheal1 January 21, 2026 17:55
Copilot stopped work on behalf of gaidheal1 due to an error January 21, 2026 17:55
@gaidheal1 gaidheal1 closed this Jan 21, 2026
@gaidheal1
gaidheal1 deleted the copilot/revert-initial-migration-file branch January 21, 2026 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants