app-MAIL-temp/migrations/versions/2020_032009_f4b8232fa17e_.py

57 lines
1.7 KiB
Python
Raw Normal View History

"""empty message
Revision ID: f4b8232fa17e
Revises: 0809266d08ca
Create Date: 2020-03-20 09:41:21.840221
"""
import sqlalchemy_utils
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "f4b8232fa17e"
down_revision = "0809266d08ca"
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column("contact", sa.Column("user_id", sa.Integer(), nullable=True))
op.create_foreign_key(
None, "contact", "users", ["user_id"], ["id"], ondelete="cascade"
)
op.add_column("email_log", sa.Column("user_id", sa.Integer(), nullable=True))
op.create_foreign_key(
None, "email_log", "users", ["user_id"], ["id"], ondelete="cascade"
)
op.add_column("file", sa.Column("user_id", sa.Integer(), nullable=True))
op.create_foreign_key(
None, "file", "users", ["user_id"], ["id"], ondelete="cascade"
)
op.drop_column("users", "can_use_pgp")
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column(
"users",
sa.Column(
"can_use_pgp",
sa.BOOLEAN(),
server_default=sa.text("false"),
autoincrement=False,
nullable=False,
),
)
op.drop_constraint(None, "file", type_="foreignkey")
op.drop_column("file", "user_id")
op.drop_constraint(None, "email_log", type_="foreignkey")
op.drop_column("email_log", "user_id")
op.drop_constraint(None, "contact", type_="foreignkey")
op.drop_column("contact", "user_id")
# ### end Alembic commands ###