Skip to content

Cascade user deletion in related rows of tables of this module #264

Description

@fenekku

Is your feature request related to a problem? Please describe.

Deleting a user should cascade to the related rows in the tables defined by this module.

Currently, attempting to delete a user marks the foreignkey as null but since nullable=False, an integrity error is raised and the transaction is aborted.

Describe the solution you'd like

Add a backref cascade in appropriate places so that related rows gets deleted nicely. Example:

from sqlalchemy.orm import backref

class RemoteAccount(db.Model, Timestamp):
    # ...
    user = db.relationship(User, backref=backref('remote_accounts', cascade="all,delete"))
    """SQLAlchemy relationship to user."""

Describe alternatives you've considered

I have to delete from the bottom up i.e. figure out all models keying into User and delete those... ugh

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions