e2412789c190_initialize_models.py 1.7 KB

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