|
| 1 | +"""Adds personal-access-token-table |
| 2 | +
|
| 3 | +Revision ID: f803a0c4343c |
| 4 | +Revises: 09311360f8b9 |
| 5 | +Create Date: 2022-11-23 13:50:24.978181 |
| 6 | +
|
| 7 | +""" |
| 8 | +from alembic import op |
| 9 | +import sqlalchemy as sa |
| 10 | +from sqlalchemy.dialects import postgresql |
| 11 | + |
| 12 | +# revision identifiers, used by Alembic. |
| 13 | +revision = "f803a0c4343c" |
| 14 | +down_revision = "09311360f8b9" |
| 15 | +branch_labels = None |
| 16 | +depends_on = None |
| 17 | + |
| 18 | + |
| 19 | +def upgrade(): |
| 20 | + # ### commands auto generated by Alembic - please adjust! ### |
| 21 | + op.create_table( |
| 22 | + "personal_access_token", |
| 23 | + sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False), |
| 24 | + sa.Column("project_id", postgresql.UUID(as_uuid=True), nullable=True), |
| 25 | + sa.Column("user_id", postgresql.UUID(as_uuid=True), nullable=True), |
| 26 | + sa.Column("name", sa.String(), nullable=True), |
| 27 | + sa.Column("scope", sa.String(), nullable=True), |
| 28 | + sa.Column("created_at", sa.DateTime(), nullable=True), |
| 29 | + sa.Column("expires_at", sa.DateTime(), nullable=True), |
| 30 | + sa.Column("last_used", sa.DateTime(), nullable=True), |
| 31 | + sa.Column("token", sa.String(), nullable=True), |
| 32 | + sa.ForeignKeyConstraint(["project_id"], ["project.id"], ondelete="CASCADE"), |
| 33 | + sa.ForeignKeyConstraint(["user_id"], ["user.id"], ondelete="CASCADE"), |
| 34 | + sa.PrimaryKeyConstraint("id"), |
| 35 | + ) |
| 36 | + op.create_index( |
| 37 | + op.f("ix_personal_access_token_project_id"), |
| 38 | + "personal_access_token", |
| 39 | + ["project_id"], |
| 40 | + unique=False, |
| 41 | + ) |
| 42 | + op.create_index( |
| 43 | + op.f("ix_personal_access_token_user_id"), |
| 44 | + "personal_access_token", |
| 45 | + ["user_id"], |
| 46 | + unique=False, |
| 47 | + ) |
| 48 | + # ### end Alembic commands ### |
| 49 | + |
| 50 | + |
| 51 | +def downgrade(): |
| 52 | + # ### commands auto generated by Alembic - please adjust! ### |
| 53 | + op.drop_index( |
| 54 | + op.f("ix_personal_access_token_user_id"), table_name="personal_access_token" |
| 55 | + ) |
| 56 | + op.drop_index( |
| 57 | + op.f("ix_personal_access_token_project_id"), table_name="personal_access_token" |
| 58 | + ) |
| 59 | + op.drop_table("personal_access_token") |
| 60 | + # ### end Alembic commands ### |
0 commit comments