parent
3df5f74ec3
commit
76cf02a1f0
3 changed files with 66 additions and 1 deletions
@ -0,0 +1,56 @@ |
||||
"""empty message |
||||
|
||||
Revision ID: 3f3046e1c83c |
||||
Revises: |
||||
Create Date: 2020-12-07 21:57:21.057956 |
||||
|
||||
""" |
||||
from alembic import op |
||||
import sqlalchemy as sa |
||||
|
||||
|
||||
# revision identifiers, used by Alembic. |
||||
revision = '3f3046e1c83c' |
||||
down_revision = None |
||||
branch_labels = None |
||||
depends_on = None |
||||
|
||||
|
||||
def upgrade(): |
||||
# ### commands auto generated by Alembic - please adjust! ### |
||||
with op.batch_alter_table('t_comments', schema=None) as batch_op: |
||||
batch_op.add_column(sa.Column('project_id', sa.Integer(), nullable=False, default=1)) |
||||
batch_op.create_unique_constraint(batch_op.f('uq_t_comments_content'), ['content']) |
||||
batch_op.create_foreign_key(batch_op.f('fk_t_comments_project_id_t_projects'), 't_projects', ['project_id'], ['id_project']) |
||||
|
||||
with op.batch_alter_table('t_email', schema=None) as batch_op: |
||||
batch_op.add_column(sa.Column('project_id', sa.Integer(), nullable=False, default=1)) |
||||
batch_op.create_unique_constraint(batch_op.f('uq_t_email_email'), ['email']) |
||||
batch_op.create_foreign_key(batch_op.f('fk_t_email_project_id_t_projects'), 't_projects', ['project_id'], ['id_project']) |
||||
|
||||
with op.batch_alter_table('t_location', schema=None) as batch_op: |
||||
batch_op.add_column(sa.Column('project_id', sa.Integer(), nullable=False, default=1)) |
||||
batch_op.create_unique_constraint(batch_op.f('uq_t_location_location'), ['location']) |
||||
batch_op.create_foreign_key(batch_op.f('fk_t_location_project_id_t_projects'), 't_projects', ['project_id'], ['id_project']) |
||||
|
||||
# ### end Alembic commands ### |
||||
|
||||
|
||||
def downgrade(): |
||||
# ### commands auto generated by Alembic - please adjust! ### |
||||
with op.batch_alter_table('t_location', schema=None) as batch_op: |
||||
batch_op.drop_constraint(batch_op.f('fk_t_location_project_id_t_projects'), type_='foreignkey') |
||||
batch_op.drop_constraint(batch_op.f('uq_t_location_location'), type_='unique') |
||||
batch_op.drop_column('project_id') |
||||
|
||||
with op.batch_alter_table('t_email', schema=None) as batch_op: |
||||
batch_op.drop_constraint(batch_op.f('fk_t_email_project_id_t_projects'), type_='foreignkey') |
||||
batch_op.drop_constraint(batch_op.f('uq_t_email_email'), type_='unique') |
||||
batch_op.drop_column('project_id') |
||||
|
||||
with op.batch_alter_table('t_comments', schema=None) as batch_op: |
||||
batch_op.drop_constraint(batch_op.f('fk_t_comments_project_id_t_projects'), type_='foreignkey') |
||||
batch_op.drop_constraint(batch_op.f('uq_t_comments_content'), type_='unique') |
||||
batch_op.drop_column('project_id') |
||||
|
||||
# ### end Alembic commands ### |
Loading…
Reference in new issue