-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
75 additions
and
2 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
alembic/versions/20231121_1856_df15f7cacf48_create_product_table.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
"""Create Product table | ||
Revision ID: aead2a83cfa8 | ||
Revises: 1c8431a64d3a | ||
Create Date: 2023-11-21 18:56:39.786743 | ||
""" | ||
from typing import Sequence, Union | ||
|
||
import sqlalchemy as sa | ||
|
||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = "df15f7cacf48" | ||
down_revision: Union[str, None] = "1c8431a64d3a" | ||
branch_labels: Union[str, Sequence[str], None] = None | ||
depends_on: Union[str, Sequence[str], None] = None | ||
|
||
|
||
def upgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.create_table( | ||
"products", | ||
sa.Column("id", sa.Integer(), nullable=False), | ||
sa.Column("code", sa.String(), nullable=True), | ||
sa.Column("off_source", sa.String(length=255), nullable=True), | ||
sa.Column("off_name", sa.String(), nullable=True), | ||
sa.Column("off_quantity", sa.Integer(), nullable=True), | ||
sa.Column("off_image_url", sa.String(), nullable=True), | ||
sa.Column( | ||
"created", | ||
sa.DateTime(timezone=True), | ||
server_default=sa.text("now()"), | ||
nullable=True, | ||
), | ||
sa.Column("updated", sa.DateTime(timezone=True), nullable=True), | ||
sa.PrimaryKeyConstraint("id"), | ||
) | ||
op.create_index(op.f("ix_products_id"), "products", ["id"], unique=False) | ||
op.create_index(op.f("ix_products_off_id"), "products", ["off_id"], unique=True) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_index(op.f("ix_products_off_id"), table_name="products") | ||
op.drop_index(op.f("ix_products_id"), table_name="products") | ||
op.drop_table("products") | ||
# ### end Alembic commands ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters