
# revision identifiers, used by Alembic.
revision = '4fdf1059c4ba'
down_revision = '393a48ab5fc7'


from alembic import op
import sqlalchemy as sa


def upgrade():
    op.create_table('memberships',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('organization_id', sa.Integer(), nullable=True),
        sa.Column('user_id', sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(['organization_id'], ['organizations.id'], ),
        sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
        sa.PrimaryKeyConstraint('id')
    )


def downgrade():
    op.drop_table('memberships')


# revision identifiers, used by Alembic.
revision = '4fdf1059c4ba'
down_revision = '393a48ab5fc7'


from alembic import op
import sqlalchemy as sa


def upgrade():
    op.create_table('memberships',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('organization_id', sa.Integer(), nullable=True),
        sa.Column('user_id', sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(
            ['organization_id'], ['organizations.id'], ondelete='CASCADE'
        ),
        sa.ForeignKeyConstraint(
            ['user_id'], ['users.id'], ondelete='CASCADE'
        ),
        sa.PrimaryKeyConstraint('id')
    )


def downgrade():
    op.drop_table('memberships')

Fix memebership table creation migration
Fix memebership table creation migration

  
  # revision identifiers, used by Alembic.
  revision = '4fdf1059c4ba'
  down_revision = '393a48ab5fc7'
  
  
  from alembic import op
  import sqlalchemy as sa
  
  
  def upgrade():
      op.create_table('memberships',
          sa.Column('id', sa.Integer(), nullable=False),
          sa.Column('organization_id', sa.Integer(), nullable=True),
          sa.Column('user_id', sa.Integer(), nullable=True),
-         sa.ForeignKeyConstraint(['organization_id'], ['organizations.id'], ),
-         sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
+         sa.ForeignKeyConstraint(
+             ['organization_id'], ['organizations.id'], ondelete='CASCADE'
+         ),
+         sa.ForeignKeyConstraint(
+             ['user_id'], ['users.id'], ondelete='CASCADE'
+         ),
          sa.PrimaryKeyConstraint('id')
      )
  
  
  def downgrade():
      op.drop_table('memberships')
  
Fix memebership table creation migration
## Code Before:

# revision identifiers, used by Alembic.
revision = '4fdf1059c4ba'
down_revision = '393a48ab5fc7'


from alembic import op
import sqlalchemy as sa


def upgrade():
    op.create_table('memberships',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('organization_id', sa.Integer(), nullable=True),
        sa.Column('user_id', sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(['organization_id'], ['organizations.id'], ),
        sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
        sa.PrimaryKeyConstraint('id')
    )


def downgrade():
    op.drop_table('memberships')

## Instruction:
Fix memebership table creation migration
## Code After:

# revision identifiers, used by Alembic.
revision = '4fdf1059c4ba'
down_revision = '393a48ab5fc7'


from alembic import op
import sqlalchemy as sa


def upgrade():
    op.create_table('memberships',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('organization_id', sa.Integer(), nullable=True),
        sa.Column('user_id', sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(
            ['organization_id'], ['organizations.id'], ondelete='CASCADE'
        ),
        sa.ForeignKeyConstraint(
            ['user_id'], ['users.id'], ondelete='CASCADE'
        ),
        sa.PrimaryKeyConstraint('id')
    )


def downgrade():
    op.drop_table('memberships')
