|
2 | 2 |
|
3 | 3 | Revision ID: e2412789c190 |
4 | 4 | Revises: |
5 | | -Create Date: 2023-11-24 22:55:43.195942 |
| 5 | +Create Date: 2026-02-18 15:03:00.000000 |
6 | 6 |
|
7 | 7 | """ |
8 | | -import sqlalchemy as sa |
9 | | -import sqlmodel.sql.sqltypes |
10 | 8 | from alembic import op |
| 9 | +from sqlalchemy.dialects import postgresql |
| 10 | +import sqlalchemy as sa |
| 11 | + |
11 | 12 |
|
12 | 13 | # revision identifiers, used by Alembic. |
13 | 14 | revision = "e2412789c190" |
|
16 | 17 | depends_on = None |
17 | 18 |
|
18 | 19 |
|
19 | | -def upgrade(): |
20 | | - # ### commands auto generated by Alembic - please adjust! ### |
| 20 | +def upgrade() -> None: |
| 21 | + op.execute('CREATE EXTENSION IF NOT EXISTS "uuid-ossp"') |
21 | 22 | op.create_table( |
22 | 23 | "user", |
23 | | - sa.Column("email", sqlmodel.sql.sqltypes.AutoString(), nullable=False), |
| 24 | + sa.Column("email", sa.String(length=255), nullable=False), |
24 | 25 | sa.Column("is_active", sa.Boolean(), nullable=False), |
25 | 26 | sa.Column("is_superuser", sa.Boolean(), nullable=False), |
26 | | - sa.Column("full_name", sqlmodel.sql.sqltypes.AutoString(), nullable=True), |
27 | | - sa.Column("id", sa.Integer(), nullable=False), |
| 27 | + sa.Column("full_name", sa.String(length=255), nullable=True), |
28 | 28 | sa.Column( |
29 | | - "hashed_password", sqlmodel.sql.sqltypes.AutoString(), nullable=False |
| 29 | + "id", |
| 30 | + postgresql.UUID(as_uuid=True), |
| 31 | + server_default=sa.text("uuid_generate_v4()"), |
| 32 | + nullable=False, |
30 | 33 | ), |
| 34 | + sa.Column("hashed_password", sa.String(), nullable=False), |
| 35 | + sa.Column("created_at", sa.DateTime(timezone=True), nullable=True), |
31 | 36 | sa.PrimaryKeyConstraint("id"), |
32 | 37 | ) |
33 | 38 | op.create_index(op.f("ix_user_email"), "user", ["email"], unique=True) |
| 39 | + |
34 | 40 | op.create_table( |
35 | 41 | "item", |
36 | | - sa.Column("description", sqlmodel.sql.sqltypes.AutoString(), nullable=True), |
37 | | - sa.Column("id", sa.Integer(), nullable=False), |
38 | | - sa.Column("title", sqlmodel.sql.sqltypes.AutoString(), nullable=False), |
39 | | - sa.Column("owner_id", sa.Integer(), nullable=False), |
40 | | - sa.ForeignKeyConstraint( |
41 | | - ["owner_id"], |
42 | | - ["user.id"], |
| 42 | + sa.Column("description", sa.String(length=255), nullable=True), |
| 43 | + sa.Column( |
| 44 | + "id", |
| 45 | + postgresql.UUID(as_uuid=True), |
| 46 | + server_default=sa.text("uuid_generate_v4()"), |
| 47 | + nullable=False, |
43 | 48 | ), |
| 49 | + sa.Column("title", sa.String(length=255), nullable=False), |
| 50 | + sa.Column("created_at", sa.DateTime(timezone=True), nullable=True), |
| 51 | + sa.Column("owner_id", postgresql.UUID(as_uuid=True), nullable=False), |
| 52 | + sa.ForeignKeyConstraint(["owner_id"], ["user.id"], ondelete="CASCADE"), |
44 | 53 | sa.PrimaryKeyConstraint("id"), |
45 | 54 | ) |
46 | | - # ### end Alembic commands ### |
47 | 55 |
|
48 | 56 |
|
49 | | -def downgrade(): |
50 | | - # ### commands auto generated by Alembic - please adjust! ### |
| 57 | +def downgrade() -> None: |
51 | 58 | op.drop_table("item") |
52 | 59 | op.drop_index(op.f("ix_user_email"), table_name="user") |
53 | 60 | op.drop_table("user") |
54 | | - # ### end Alembic commands ### |
|
0 commit comments