def METHOD_NAME(self, Base, User, Team):
    class METHOD_NAME(Base):
        __tablename__ = 'team_member'
        user_id = sa.Column(
            sa.Integer,
            sa.ForeignKey(User.id, ondelete='CASCADE'),
            primary_key=True
        )
        team_id = sa.Column(
            sa.Integer,
            sa.ForeignKey(Team.id, ondelete='CASCADE'),
            primary_key=True
        )
        role = sa.Column(sa.Unicode(255))
        team = sa.orm.relationship(
            Team,
            backref=sa.orm.backref(
                'members',
                cascade='all, delete-orphan'
            ),
            primaryjoin=team_id == Team.id,
        )
        user = sa.orm.relationship(
            User,
            backref=sa.orm.backref(
                'memberships',
                cascade='all, delete-orphan'
            ),
            primaryjoin=user_id == User.id,
        )
    return METHOD_NAME