Files
kami_apple_exchage/backend/alembic/versions/add_links_table.py
danial e141a2ba3f Refactor test files for consistency and readability
- Consolidated multi-line statements into single lines for improved readability in `conftest.py`, `test_distributed_lock.py`, `run_tests.py`, `test_all_apis.py`, `test_gift_card_api.py`, `test_user_data_api.py`, `unit/test_gift_card_api.py`, `unit/test_links_api.py`, `unit/test_opentelemetry.py`, `unit/test_orders_api.py`, and `unit/test_user_data_api.py`.
- Updated import statements to reflect changes in service names and paths in `test_distributed_lock.py` and `test_opentelemetry.py`.
- Enhanced test descriptions and assertions for clarity in various test files.
- Ensured consistent formatting of dictionaries and lists across test files.
2025-09-08 19:57:10 +08:00

43 lines
1.2 KiB
Python

"""Add links table
Revision ID: add_links_table
Revises:
Create Date: 2025-01-27 16:00:00.000000
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "add_links_table"
down_revision = None
branch_labels = None
depends_on = None
def upgrade() -> None:
# Create links table if it doesn't exist
op.create_table(
"links",
sa.Column("id", sa.String(length=32), nullable=False, comment="主键ID"),
sa.Column("created_at", sa.DateTime(), nullable=False, comment="创建时间"),
sa.Column("updated_at", sa.DateTime(), nullable=False, comment="更新时间"),
sa.Column("url", sa.String(length=255), nullable=False),
sa.Column("amount", sa.Float(), nullable=False),
sa.PrimaryKeyConstraint("id"),
)
# Create index on url for faster lookups
op.create_index("ix_links_url", "links", ["url"])
# Create index on amount for range queries
op.create_index("ix_links_amount", "links", ["amount"])
def downgrade() -> None:
op.drop_index("ix_links_amount", table_name="links")
op.drop_index("ix_links_url", table_name="links")
op.drop_table("links")