Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

manager.alter_column: changing on_delete doesn't seem to work #1155

Open
Jacky56 opened this issue Feb 17, 2025 · 1 comment
Open

manager.alter_column: changing on_delete doesn't seem to work #1155

Jacky56 opened this issue Feb 17, 2025 · 1 comment

Comments

@Jacky56
Copy link

Jacky56 commented Feb 17, 2025

Assume you have the scenario of changing the existing on delete cascade behaviour:

class Post(Table):
    multimedia = ForeignKey(Multimedia, null=True, on_delete=OnDelete.set_null)

which then perform the auto migration to generates the code below:

async def forwards():
    manager = MigrationManager(
        migration_id=ID, app_name="post", description=DESCRIPTION
    )
    manager.alter_column(
        table_class_name="Post",
        tablename="post",
        column_name="multimedia",
        db_column_name="multimedia",
        params={"on_delete": OnDelete.set_null},
        old_params={"on_delete": OnDelete.cascade},
        column_class=ForeignKey,
        old_column_class=ForeignKey,
        schema=None,
    )
    return manager

The migration ran successfully but my FK cascade behaviour did not change

CockroachDB version: Basic, Google Cloud v24.3.4
Piccolo version: piccolo==1.21.0

@dantownsend
Copy link
Member

Yes, you're right - I've noticed this too. The migrations don't detect this change at the moment, I need to fix it.

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

No branches or pull requests

2 participants