Skip to content

Commit

Permalink
new migration.
Browse files Browse the repository at this point in the history
  • Loading branch information
nimaafshar79 committed Jun 12, 2020
1 parent 85510f7 commit aea387e
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions migrations/versions/9d0a2766befe_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
"""empty message
Revision ID: 9d0a2766befe
Revises: 34508ec90fd5
Create Date: 2020-06-12 03:36:00.842824
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = '9d0a2766befe'
down_revision = '34508ec90fd5'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('diet_record',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('generated_at', sa.TIMESTAMP(), nullable=False),
sa.Column('owner_id', sa.Integer(), nullable=False),
sa.Column('diet', sa.JSON(), nullable=False),
sa.ForeignKeyConstraint(['owner_id'], ['users.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.alter_column('foods', 'author',
existing_type=sa.INTEGER(),
nullable=False,
existing_server_default=sa.text('1'))
op.alter_column('foods', 'created_at',
existing_type=postgresql.TIMESTAMP(),
nullable=True,
existing_server_default=sa.text("timezone('Asia/Tehran'::text, CURRENT_TIMESTAMP)"))
op.alter_column('posts', 'authorid',
existing_type=sa.INTEGER(),
nullable=False)
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column('posts', 'authorid',
existing_type=sa.INTEGER(),
nullable=True)
op.alter_column('foods', 'created_at',
existing_type=postgresql.TIMESTAMP(),
nullable=False,
existing_server_default=sa.text("timezone('Asia/Tehran'::text, CURRENT_TIMESTAMP)"))
op.alter_column('foods', 'author',
existing_type=sa.INTEGER(),
nullable=True,
existing_server_default=sa.text('1'))
op.drop_table('diet_record')
# ### end Alembic commands ###

0 comments on commit aea387e

Please sign in to comment.