|
| 1 | +"""Added Unidentified Item Table |
| 2 | +
|
| 3 | +Revision ID: 0f3f15f56b7d |
| 4 | +Revises: fa3b02812f53 |
| 5 | +Create Date: 2025-03-04 00:21:22.039605 |
| 6 | +
|
| 7 | +""" |
| 8 | + |
| 9 | +from typing import Sequence, Union |
| 10 | + |
| 11 | +from alembic import op |
| 12 | +import sqlalchemy as sa |
| 13 | +from sqlalchemy.dialects import postgresql |
| 14 | + |
| 15 | +# revision identifiers, used by Alembic. |
| 16 | +revision: str = "0f3f15f56b7d" |
| 17 | +down_revision: Union[str, None] = "fa3b02812f53" |
| 18 | +branch_labels: Union[str, Sequence[str], None] = None |
| 19 | +depends_on: Union[str, Sequence[str], None] = None |
| 20 | + |
| 21 | + |
| 22 | +def upgrade() -> None: |
| 23 | + # ### commands auto generated by Alembic - please adjust! ### |
| 24 | + op.create_table( |
| 25 | + "unidentified_item", |
| 26 | + sa.Column("name", sa.Text(), nullable=False), |
| 27 | + sa.Column("itemBaseTypeId", sa.SmallInteger(), nullable=False), |
| 28 | + sa.Column("createdHoursSinceLaunch", sa.SmallInteger(), nullable=False), |
| 29 | + sa.Column("league", sa.Text(), nullable=False), |
| 30 | + sa.Column( |
| 31 | + "itemId", |
| 32 | + sa.BigInteger(), |
| 33 | + sa.Identity(always=True, start=1, increment=1), |
| 34 | + nullable=False, |
| 35 | + ), |
| 36 | + sa.Column("currencyId", sa.Integer(), nullable=False), |
| 37 | + sa.Column("ilvl", sa.SmallInteger(), nullable=False), |
| 38 | + sa.Column("currencyAmount", sa.Float(precision=4), nullable=False), |
| 39 | + sa.Column("nItems", sa.SmallInteger(), nullable=False, default=1), |
| 40 | + sa.Column("identified", sa.Boolean(), nullable=False), |
| 41 | + sa.Column("rarity", sa.Text(), nullable=False), |
| 42 | + sa.Column("aggregated", sa.Boolean(), nullable=False, default=False), |
| 43 | + sa.CheckConstraint( |
| 44 | + "\n identified IS NOT TRUE\n ", |
| 45 | + name="identified_is_false", |
| 46 | + ), |
| 47 | + sa.ForeignKeyConstraint( |
| 48 | + ["currencyId"], ["currency.currencyId"], ondelete="RESTRICT" |
| 49 | + ), |
| 50 | + sa.ForeignKeyConstraint( |
| 51 | + ["itemBaseTypeId"], |
| 52 | + ["item_base_type.itemBaseTypeId"], |
| 53 | + onupdate="CASCADE", |
| 54 | + ondelete="RESTRICT", |
| 55 | + ), |
| 56 | + sa.PrimaryKeyConstraint("itemId"), |
| 57 | + ) |
| 58 | + op.create_index( |
| 59 | + "ix_unid_item_name_itemBaseTypeId_createdHoursSinceLaunch_league", |
| 60 | + "unidentified_item", |
| 61 | + ["name", "itemBaseTypeId", "createdHoursSinceLaunch", "league"], |
| 62 | + unique=False, |
| 63 | + ) |
| 64 | + op.create_index( |
| 65 | + op.f("ix_unidentified_item_currencyId"), |
| 66 | + "unidentified_item", |
| 67 | + ["currencyId"], |
| 68 | + unique=False, |
| 69 | + ) |
| 70 | + op.drop_index("item_createdHoursSinceLaunch_idx", table_name="item") |
| 71 | + op.create_foreign_key( |
| 72 | + None, |
| 73 | + "item", |
| 74 | + "item_base_type", |
| 75 | + ["itemBaseTypeId"], |
| 76 | + ["itemBaseTypeId"], |
| 77 | + onupdate="CASCADE", |
| 78 | + ondelete="RESTRICT", |
| 79 | + ) |
| 80 | + op.create_foreign_key( |
| 81 | + None, "item", "currency", ["currencyId"], ["currencyId"], ondelete="RESTRICT" |
| 82 | + ) |
| 83 | + op.drop_index( |
| 84 | + "item_modifier_createdHoursSinceLaunch_idx", table_name="item_modifier" |
| 85 | + ) |
| 86 | + op.create_foreign_key( |
| 87 | + None, |
| 88 | + "item_modifier", |
| 89 | + "modifier", |
| 90 | + ["modifierId"], |
| 91 | + ["modifierId"], |
| 92 | + onupdate="CASCADE", |
| 93 | + ondelete="CASCADE", |
| 94 | + ) |
| 95 | + # ### end Alembic commands ### |
| 96 | + |
| 97 | + |
| 98 | +def downgrade() -> None: |
| 99 | + # ### commands auto generated by Alembic - please adjust! ### |
| 100 | + op.drop_constraint(None, "item_modifier", type_="foreignkey") |
| 101 | + op.create_index( |
| 102 | + "item_modifier_createdHoursSinceLaunch_idx", |
| 103 | + "item_modifier", |
| 104 | + [sa.text('"createdHoursSinceLaunch" DESC')], |
| 105 | + unique=False, |
| 106 | + ) |
| 107 | + op.drop_constraint(None, "item", type_="foreignkey") |
| 108 | + op.drop_constraint(None, "item", type_="foreignkey") |
| 109 | + op.create_index( |
| 110 | + "item_createdHoursSinceLaunch_idx", |
| 111 | + "item", |
| 112 | + [sa.text('"createdHoursSinceLaunch" DESC')], |
| 113 | + unique=False, |
| 114 | + ) |
| 115 | + op.drop_index( |
| 116 | + op.f("ix_unidentified_item_currencyId"), table_name="unidentified_item" |
| 117 | + ) |
| 118 | + op.drop_index( |
| 119 | + "ix_unid_item_name_itemBaseTypeId_createdHoursSinceLaunch_league", |
| 120 | + table_name="unidentified_item", |
| 121 | + ) |
| 122 | + op.drop_table("unidentified_item") |
| 123 | + # ### end Alembic commands ### |
0 commit comments