476b167aef80_initial_migration.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. """initial_migration
  2. Revision ID: 476b167aef80
  3. Revises:
  4. Create Date: 2019-01-03 17:03:37.684091
  5. """
  6. from alembic import op
  7. import sqlalchemy as sa
  8. # revision identifiers, used by Alembic.
  9. revision = '476b167aef80'
  10. down_revision = None
  11. branch_labels = None
  12. depends_on = None
  13. def upgrade():
  14. op.create_table('user',
  15. sa.Column('id', sa.Integer(), nullable=False),
  16. sa.Column('name', sa.String(), nullable=False),
  17. sa.Column('email', sa.String(length=255), nullable=True),
  18. sa.Column('password', sa.String(length=255), nullable=True),
  19. sa.Column('registration_at', sa.DateTime(), nullable=True),
  20. sa.PrimaryKeyConstraint('id'),
  21. sa.UniqueConstraint('email'),
  22. sa.UniqueConstraint('name')
  23. )
  24. op.create_table('page',
  25. sa.Column('id', sa.Integer(), nullable=False),
  26. sa.Column('title', sa.String(), nullable=False),
  27. sa.Column('datetime', sa.DateTime(), nullable=True),
  28. sa.Column('source', sa.String(), nullable=True),
  29. sa.Column('user_id', sa.Integer(), nullable=True),
  30. sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
  31. sa.PrimaryKeyConstraint('id')
  32. )
  33. def downgrade():
  34. op.drop_table('page')
  35. op.drop_table('user')