d4867f3a4c0a_first_revision.py 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. """First revision
  2. Revision ID: d4867f3a4c0a
  3. Revises:
  4. Create Date: 2019-04-17 13:53:32.978401
  5. """
  6. from alembic import op
  7. import sqlalchemy as sa
  8. # revision identifiers, used by Alembic.
  9. revision = "d4867f3a4c0a"
  10. down_revision = None
  11. branch_labels = None
  12. depends_on = None
  13. def upgrade():
  14. # ### commands auto generated by Alembic - please adjust! ###
  15. op.create_table(
  16. "user",
  17. sa.Column("id", sa.Integer(), nullable=False),
  18. sa.Column("full_name", sa.String(), nullable=True),
  19. sa.Column("email", sa.String(), nullable=True),
  20. sa.Column("hashed_password", sa.String(), nullable=True),
  21. sa.Column("is_active", sa.Boolean(), nullable=True),
  22. sa.Column("is_superuser", sa.Boolean(), nullable=True),
  23. sa.PrimaryKeyConstraint("id"),
  24. )
  25. op.create_index(op.f("ix_user_email"), "user", ["email"], unique=True)
  26. op.create_index(op.f("ix_user_full_name"), "user", ["full_name"], unique=False)
  27. op.create_index(op.f("ix_user_id"), "user", ["id"], unique=False)
  28. op.create_table(
  29. "item",
  30. sa.Column("id", sa.Integer(), nullable=False),
  31. sa.Column("title", sa.String(), nullable=True),
  32. sa.Column("description", sa.String(), nullable=True),
  33. sa.Column("owner_id", sa.Integer(), nullable=True),
  34. sa.ForeignKeyConstraint(["owner_id"], ["user.id"],),
  35. sa.PrimaryKeyConstraint("id"),
  36. )
  37. op.create_index(op.f("ix_item_description"), "item", ["description"], unique=False)
  38. op.create_index(op.f("ix_item_id"), "item", ["id"], unique=False)
  39. op.create_index(op.f("ix_item_title"), "item", ["title"], unique=False)
  40. # ### end Alembic commands ###
  41. def downgrade():
  42. # ### commands auto generated by Alembic - please adjust! ###
  43. op.drop_index(op.f("ix_item_title"), table_name="item")
  44. op.drop_index(op.f("ix_item_id"), table_name="item")
  45. op.drop_index(op.f("ix_item_description"), table_name="item")
  46. op.drop_table("item")
  47. op.drop_index(op.f("ix_user_id"), table_name="user")
  48. op.drop_index(op.f("ix_user_full_name"), table_name="user")
  49. op.drop_index(op.f("ix_user_email"), table_name="user")
  50. op.drop_table("user")
  51. # ### end Alembic commands ###