Fix Alembic issue
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
"""Alembic environment configuration for pos service"""
|
||||
|
||||
import asyncio
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
from logging.config import fileConfig
|
||||
@@ -25,7 +24,7 @@ try:
|
||||
from shared.database.base import Base
|
||||
|
||||
# Import all models to ensure they are registered with Base.metadata
|
||||
from app.models import * # Import all models
|
||||
from app.models import * # noqa: F401, F403
|
||||
|
||||
except ImportError as e:
|
||||
print(f"Import error in migrations env.py: {e}")
|
||||
@@ -35,12 +34,19 @@ except ImportError as e:
|
||||
# this is the Alembic Config object
|
||||
config = context.config
|
||||
|
||||
# Set database URL from environment variables or settings
|
||||
# Try service-specific DATABASE_URL first, then fall back to generic
|
||||
database_url = os.getenv('POS_DATABASE_URL') or os.getenv('DATABASE_URL')
|
||||
# Determine service name from file path
|
||||
service_name = os.path.basename(os.path.dirname(os.path.dirname(__file__)))
|
||||
service_name_upper = service_name.upper().replace('-', '_')
|
||||
|
||||
# Set database URL from environment variables with multiple fallback strategies
|
||||
database_url = (
|
||||
os.getenv(f'{service_name_upper}_DATABASE_URL') or # Service-specific
|
||||
os.getenv('DATABASE_URL') # Generic fallback
|
||||
)
|
||||
|
||||
# If DATABASE_URL is not set, construct from individual components
|
||||
if not database_url:
|
||||
# Try generic PostgreSQL environment variables first
|
||||
postgres_host = os.getenv('POSTGRES_HOST')
|
||||
postgres_port = os.getenv('POSTGRES_PORT', '5432')
|
||||
postgres_db = os.getenv('POSTGRES_DB')
|
||||
@@ -50,11 +56,28 @@ if not database_url:
|
||||
if all([postgres_host, postgres_db, postgres_user, postgres_password]):
|
||||
database_url = f"postgresql+asyncpg://{postgres_user}:{postgres_password}@{postgres_host}:{postgres_port}/{postgres_db}"
|
||||
else:
|
||||
# Fallback to settings
|
||||
database_url = getattr(settings, 'DATABASE_URL', None)
|
||||
# Try service-specific environment variables
|
||||
db_host = os.getenv(f'{service_name_upper}_DB_HOST', f'{service_name}-db-service')
|
||||
db_port = os.getenv(f'{service_name_upper}_DB_PORT', '5432')
|
||||
db_name = os.getenv(f'{service_name_upper}_DB_NAME', f'{service_name.replace("-", "_")}_db')
|
||||
db_user = os.getenv(f'{service_name_upper}_DB_USER', f'{service_name.replace("-", "_")}_user')
|
||||
db_password = os.getenv(f'{service_name_upper}_DB_PASSWORD')
|
||||
|
||||
if database_url:
|
||||
config.set_main_option("sqlalchemy.url", database_url)
|
||||
if db_password:
|
||||
database_url = f"postgresql+asyncpg://{db_user}:{db_password}@{db_host}:{db_port}/{db_name}"
|
||||
else:
|
||||
# Final fallback: try to get from settings object
|
||||
try:
|
||||
database_url = getattr(settings, 'DATABASE_URL', None)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
if not database_url:
|
||||
error_msg = f"ERROR: No database URL configured for {service_name} service"
|
||||
print(error_msg)
|
||||
raise Exception(error_msg)
|
||||
|
||||
config.set_main_option("sqlalchemy.url", database_url)
|
||||
|
||||
# Interpret the config file for Python logging
|
||||
if config.config_file_name is not None:
|
||||
@@ -63,6 +86,7 @@ if config.config_file_name is not None:
|
||||
# Set target metadata
|
||||
target_metadata = Base.metadata
|
||||
|
||||
|
||||
def run_migrations_offline() -> None:
|
||||
"""Run migrations in 'offline' mode."""
|
||||
url = config.get_main_option("sqlalchemy.url")
|
||||
@@ -78,7 +102,9 @@ def run_migrations_offline() -> None:
|
||||
with context.begin_transaction():
|
||||
context.run_migrations()
|
||||
|
||||
|
||||
def do_run_migrations(connection: Connection) -> None:
|
||||
"""Execute migrations with the given connection."""
|
||||
context.configure(
|
||||
connection=connection,
|
||||
target_metadata=target_metadata,
|
||||
@@ -89,8 +115,9 @@ def do_run_migrations(connection: Connection) -> None:
|
||||
with context.begin_transaction():
|
||||
context.run_migrations()
|
||||
|
||||
|
||||
async def run_async_migrations() -> None:
|
||||
"""Run migrations in 'online' mode."""
|
||||
"""Run migrations in 'online' mode with async support."""
|
||||
connectable = async_engine_from_config(
|
||||
config.get_section(config.config_ini_section, {}),
|
||||
prefix="sqlalchemy.",
|
||||
@@ -102,10 +129,12 @@ async def run_async_migrations() -> None:
|
||||
|
||||
await connectable.dispose()
|
||||
|
||||
|
||||
def run_migrations_online() -> None:
|
||||
"""Run migrations in 'online' mode."""
|
||||
asyncio.run(run_async_migrations())
|
||||
|
||||
|
||||
if context.is_offline_mode():
|
||||
run_migrations_offline()
|
||||
else:
|
||||
|
||||
@@ -1,434 +0,0 @@
|
||||
"""Initial schema for POS service
|
||||
|
||||
Revision ID: 000001
|
||||
Revises:
|
||||
Create Date: 2025-09-30 18:00:00.0000
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '000001'
|
||||
down_revision = None
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# Create pos_configurations table
|
||||
op.create_table('pos_configurations',
|
||||
sa.Column('id', sa.UUID(), nullable=False),
|
||||
sa.Column('tenant_id', sa.UUID(), nullable=True),
|
||||
sa.Column('location_id', sa.String(100), nullable=False),
|
||||
sa.Column('city', sa.String(50), nullable=False),
|
||||
sa.Column('date', sa.DateTime(timezone=True), nullable=False),
|
||||
sa.Column('traffic_volume', sa.Integer(), nullable=True),
|
||||
sa.Column('congestion_level', sa.String(20), nullable=True),
|
||||
sa.Column('average_speed', sa.Float(), nullable=True),
|
||||
sa.Column('occupation_percentage', sa.Float(), nullable=True),
|
||||
sa.Column('load_percentage', sa.Float(), nullable=True),
|
||||
sa.Column('pedestrian_count', sa.Integer(), nullable=True),
|
||||
sa.Column('measurement_point_id', sa.String(100), nullable=True),
|
||||
sa.Column('measurement_point_name', sa.String(500), nullable=True),
|
||||
sa.Column('measurement_point_type', sa.String(50), nullable=True),
|
||||
sa.Column('latitude', sa.Float(), nullable=True),
|
||||
sa.Column('longitude', sa.Float(), nullable=True),
|
||||
sa.Column('district', sa.String(100), nullable=True),
|
||||
sa.Column('zone', sa.String(100), nullable=True),
|
||||
sa.Column('source', sa.String(50), nullable=False),
|
||||
sa.Column('data_quality_score', sa.Float(), nullable=True),
|
||||
sa.Column('is_synthetic', sa.Boolean(), nullable=True),
|
||||
sa.Column('has_pedestrian_inference', sa.Boolean(), nullable=True),
|
||||
sa.Column('city_specific_data', postgresql.JSON(astext_type=sa.Text()), nullable=True),
|
||||
sa.Column('raw_data', sa.Text(), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('timezone(\'utc\', now())'), nullable=True),
|
||||
sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('timezone(\'utc\', now())'), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index(op.f('ix_pos_configurations_tenant_id'), 'pos_configurations', ['tenant_id'], unique=False)
|
||||
op.create_index(op.f('ix_pos_configurations_location_id'), 'pos_configurations', ['location_id'], unique=False)
|
||||
op.create_index(op.f('ix_pos_configurations_city'), 'pos_configurations', ['city'], unique=False)
|
||||
op.create_index(op.f('ix_pos_configurations_date'), 'pos_configurations', ['date'], unique=False)
|
||||
op.create_index('idx_pos_location_date', 'pos_configurations', ['location_id', 'date'], unique=False)
|
||||
op.create_index('idx_pos_city_date', 'pos_configurations', ['city', 'date'], unique=False)
|
||||
op.create_index('idx_pos_tenant_date', 'pos_configurations', ['tenant_id', 'date'], unique=False)
|
||||
op.create_index('idx_pos_city_location', 'pos_configurations', ['city', 'location_id'], unique=False)
|
||||
op.create_index('idx_pos_measurement_point', 'pos_configurations', ['city', 'measurement_point_id'], unique=False)
|
||||
op.create_index('idx_pos_district_date', 'pos_configurations', ['city', 'district', 'date'], unique=False)
|
||||
op.create_index('idx_pos_training', 'pos_configurations', ['tenant_id', 'city', 'date', 'is_synthetic'], unique=False)
|
||||
op.create_index('idx_pos_quality', 'pos_configurations', ['city', 'data_quality_score', 'date'], unique=False)
|
||||
|
||||
# Create pos_transactions table
|
||||
op.create_table('pos_transactions',
|
||||
sa.Column('id', sa.UUID(), nullable=False),
|
||||
sa.Column('tenant_id', sa.UUID(), nullable=False),
|
||||
sa.Column('pos_config_id', sa.UUID(), nullable=False),
|
||||
sa.Column('external_transaction_id', sa.String(255), nullable=False),
|
||||
sa.Column('external_order_id', sa.String(255), nullable=True),
|
||||
sa.Column('pos_system', sa.String(50), nullable=False),
|
||||
sa.Column('transaction_type', sa.String(50), nullable=False),
|
||||
sa.Column('status', sa.String(50), nullable=False),
|
||||
sa.Column('subtotal', sa.Numeric(10, 2), nullable=False),
|
||||
sa.Column('tax_amount', sa.Numeric(10, 2), nullable=False),
|
||||
sa.Column('tip_amount', sa.Numeric(10, 2), nullable=False),
|
||||
sa.Column('discount_amount', sa.Numeric(10, 2), nullable=False),
|
||||
sa.Column('total_amount', sa.Numeric(10, 2), nullable=False),
|
||||
sa.Column('currency', sa.String(3), nullable=False),
|
||||
sa.Column('payment_method', sa.String(50), nullable=True),
|
||||
sa.Column('payment_status', sa.String(50), nullable=True),
|
||||
sa.Column('transaction_date', sa.DateTime(timezone=True), nullable=False),
|
||||
sa.Column('pos_created_at', sa.DateTime(timezone=True), nullable=False),
|
||||
sa.Column('pos_updated_at', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('location_id', sa.String(100), nullable=True),
|
||||
sa.Column('location_name', sa.String(255), nullable=True),
|
||||
sa.Column('staff_id', sa.String(100), nullable=True),
|
||||
sa.Column('staff_name', sa.String(255), nullable=True),
|
||||
sa.Column('customer_id', sa.String(100), nullable=True),
|
||||
sa.Column('customer_email', sa.String(255), nullable=True),
|
||||
sa.Column('customer_phone', sa.String(50), nullable=True),
|
||||
sa.Column('order_type', sa.String(50), nullable=True),
|
||||
sa.Column('table_number', sa.String(20), nullable=True),
|
||||
sa.Column('receipt_number', sa.String(100), nullable=True),
|
||||
sa.Column('is_synced_to_sales', sa.Boolean(), nullable=False),
|
||||
sa.Column('sales_record_id', sa.UUID(), nullable=True),
|
||||
sa.Column('sync_attempted_at', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('sync_completed_at', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('sync_error', sa.Text(), nullable=True),
|
||||
sa.Column('sync_retry_count', sa.Integer(), nullable=False),
|
||||
sa.Column('raw_data', postgresql.JSON(astext_type=sa.Text()), nullable=True),
|
||||
sa.Column('is_processed', sa.Boolean(), nullable=False),
|
||||
sa.Column('processing_error', sa.Text(), nullable=True),
|
||||
sa.Column('is_duplicate', sa.Boolean(), nullable=False),
|
||||
sa.Column('duplicate_of', sa.UUID(), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('timezone(\'utc\', now())'), nullable=True),
|
||||
sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('timezone(\'utc\', now())'), nullable=True),
|
||||
sa.ForeignKeyConstraint(['pos_config_id'], ['pos_configurations.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index(op.f('ix_pos_transactions_tenant_id'), 'pos_transactions', ['tenant_id'], unique=False)
|
||||
op.create_index(op.f('ix_pos_transactions_pos_config_id'), 'pos_transactions', ['pos_config_id'], unique=False)
|
||||
op.create_index(op.f('ix_pos_transactions_external_transaction_id'), 'pos_transactions', ['external_transaction_id'], unique=False)
|
||||
op.create_index(op.f('ix_pos_transactions_external_order_id'), 'pos_transactions', ['external_order_id'], unique=False)
|
||||
op.create_index(op.f('ix_pos_transactions_pos_system'), 'pos_transactions', ['pos_system'], unique=False)
|
||||
op.create_index(op.f('ix_pos_transactions_transaction_type'), 'pos_transactions', ['transaction_type'], unique=False)
|
||||
op.create_index(op.f('ix_pos_transactions_status'), 'pos_transactions', ['status'], unique=False)
|
||||
op.create_index(op.f('ix_pos_transactions_transaction_date'), 'pos_transactions', ['transaction_date'], unique=False)
|
||||
op.create_index(op.f('ix_pos_transactions_location_id'), 'pos_transactions', ['location_id'], unique=False)
|
||||
op.create_index(op.f('ix_pos_transactions_customer_id'), 'pos_transactions', ['customer_id'], unique=False)
|
||||
op.create_index(op.f('ix_pos_transactions_sales_record_id'), 'pos_transactions', ['sales_record_id'], unique=False)
|
||||
op.create_index(op.f('ix_pos_transactions_is_synced_to_sales'), 'pos_transactions', ['is_synced_to_sales'], unique=False)
|
||||
op.create_index(op.f('ix_pos_transactions_is_processed'), 'pos_transactions', ['is_processed'], unique=False)
|
||||
op.create_index(op.f('ix_pos_transactions_is_duplicate'), 'pos_transactions', ['is_duplicate'], unique=False)
|
||||
op.create_index(op.f('ix_pos_transactions_duplicate_of'), 'pos_transactions', ['duplicate_of'], unique=False)
|
||||
op.create_index('idx_pos_transaction_tenant_date', 'pos_transactions', ['tenant_id', 'transaction_date'], unique=False)
|
||||
op.create_index('idx_pos_transaction_external_id', 'pos_transactions', ['pos_system', 'external_transaction_id'], unique=False)
|
||||
op.create_index('idx_pos_transaction_sync_status', 'pos_transactions', ['is_synced_to_sales'], unique=False)
|
||||
op.create_index('idx_pos_transaction_processed', 'pos_transactions', ['is_processed'], unique=False)
|
||||
op.create_index('idx_pos_transaction_location', 'pos_transactions', ['location_id'], unique=False)
|
||||
op.create_index('idx_pos_transaction_customer', 'pos_transactions', ['customer_id'], unique=False)
|
||||
|
||||
# Create pos_transaction_items table
|
||||
op.create_table('pos_transaction_items',
|
||||
sa.Column('id', sa.UUID(), nullable=False),
|
||||
sa.Column('transaction_id', sa.UUID(), nullable=False),
|
||||
sa.Column('tenant_id', sa.UUID(), nullable=False),
|
||||
sa.Column('external_item_id', sa.String(255), nullable=True),
|
||||
sa.Column('sku', sa.String(100), nullable=True),
|
||||
sa.Column('product_name', sa.String(255), nullable=False),
|
||||
sa.Column('product_category', sa.String(100), nullable=True),
|
||||
sa.Column('product_subcategory', sa.String(100), nullable=True),
|
||||
sa.Column('quantity', sa.Numeric(10, 3), nullable=False),
|
||||
sa.Column('unit_price', sa.Numeric(10, 2), nullable=False),
|
||||
sa.Column('total_price', sa.Numeric(10, 2), nullable=False),
|
||||
sa.Column('discount_amount', sa.Numeric(10, 2), nullable=False),
|
||||
sa.Column('tax_amount', sa.Numeric(10, 2), nullable=False),
|
||||
sa.Column('modifiers', postgresql.JSON(astext_type=sa.Text()), nullable=True),
|
||||
sa.Column('inventory_product_id', sa.UUID(), nullable=True),
|
||||
sa.Column('is_mapped_to_inventory', sa.Boolean(), nullable=False),
|
||||
sa.Column('is_synced_to_sales', sa.Boolean(), nullable=False),
|
||||
sa.Column('sync_error', sa.Text(), nullable=True),
|
||||
sa.Column('raw_data', postgresql.JSON(astext_type=sa.Text()), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('timezone(\'utc\', now())'), nullable=True),
|
||||
sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('timezone(\'utc\', now())'), nullable=True),
|
||||
sa.ForeignKeyConstraint(['transaction_id'], ['pos_transactions.id'], ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index(op.f('ix_pos_transaction_items_transaction_id'), 'pos_transaction_items', ['transaction_id'], unique=False)
|
||||
op.create_index(op.f('ix_pos_transaction_items_tenant_id'), 'pos_transaction_items', ['tenant_id'], unique=False)
|
||||
op.create_index(op.f('ix_pos_transaction_items_external_item_id'), 'pos_transaction_items', ['external_item_id'], unique=False)
|
||||
op.create_index(op.f('ix_pos_transaction_items_sku'), 'pos_transaction_items', ['sku'], unique=False)
|
||||
op.create_index(op.f('ix_pos_transaction_items_product_name'), 'pos_transaction_items', ['product_name'], unique=False)
|
||||
op.create_index(op.f('ix_pos_transaction_items_product_category'), 'pos_transaction_items', ['product_category'], unique=False)
|
||||
op.create_index(op.f('ix_pos_transaction_items_inventory_product_id'), 'pos_transaction_items', ['inventory_product_id'], unique=False)
|
||||
op.create_index(op.f('ix_pos_transaction_items_is_mapped_to_inventory'), 'pos_transaction_items', ['is_mapped_to_inventory'], unique=False)
|
||||
op.create_index(op.f('ix_pos_transaction_items_is_synced_to_sales'), 'pos_transaction_items', ['is_synced_to_sales'], unique=False)
|
||||
op.create_index('idx_pos_item_transaction', 'pos_transaction_items', ['transaction_id'], unique=False)
|
||||
op.create_index('idx_pos_item_product', 'pos_transaction_items', ['product_name'], unique=False)
|
||||
op.create_index('idx_pos_item_category', 'pos_transaction_items', ['product_category'], unique=False)
|
||||
op.create_index('idx_pos_item_sku', 'pos_transaction_items', ['sku'], unique=False)
|
||||
op.create_index('idx_pos_item_inventory', 'pos_transaction_items', ['inventory_product_id'], unique=False)
|
||||
op.create_index('idx_pos_item_sync', 'pos_transaction_items', ['is_synced_to_sales'], unique=False)
|
||||
op.create_index('idx_pos_item_mapped', 'pos_transaction_items', ['is_mapped_to_inventory'], unique=False)
|
||||
|
||||
# Create pos_sync_logs table
|
||||
op.create_table('pos_sync_logs',
|
||||
sa.Column('id', sa.UUID(), nullable=False),
|
||||
sa.Column('tenant_id', sa.UUID(), nullable=False),
|
||||
sa.Column('pos_config_id', sa.UUID(), nullable=False),
|
||||
sa.Column('sync_type', sa.String(50), nullable=False),
|
||||
sa.Column('sync_direction', sa.String(20), nullable=False),
|
||||
sa.Column('data_type', sa.String(50), nullable=False),
|
||||
sa.Column('pos_system', sa.String(50), nullable=False),
|
||||
sa.Column('status', sa.String(50), nullable=False),
|
||||
sa.Column('started_at', sa.DateTime(timezone=True), nullable=False),
|
||||
sa.Column('completed_at', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('duration_seconds', sa.Numeric(10, 3), nullable=True),
|
||||
sa.Column('sync_from_date', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('sync_to_date', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('records_requested', sa.Integer(), nullable=False),
|
||||
sa.Column('records_processed', sa.Integer(), nullable=False),
|
||||
sa.Column('records_created', sa.Integer(), nullable=False),
|
||||
sa.Column('records_updated', sa.Integer(), nullable=False),
|
||||
sa.Column('records_skipped', sa.Integer(), nullable=False),
|
||||
sa.Column('records_failed', sa.Integer(), nullable=False),
|
||||
sa.Column('api_calls_made', sa.Integer(), nullable=False),
|
||||
sa.Column('api_rate_limit_hits', sa.Integer(), nullable=False),
|
||||
sa.Column('total_api_time_ms', sa.Integer(), nullable=False),
|
||||
sa.Column('error_message', sa.Text(), nullable=True),
|
||||
sa.Column('error_code', sa.String(100), nullable=True),
|
||||
sa.Column('error_details', postgresql.JSON(astext_type=sa.Text()), nullable=True),
|
||||
sa.Column('retry_attempt', sa.Integer(), nullable=False),
|
||||
sa.Column('max_retries', sa.Integer(), nullable=False),
|
||||
sa.Column('parent_sync_id', sa.UUID(), nullable=True),
|
||||
sa.Column('sync_configuration', postgresql.JSON(astext_type=sa.Text()), nullable=True),
|
||||
sa.Column('current_page', sa.Integer(), nullable=True),
|
||||
sa.Column('total_pages', sa.Integer(), nullable=True),
|
||||
sa.Column('current_batch', sa.Integer(), nullable=True),
|
||||
sa.Column('total_batches', sa.Integer(), nullable=True),
|
||||
sa.Column('progress_percentage', sa.Numeric(5, 2), nullable=True),
|
||||
sa.Column('validation_errors', postgresql.JSON(astext_type=sa.Text()), nullable=True),
|
||||
sa.Column('data_quality_score', sa.Numeric(5, 2), nullable=True),
|
||||
sa.Column('memory_usage_mb', sa.Numeric(10, 2), nullable=True),
|
||||
sa.Column('cpu_usage_percentage', sa.Numeric(5, 2), nullable=True),
|
||||
sa.Column('network_bytes_received', sa.Integer(), nullable=True),
|
||||
sa.Column('network_bytes_sent', sa.Integer(), nullable=True),
|
||||
sa.Column('revenue_synced', sa.Numeric(12, 2), nullable=True),
|
||||
sa.Column('transactions_synced', sa.Integer(), nullable=False),
|
||||
sa.Column('triggered_by', sa.String(50), nullable=True),
|
||||
sa.Column('triggered_by_user_id', sa.UUID(), nullable=True),
|
||||
sa.Column('trigger_details', postgresql.JSON(astext_type=sa.Text()), nullable=True),
|
||||
sa.Column('external_batch_id', sa.String(255), nullable=True),
|
||||
sa.Column('webhook_log_id', sa.UUID(), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('timezone(\'utc\', now())'), nullable=True),
|
||||
sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('timezone(\'utc\', now())'), nullable=True),
|
||||
sa.ForeignKeyConstraint(['pos_config_id'], ['pos_configurations.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index(op.f('ix_pos_sync_logs_tenant_id'), 'pos_sync_logs', ['tenant_id'], unique=False)
|
||||
op.create_index(op.f('ix_pos_sync_logs_pos_config_id'), 'pos_sync_logs', ['pos_config_id'], unique=False)
|
||||
op.create_index(op.f('ix_pos_sync_logs_sync_type'), 'pos_sync_logs', ['sync_type'], unique=False)
|
||||
op.create_index(op.f('ix_pos_sync_logs_data_type'), 'pos_sync_logs', ['data_type'], unique=False)
|
||||
op.create_index(op.f('ix_pos_sync_logs_pos_system'), 'pos_sync_logs', ['pos_system'], unique=False)
|
||||
op.create_index(op.f('ix_pos_sync_logs_status'), 'pos_sync_logs', ['status'], unique=False)
|
||||
op.create_index(op.f('ix_pos_sync_logs_started_at'), 'pos_sync_logs', ['started_at'], unique=False)
|
||||
op.create_index(op.f('ix_pos_sync_logs_completed_at'), 'pos_sync_logs', ['completed_at'], unique=False)
|
||||
op.create_index(op.f('ix_pos_sync_logs_parent_sync_id'), 'pos_sync_logs', ['parent_sync_id'], unique=False)
|
||||
op.create_index(op.f('ix_pos_sync_logs_webhook_log_id'), 'pos_sync_logs', ['webhook_log_id'], unique=False)
|
||||
op.create_index(op.f('ix_pos_sync_logs_external_batch_id'), 'pos_sync_logs', ['external_batch_id'], unique=False)
|
||||
op.create_index('idx_sync_log_tenant_started', 'pos_sync_logs', ['tenant_id', 'started_at'], unique=False)
|
||||
op.create_index('idx_sync_log_pos_system_type', 'pos_sync_logs', ['pos_system', 'sync_type'], unique=False)
|
||||
op.create_index('idx_sync_log_data_type', 'pos_sync_logs', ['data_type'], unique=False)
|
||||
op.create_index('idx_sync_log_trigger', 'pos_sync_logs', ['triggered_by'], unique=False)
|
||||
|
||||
# Create pos_webhooks table
|
||||
op.create_table('pos_webhooks',
|
||||
sa.Column('id', sa.UUID(), nullable=False),
|
||||
sa.Column('tenant_id', sa.UUID(), nullable=True),
|
||||
sa.Column('pos_config_id', sa.UUID(), nullable=False),
|
||||
sa.Column('event_type', sa.String(100), nullable=False),
|
||||
sa.Column('target_url', sa.String(500), nullable=False),
|
||||
sa.Column('status', sa.String(50), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True),
|
||||
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['pos_config_id'], ['pos_configurations.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index(op.f('ix_pos_webhooks_tenant_id'), 'pos_webhooks', ['tenant_id'], unique=False)
|
||||
op.create_index(op.f('ix_pos_webhooks_pos_config_id'), 'pos_webhooks', ['pos_config_id'], unique=False)
|
||||
op.create_index(op.f('ix_pos_webhooks_event_type'), 'pos_webhooks', ['event_type'], unique=False)
|
||||
op.create_index(op.f('ix_pos_webhooks_status'), 'pos_webhooks', ['status'], unique=False)
|
||||
|
||||
# Create pos_webhook_logs table
|
||||
op.create_table('pos_webhook_logs',
|
||||
sa.Column('id', sa.UUID(), nullable=False),
|
||||
sa.Column('tenant_id', sa.UUID(), nullable=True),
|
||||
sa.Column('pos_system', sa.String(50), nullable=False),
|
||||
sa.Column('webhook_type', sa.String(100), nullable=False),
|
||||
sa.Column('method', sa.String(10), nullable=False),
|
||||
sa.Column('url_path', sa.String(500), nullable=False),
|
||||
sa.Column('query_params', postgresql.JSON(astext_type=sa.Text()), nullable=True),
|
||||
sa.Column('headers', postgresql.JSON(astext_type=sa.Text()), nullable=True),
|
||||
sa.Column('raw_payload', sa.Text(), nullable=False),
|
||||
sa.Column('payload_size', sa.Integer(), nullable=False),
|
||||
sa.Column('content_type', sa.String(100), nullable=True),
|
||||
sa.Column('signature', sa.String(500), nullable=True),
|
||||
sa.Column('is_signature_valid', sa.Boolean(), nullable=True),
|
||||
sa.Column('source_ip', sa.String(45), nullable=True),
|
||||
sa.Column('status', sa.String(50), nullable=False),
|
||||
sa.Column('processing_started_at', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('processing_completed_at', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('processing_duration_ms', sa.Integer(), nullable=True),
|
||||
sa.Column('error_message', sa.Text(), nullable=True),
|
||||
sa.Column('error_code', sa.String(50), nullable=True),
|
||||
sa.Column('retry_count', sa.Integer(), nullable=False),
|
||||
sa.Column('max_retries', sa.Integer(), nullable=False),
|
||||
sa.Column('response_status_code', sa.Integer(), nullable=True),
|
||||
sa.Column('response_body', sa.Text(), nullable=True),
|
||||
sa.Column('response_sent_at', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('event_id', sa.String(255), nullable=True),
|
||||
sa.Column('event_timestamp', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('sequence_number', sa.Integer(), nullable=True),
|
||||
sa.Column('transaction_id', sa.String(255), nullable=True),
|
||||
sa.Column('order_id', sa.String(255), nullable=True),
|
||||
sa.Column('customer_id', sa.String(255), nullable=True),
|
||||
sa.Column('created_transaction_id', sa.UUID(), nullable=True),
|
||||
sa.Column('updated_transaction_id', sa.UUID(), nullable=True),
|
||||
sa.Column('is_duplicate', sa.Boolean(), nullable=False),
|
||||
sa.Column('duplicate_of', sa.UUID(), nullable=True),
|
||||
sa.Column('priority', sa.String(20), nullable=False),
|
||||
sa.Column('user_agent', sa.String(500), nullable=True),
|
||||
sa.Column('forwarded_for', sa.String(200), nullable=True),
|
||||
sa.Column('request_id', sa.String(100), nullable=True),
|
||||
sa.Column('received_at', sa.DateTime(timezone=True), server_default=sa.text('timezone(\'utc\', now())'), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('timezone(\'utc\', now())'), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('timezone(\'utc\', now())'), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index(op.f('ix_pos_webhook_logs_tenant_id'), 'pos_webhook_logs', ['tenant_id'], unique=False)
|
||||
op.create_index(op.f('ix_pos_webhook_logs_pos_system'), 'pos_webhook_logs', ['pos_system'], unique=False)
|
||||
op.create_index(op.f('ix_pos_webhook_logs_webhook_type'), 'pos_webhook_logs', ['webhook_type'], unique=False)
|
||||
op.create_index(op.f('ix_pos_webhook_logs_status'), 'pos_webhook_logs', ['status'], unique=False)
|
||||
op.create_index(op.f('ix_pos_webhook_logs_event_id'), 'pos_webhook_logs', ['event_id'], unique=False)
|
||||
op.create_index(op.f('ix_pos_webhook_logs_received_at'), 'pos_webhook_logs', ['received_at'], unique=False)
|
||||
op.create_index(op.f('ix_pos_webhook_logs_transaction_id'), 'pos_webhook_logs', ['transaction_id'], unique=False)
|
||||
op.create_index(op.f('ix_pos_webhook_logs_order_id'), 'pos_webhook_logs', ['order_id'], unique=False)
|
||||
op.create_index(op.f('ix_pos_webhook_logs_is_duplicate'), 'pos_webhook_logs', ['is_duplicate'], unique=False)
|
||||
op.create_index(op.f('ix_pos_webhook_logs_duplicate_of'), 'pos_webhook_logs', ['duplicate_of'], unique=False)
|
||||
op.create_index('idx_webhook_pos_system_type', 'pos_webhook_logs', ['pos_system', 'webhook_type'], unique=False)
|
||||
op.create_index('idx_webhook_event_id', 'pos_webhook_logs', ['event_id'], unique=False)
|
||||
op.create_index('idx_webhook_tenant_received', 'pos_webhook_logs', ['tenant_id', 'received_at'], unique=False)
|
||||
op.create_index('idx_webhook_transaction_id', 'pos_webhook_logs', ['transaction_id'], unique=False)
|
||||
op.create_index('idx_webhook_order_id', 'pos_webhook_logs', ['order_id'], unique=False)
|
||||
op.create_index('idx_webhook_duplicate', 'pos_webhook_logs', ['is_duplicate'], unique=False)
|
||||
op.create_index('idx_webhook_priority', 'pos_webhook_logs', ['priority'], unique=False)
|
||||
op.create_index('idx_webhook_retry', 'pos_webhook_logs', ['retry_count'], unique=False)
|
||||
op.create_index('idx_webhook_signature_valid', 'pos_webhook_logs', ['is_signature_valid'], unique=False)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# Drop pos_webhook_logs table
|
||||
op.drop_index('idx_webhook_signature_valid', table_name='pos_webhook_logs')
|
||||
op.drop_index('idx_webhook_retry', table_name='pos_webhook_logs')
|
||||
op.drop_index('idx_webhook_priority', table_name='pos_webhook_logs')
|
||||
op.drop_index('idx_webhook_duplicate', table_name='pos_webhook_logs')
|
||||
op.drop_index('idx_webhook_order_id', table_name='pos_webhook_logs')
|
||||
op.drop_index('idx_webhook_transaction_id', table_name='pos_webhook_logs')
|
||||
op.drop_index('idx_webhook_tenant_received', table_name='pos_webhook_logs')
|
||||
op.drop_index('idx_webhook_event_id', table_name='pos_webhook_logs')
|
||||
op.drop_index('idx_webhook_pos_system_type', table_name='pos_webhook_logs')
|
||||
op.drop_index(op.f('ix_pos_webhook_logs_duplicate_of'), table_name='pos_webhook_logs')
|
||||
op.drop_index(op.f('ix_pos_webhook_logs_is_duplicate'), table_name='pos_webhook_logs')
|
||||
op.drop_index(op.f('ix_pos_webhook_logs_order_id'), table_name='pos_webhook_logs')
|
||||
op.drop_index(op.f('ix_pos_webhook_logs_transaction_id'), table_name='pos_webhook_logs')
|
||||
op.drop_index(op.f('ix_pos_webhook_logs_received_at'), table_name='pos_webhook_logs')
|
||||
op.drop_index(op.f('ix_pos_webhook_logs_event_id'), table_name='pos_webhook_logs')
|
||||
op.drop_index(op.f('ix_pos_webhook_logs_status'), table_name='pos_webhook_logs')
|
||||
op.drop_index(op.f('ix_pos_webhook_logs_webhook_type'), table_name='pos_webhook_logs')
|
||||
op.drop_index(op.f('ix_pos_webhook_logs_pos_system'), table_name='pos_webhook_logs')
|
||||
op.drop_index(op.f('ix_pos_webhook_logs_tenant_id'), table_name='pos_webhook_logs')
|
||||
op.drop_table('pos_webhook_logs')
|
||||
|
||||
# Drop pos_webhooks table
|
||||
op.drop_index(op.f('ix_pos_webhooks_status'), table_name='pos_webhooks')
|
||||
op.drop_index(op.f('ix_pos_webhooks_event_type'), table_name='pos_webhooks')
|
||||
op.drop_index(op.f('ix_pos_webhooks_pos_config_id'), table_name='pos_webhooks')
|
||||
op.drop_index(op.f('ix_pos_webhooks_tenant_id'), table_name='pos_webhooks')
|
||||
op.drop_table('pos_webhooks')
|
||||
|
||||
# Drop pos_sync_logs table
|
||||
op.drop_index('idx_sync_log_trigger', table_name='pos_sync_logs')
|
||||
op.drop_index('idx_sync_log_data_type', table_name='pos_sync_logs')
|
||||
op.drop_index('idx_sync_log_pos_system_type', table_name='pos_sync_logs')
|
||||
op.drop_index('idx_sync_log_tenant_started', table_name='pos_sync_logs')
|
||||
op.drop_index(op.f('ix_pos_sync_logs_external_batch_id'), table_name='pos_sync_logs')
|
||||
op.drop_index(op.f('ix_pos_sync_logs_webhook_log_id'), table_name='pos_sync_logs')
|
||||
op.drop_index(op.f('ix_pos_sync_logs_parent_sync_id'), table_name='pos_sync_logs')
|
||||
op.drop_index(op.f('ix_pos_sync_logs_completed_at'), table_name='pos_sync_logs')
|
||||
op.drop_index(op.f('ix_pos_sync_logs_started_at'), table_name='pos_sync_logs')
|
||||
op.drop_index(op.f('ix_pos_sync_logs_status'), table_name='pos_sync_logs')
|
||||
op.drop_index(op.f('ix_pos_sync_logs_pos_system'), table_name='pos_sync_logs')
|
||||
op.drop_index(op.f('ix_pos_sync_logs_data_type'), table_name='pos_sync_logs')
|
||||
op.drop_index(op.f('ix_pos_sync_logs_sync_type'), table_name='pos_sync_logs')
|
||||
op.drop_index(op.f('ix_pos_sync_logs_pos_config_id'), table_name='pos_sync_logs')
|
||||
op.drop_index(op.f('ix_pos_sync_logs_tenant_id'), table_name='pos_sync_logs')
|
||||
op.drop_table('pos_sync_logs')
|
||||
|
||||
# Drop pos_transaction_items table
|
||||
op.drop_index('idx_pos_item_mapped', table_name='pos_transaction_items')
|
||||
op.drop_index('idx_pos_item_sync', table_name='pos_transaction_items')
|
||||
op.drop_index('idx_pos_item_inventory', table_name='pos_transaction_items')
|
||||
op.drop_index('idx_pos_item_sku', table_name='pos_transaction_items')
|
||||
op.drop_index('idx_pos_item_category', table_name='pos_transaction_items')
|
||||
op.drop_index('idx_pos_item_product', table_name='pos_transaction_items')
|
||||
op.drop_index('idx_pos_item_transaction', table_name='pos_transaction_items')
|
||||
op.drop_index(op.f('ix_pos_transaction_items_is_synced_to_sales'), table_name='pos_transaction_items')
|
||||
op.drop_index(op.f('ix_pos_transaction_items_is_mapped_to_inventory'), table_name='pos_transaction_items')
|
||||
op.drop_index(op.f('ix_pos_transaction_items_inventory_product_id'), table_name='pos_transaction_items')
|
||||
op.drop_index(op.f('ix_pos_transaction_items_product_category'), table_name='pos_transaction_items')
|
||||
op.drop_index(op.f('ix_pos_transaction_items_product_name'), table_name='pos_transaction_items')
|
||||
op.drop_index(op.f('ix_pos_transaction_items_sku'), table_name='pos_transaction_items')
|
||||
op.drop_index(op.f('ix_pos_transaction_items_external_item_id'), table_name='pos_transaction_items')
|
||||
op.drop_index(op.f('ix_pos_transaction_items_tenant_id'), table_name='pos_transaction_items')
|
||||
op.drop_index(op.f('ix_pos_transaction_items_transaction_id'), table_name='pos_transaction_items')
|
||||
op.drop_table('pos_transaction_items')
|
||||
|
||||
# Drop pos_transactions table
|
||||
op.drop_index('idx_pos_transaction_customer', table_name='pos_transactions')
|
||||
op.drop_index('idx_pos_transaction_location', table_name='pos_transactions')
|
||||
op.drop_index('idx_pos_transaction_processed', table_name='pos_transactions')
|
||||
op.drop_index('idx_pos_transaction_sync_status', table_name='pos_transactions')
|
||||
op.drop_index('idx_pos_transaction_external_id', table_name='pos_transactions')
|
||||
op.drop_index('idx_pos_transaction_tenant_date', table_name='pos_transactions')
|
||||
op.drop_index(op.f('ix_pos_transactions_duplicate_of'), table_name='pos_transactions')
|
||||
op.drop_index(op.f('ix_pos_transactions_is_duplicate'), table_name='pos_transactions')
|
||||
op.drop_index(op.f('ix_pos_transactions_is_processed'), table_name='pos_transactions')
|
||||
op.drop_index(op.f('ix_pos_transactions_is_synced_to_sales'), table_name='pos_transactions')
|
||||
op.drop_index(op.f('ix_pos_transactions_sales_record_id'), table_name='pos_transactions')
|
||||
op.drop_index(op.f('ix_pos_transactions_customer_id'), table_name='pos_transactions')
|
||||
op.drop_index(op.f('ix_pos_transactions_location_id'), table_name='pos_transactions')
|
||||
op.drop_index(op.f('ix_pos_transactions_transaction_date'), table_name='pos_transactions')
|
||||
op.drop_index(op.f('ix_pos_transactions_status'), table_name='pos_transactions')
|
||||
op.drop_index(op.f('ix_pos_transactions_transaction_type'), table_name='pos_transactions')
|
||||
op.drop_index(op.f('ix_pos_transactions_pos_system'), table_name='pos_transactions')
|
||||
op.drop_index(op.f('ix_pos_transactions_external_order_id'), table_name='pos_transactions')
|
||||
op.drop_index(op.f('ix_pos_transactions_external_transaction_id'), table_name='pos_transactions')
|
||||
op.drop_index(op.f('ix_pos_transactions_pos_config_id'), table_name='pos_transactions')
|
||||
op.drop_index(op.f('ix_pos_transactions_tenant_id'), table_name='pos_transactions')
|
||||
op.drop_table('pos_transactions')
|
||||
|
||||
# Drop pos_configurations table
|
||||
op.drop_index('idx_pos_quality', table_name='pos_configurations')
|
||||
op.drop_index('idx_pos_training', table_name='pos_configurations')
|
||||
op.drop_index('idx_pos_district_date', table_name='pos_configurations')
|
||||
op.drop_index('idx_pos_measurement_point', table_name='pos_configurations')
|
||||
op.drop_index('idx_pos_city_location', table_name='pos_configurations')
|
||||
op.drop_index('idx_pos_tenant_date', table_name='pos_configurations')
|
||||
op.drop_index('idx_pos_city_date', table_name='pos_configurations')
|
||||
op.drop_index('idx_pos_location_date', table_name='pos_configurations')
|
||||
op.drop_index(op.f('ix_pos_configurations_date'), table_name='pos_configurations')
|
||||
op.drop_index(op.f('ix_pos_configurations_city'), table_name='pos_configurations')
|
||||
op.drop_index(op.f('ix_pos_configurations_location_id'), table_name='pos_configurations')
|
||||
op.drop_index(op.f('ix_pos_configurations_tenant_id'), table_name='pos_configurations')
|
||||
op.drop_table('pos_configurations')
|
||||
@@ -0,0 +1,392 @@
|
||||
"""initial_schema_20251001_1118
|
||||
|
||||
Revision ID: 36bd79501798
|
||||
Revises:
|
||||
Create Date: 2025-10-01 11:18:18.854624+02:00
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '36bd79501798'
|
||||
down_revision: Union[str, None] = None
|
||||
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('pos_configurations',
|
||||
sa.Column('id', sa.UUID(), nullable=False),
|
||||
sa.Column('tenant_id', sa.UUID(), nullable=False),
|
||||
sa.Column('pos_system', sa.String(length=50), nullable=False),
|
||||
sa.Column('provider_name', sa.String(length=100), nullable=False),
|
||||
sa.Column('is_active', sa.Boolean(), nullable=False),
|
||||
sa.Column('is_connected', sa.Boolean(), nullable=False),
|
||||
sa.Column('encrypted_credentials', sa.Text(), nullable=True),
|
||||
sa.Column('webhook_url', sa.String(length=500), nullable=True),
|
||||
sa.Column('webhook_secret', sa.String(length=255), nullable=True),
|
||||
sa.Column('environment', sa.String(length=20), nullable=False),
|
||||
sa.Column('location_id', sa.String(length=100), nullable=True),
|
||||
sa.Column('merchant_id', sa.String(length=100), nullable=True),
|
||||
sa.Column('sync_enabled', sa.Boolean(), nullable=False),
|
||||
sa.Column('sync_interval_minutes', sa.String(length=10), nullable=False),
|
||||
sa.Column('auto_sync_products', sa.Boolean(), nullable=False),
|
||||
sa.Column('auto_sync_transactions', sa.Boolean(), nullable=False),
|
||||
sa.Column('last_sync_at', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('last_successful_sync_at', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('last_sync_status', sa.String(length=50), nullable=True),
|
||||
sa.Column('last_sync_message', sa.Text(), nullable=True),
|
||||
sa.Column('provider_settings', sa.JSON(), nullable=True),
|
||||
sa.Column('last_health_check_at', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('health_status', sa.String(length=50), nullable=False),
|
||||
sa.Column('health_message', sa.Text(), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('created_by', sa.UUID(), nullable=True),
|
||||
sa.Column('notes', sa.Text(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index('idx_pos_config_active', 'pos_configurations', ['is_active'], unique=False)
|
||||
op.create_index('idx_pos_config_connected', 'pos_configurations', ['is_connected'], unique=False)
|
||||
op.create_index('idx_pos_config_created_at', 'pos_configurations', ['created_at'], unique=False)
|
||||
op.create_index('idx_pos_config_health_status', 'pos_configurations', ['health_status'], unique=False)
|
||||
op.create_index('idx_pos_config_sync_enabled', 'pos_configurations', ['sync_enabled'], unique=False)
|
||||
op.create_index('idx_pos_config_tenant_pos_system', 'pos_configurations', ['tenant_id', 'pos_system'], unique=False)
|
||||
op.create_index(op.f('ix_pos_configurations_id'), 'pos_configurations', ['id'], unique=False)
|
||||
op.create_index(op.f('ix_pos_configurations_tenant_id'), 'pos_configurations', ['tenant_id'], unique=False)
|
||||
op.create_table('pos_sync_logs',
|
||||
sa.Column('id', sa.UUID(), nullable=False),
|
||||
sa.Column('tenant_id', sa.UUID(), nullable=False),
|
||||
sa.Column('pos_config_id', sa.UUID(), nullable=False),
|
||||
sa.Column('sync_type', sa.String(length=50), nullable=False),
|
||||
sa.Column('sync_direction', sa.String(length=20), nullable=False),
|
||||
sa.Column('data_type', sa.String(length=50), nullable=False),
|
||||
sa.Column('pos_system', sa.String(length=50), nullable=False),
|
||||
sa.Column('status', sa.String(length=50), nullable=False),
|
||||
sa.Column('started_at', sa.DateTime(timezone=True), nullable=False),
|
||||
sa.Column('completed_at', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('duration_seconds', sa.Numeric(precision=10, scale=3), nullable=True),
|
||||
sa.Column('sync_from_date', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('sync_to_date', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('records_requested', sa.Integer(), nullable=False),
|
||||
sa.Column('records_processed', sa.Integer(), nullable=False),
|
||||
sa.Column('records_created', sa.Integer(), nullable=False),
|
||||
sa.Column('records_updated', sa.Integer(), nullable=False),
|
||||
sa.Column('records_skipped', sa.Integer(), nullable=False),
|
||||
sa.Column('records_failed', sa.Integer(), nullable=False),
|
||||
sa.Column('api_calls_made', sa.Integer(), nullable=False),
|
||||
sa.Column('api_rate_limit_hits', sa.Integer(), nullable=False),
|
||||
sa.Column('total_api_time_ms', sa.Integer(), nullable=False),
|
||||
sa.Column('error_message', sa.Text(), nullable=True),
|
||||
sa.Column('error_code', sa.String(length=100), nullable=True),
|
||||
sa.Column('error_details', sa.JSON(), nullable=True),
|
||||
sa.Column('retry_attempt', sa.Integer(), nullable=False),
|
||||
sa.Column('max_retries', sa.Integer(), nullable=False),
|
||||
sa.Column('parent_sync_id', sa.UUID(), nullable=True),
|
||||
sa.Column('sync_configuration', sa.JSON(), nullable=True),
|
||||
sa.Column('current_page', sa.Integer(), nullable=True),
|
||||
sa.Column('total_pages', sa.Integer(), nullable=True),
|
||||
sa.Column('current_batch', sa.Integer(), nullable=True),
|
||||
sa.Column('total_batches', sa.Integer(), nullable=True),
|
||||
sa.Column('progress_percentage', sa.Numeric(precision=5, scale=2), nullable=True),
|
||||
sa.Column('validation_errors', sa.JSON(), nullable=True),
|
||||
sa.Column('data_quality_score', sa.Numeric(precision=5, scale=2), nullable=True),
|
||||
sa.Column('memory_usage_mb', sa.Numeric(precision=10, scale=2), nullable=True),
|
||||
sa.Column('cpu_usage_percentage', sa.Numeric(precision=5, scale=2), nullable=True),
|
||||
sa.Column('network_bytes_received', sa.Integer(), nullable=True),
|
||||
sa.Column('network_bytes_sent', sa.Integer(), nullable=True),
|
||||
sa.Column('revenue_synced', sa.Numeric(precision=12, scale=2), nullable=True),
|
||||
sa.Column('transactions_synced', sa.Integer(), nullable=False),
|
||||
sa.Column('triggered_by', sa.String(length=50), nullable=True),
|
||||
sa.Column('triggered_by_user_id', sa.UUID(), nullable=True),
|
||||
sa.Column('trigger_details', sa.JSON(), nullable=True),
|
||||
sa.Column('external_batch_id', sa.String(length=255), nullable=True),
|
||||
sa.Column('webhook_log_id', sa.UUID(), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('notes', sa.Text(), nullable=True),
|
||||
sa.Column('tags', sa.JSON(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index('idx_sync_log_completed', 'pos_sync_logs', ['completed_at'], unique=False)
|
||||
op.create_index('idx_sync_log_data_type', 'pos_sync_logs', ['data_type'], unique=False)
|
||||
op.create_index('idx_sync_log_duration', 'pos_sync_logs', ['duration_seconds'], unique=False)
|
||||
op.create_index('idx_sync_log_external_batch', 'pos_sync_logs', ['external_batch_id'], unique=False)
|
||||
op.create_index('idx_sync_log_parent', 'pos_sync_logs', ['parent_sync_id'], unique=False)
|
||||
op.create_index('idx_sync_log_pos_system_type', 'pos_sync_logs', ['pos_system', 'sync_type'], unique=False)
|
||||
op.create_index('idx_sync_log_retry', 'pos_sync_logs', ['retry_attempt'], unique=False)
|
||||
op.create_index('idx_sync_log_status', 'pos_sync_logs', ['status'], unique=False)
|
||||
op.create_index('idx_sync_log_tenant_started', 'pos_sync_logs', ['tenant_id', 'started_at'], unique=False)
|
||||
op.create_index('idx_sync_log_trigger', 'pos_sync_logs', ['triggered_by'], unique=False)
|
||||
op.create_index('idx_sync_log_webhook', 'pos_sync_logs', ['webhook_log_id'], unique=False)
|
||||
op.create_index(op.f('ix_pos_sync_logs_data_type'), 'pos_sync_logs', ['data_type'], unique=False)
|
||||
op.create_index(op.f('ix_pos_sync_logs_id'), 'pos_sync_logs', ['id'], unique=False)
|
||||
op.create_index(op.f('ix_pos_sync_logs_pos_config_id'), 'pos_sync_logs', ['pos_config_id'], unique=False)
|
||||
op.create_index(op.f('ix_pos_sync_logs_pos_system'), 'pos_sync_logs', ['pos_system'], unique=False)
|
||||
op.create_index(op.f('ix_pos_sync_logs_started_at'), 'pos_sync_logs', ['started_at'], unique=False)
|
||||
op.create_index(op.f('ix_pos_sync_logs_status'), 'pos_sync_logs', ['status'], unique=False)
|
||||
op.create_index(op.f('ix_pos_sync_logs_sync_type'), 'pos_sync_logs', ['sync_type'], unique=False)
|
||||
op.create_index(op.f('ix_pos_sync_logs_tenant_id'), 'pos_sync_logs', ['tenant_id'], unique=False)
|
||||
op.create_table('pos_webhook_logs',
|
||||
sa.Column('id', sa.UUID(), nullable=False),
|
||||
sa.Column('tenant_id', sa.UUID(), nullable=True),
|
||||
sa.Column('pos_system', sa.String(length=50), nullable=False),
|
||||
sa.Column('webhook_type', sa.String(length=100), nullable=False),
|
||||
sa.Column('method', sa.String(length=10), nullable=False),
|
||||
sa.Column('url_path', sa.String(length=500), nullable=False),
|
||||
sa.Column('query_params', sa.JSON(), nullable=True),
|
||||
sa.Column('headers', sa.JSON(), nullable=True),
|
||||
sa.Column('raw_payload', sa.Text(), nullable=False),
|
||||
sa.Column('payload_size', sa.Integer(), nullable=False),
|
||||
sa.Column('content_type', sa.String(length=100), nullable=True),
|
||||
sa.Column('signature', sa.String(length=500), nullable=True),
|
||||
sa.Column('is_signature_valid', sa.Boolean(), nullable=True),
|
||||
sa.Column('source_ip', sa.String(length=45), nullable=True),
|
||||
sa.Column('status', sa.String(length=50), nullable=False),
|
||||
sa.Column('processing_started_at', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('processing_completed_at', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('processing_duration_ms', sa.Integer(), nullable=True),
|
||||
sa.Column('error_message', sa.Text(), nullable=True),
|
||||
sa.Column('error_code', sa.String(length=50), nullable=True),
|
||||
sa.Column('retry_count', sa.Integer(), nullable=False),
|
||||
sa.Column('max_retries', sa.Integer(), nullable=False),
|
||||
sa.Column('response_status_code', sa.Integer(), nullable=True),
|
||||
sa.Column('response_body', sa.Text(), nullable=True),
|
||||
sa.Column('response_sent_at', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('event_id', sa.String(length=255), nullable=True),
|
||||
sa.Column('event_timestamp', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('sequence_number', sa.Integer(), nullable=True),
|
||||
sa.Column('transaction_id', sa.String(length=255), nullable=True),
|
||||
sa.Column('order_id', sa.String(length=255), nullable=True),
|
||||
sa.Column('customer_id', sa.String(length=255), nullable=True),
|
||||
sa.Column('created_transaction_id', sa.UUID(), nullable=True),
|
||||
sa.Column('updated_transaction_id', sa.UUID(), nullable=True),
|
||||
sa.Column('is_duplicate', sa.Boolean(), nullable=False),
|
||||
sa.Column('duplicate_of', sa.UUID(), nullable=True),
|
||||
sa.Column('priority', sa.String(length=20), nullable=False),
|
||||
sa.Column('user_agent', sa.String(length=500), nullable=True),
|
||||
sa.Column('forwarded_for', sa.String(length=200), nullable=True),
|
||||
sa.Column('request_id', sa.String(length=100), nullable=True),
|
||||
sa.Column('received_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index('idx_webhook_duplicate', 'pos_webhook_logs', ['is_duplicate'], unique=False)
|
||||
op.create_index('idx_webhook_event_id', 'pos_webhook_logs', ['event_id'], unique=False)
|
||||
op.create_index('idx_webhook_order_id', 'pos_webhook_logs', ['order_id'], unique=False)
|
||||
op.create_index('idx_webhook_pos_system_type', 'pos_webhook_logs', ['pos_system', 'webhook_type'], unique=False)
|
||||
op.create_index('idx_webhook_priority', 'pos_webhook_logs', ['priority'], unique=False)
|
||||
op.create_index('idx_webhook_received_at', 'pos_webhook_logs', ['received_at'], unique=False)
|
||||
op.create_index('idx_webhook_retry', 'pos_webhook_logs', ['retry_count'], unique=False)
|
||||
op.create_index('idx_webhook_signature_valid', 'pos_webhook_logs', ['is_signature_valid'], unique=False)
|
||||
op.create_index('idx_webhook_status', 'pos_webhook_logs', ['status'], unique=False)
|
||||
op.create_index('idx_webhook_tenant_received', 'pos_webhook_logs', ['tenant_id', 'received_at'], unique=False)
|
||||
op.create_index('idx_webhook_transaction_id', 'pos_webhook_logs', ['transaction_id'], unique=False)
|
||||
op.create_index(op.f('ix_pos_webhook_logs_event_id'), 'pos_webhook_logs', ['event_id'], unique=False)
|
||||
op.create_index(op.f('ix_pos_webhook_logs_id'), 'pos_webhook_logs', ['id'], unique=False)
|
||||
op.create_index(op.f('ix_pos_webhook_logs_is_duplicate'), 'pos_webhook_logs', ['is_duplicate'], unique=False)
|
||||
op.create_index(op.f('ix_pos_webhook_logs_order_id'), 'pos_webhook_logs', ['order_id'], unique=False)
|
||||
op.create_index(op.f('ix_pos_webhook_logs_pos_system'), 'pos_webhook_logs', ['pos_system'], unique=False)
|
||||
op.create_index(op.f('ix_pos_webhook_logs_received_at'), 'pos_webhook_logs', ['received_at'], unique=False)
|
||||
op.create_index(op.f('ix_pos_webhook_logs_status'), 'pos_webhook_logs', ['status'], unique=False)
|
||||
op.create_index(op.f('ix_pos_webhook_logs_tenant_id'), 'pos_webhook_logs', ['tenant_id'], unique=False)
|
||||
op.create_index(op.f('ix_pos_webhook_logs_transaction_id'), 'pos_webhook_logs', ['transaction_id'], unique=False)
|
||||
op.create_index(op.f('ix_pos_webhook_logs_webhook_type'), 'pos_webhook_logs', ['webhook_type'], unique=False)
|
||||
op.create_table('pos_transactions',
|
||||
sa.Column('id', sa.UUID(), nullable=False),
|
||||
sa.Column('tenant_id', sa.UUID(), nullable=False),
|
||||
sa.Column('pos_config_id', sa.UUID(), nullable=False),
|
||||
sa.Column('pos_system', sa.String(length=50), nullable=False),
|
||||
sa.Column('external_transaction_id', sa.String(length=255), nullable=False),
|
||||
sa.Column('external_order_id', sa.String(length=255), nullable=True),
|
||||
sa.Column('transaction_type', sa.String(length=50), nullable=False),
|
||||
sa.Column('status', sa.String(length=50), nullable=False),
|
||||
sa.Column('subtotal', sa.Numeric(precision=10, scale=2), nullable=False),
|
||||
sa.Column('tax_amount', sa.Numeric(precision=10, scale=2), nullable=False),
|
||||
sa.Column('tip_amount', sa.Numeric(precision=10, scale=2), nullable=False),
|
||||
sa.Column('discount_amount', sa.Numeric(precision=10, scale=2), nullable=False),
|
||||
sa.Column('total_amount', sa.Numeric(precision=10, scale=2), nullable=False),
|
||||
sa.Column('currency', sa.String(length=3), nullable=False),
|
||||
sa.Column('payment_method', sa.String(length=50), nullable=True),
|
||||
sa.Column('payment_status', sa.String(length=50), nullable=True),
|
||||
sa.Column('transaction_date', sa.DateTime(timezone=True), nullable=False),
|
||||
sa.Column('pos_created_at', sa.DateTime(timezone=True), nullable=False),
|
||||
sa.Column('pos_updated_at', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('location_id', sa.String(length=100), nullable=True),
|
||||
sa.Column('location_name', sa.String(length=255), nullable=True),
|
||||
sa.Column('staff_id', sa.String(length=100), nullable=True),
|
||||
sa.Column('staff_name', sa.String(length=255), nullable=True),
|
||||
sa.Column('customer_id', sa.String(length=100), nullable=True),
|
||||
sa.Column('customer_email', sa.String(length=255), nullable=True),
|
||||
sa.Column('customer_phone', sa.String(length=50), nullable=True),
|
||||
sa.Column('order_type', sa.String(length=50), nullable=True),
|
||||
sa.Column('table_number', sa.String(length=20), nullable=True),
|
||||
sa.Column('receipt_number', sa.String(length=100), nullable=True),
|
||||
sa.Column('is_synced_to_sales', sa.Boolean(), nullable=False),
|
||||
sa.Column('sales_record_id', sa.UUID(), nullable=True),
|
||||
sa.Column('sync_attempted_at', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('sync_completed_at', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('sync_error', sa.Text(), nullable=True),
|
||||
sa.Column('sync_retry_count', sa.Integer(), nullable=False),
|
||||
sa.Column('raw_data', sa.JSON(), nullable=True),
|
||||
sa.Column('is_processed', sa.Boolean(), nullable=False),
|
||||
sa.Column('processing_error', sa.Text(), nullable=True),
|
||||
sa.Column('is_duplicate', sa.Boolean(), nullable=False),
|
||||
sa.Column('duplicate_of', sa.UUID(), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
|
||||
sa.ForeignKeyConstraint(['pos_config_id'], ['pos_configurations.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index('idx_pos_transaction_customer', 'pos_transactions', ['customer_id'], unique=False)
|
||||
op.create_index('idx_pos_transaction_duplicate', 'pos_transactions', ['is_duplicate'], unique=False)
|
||||
op.create_index('idx_pos_transaction_external_id', 'pos_transactions', ['pos_system', 'external_transaction_id'], unique=False)
|
||||
op.create_index('idx_pos_transaction_location', 'pos_transactions', ['location_id'], unique=False)
|
||||
op.create_index('idx_pos_transaction_processed', 'pos_transactions', ['is_processed'], unique=False)
|
||||
op.create_index('idx_pos_transaction_status', 'pos_transactions', ['status'], unique=False)
|
||||
op.create_index('idx_pos_transaction_sync_status', 'pos_transactions', ['is_synced_to_sales'], unique=False)
|
||||
op.create_index('idx_pos_transaction_tenant_date', 'pos_transactions', ['tenant_id', 'transaction_date'], unique=False)
|
||||
op.create_index('idx_pos_transaction_type', 'pos_transactions', ['transaction_type'], unique=False)
|
||||
op.create_index(op.f('ix_pos_transactions_external_order_id'), 'pos_transactions', ['external_order_id'], unique=False)
|
||||
op.create_index(op.f('ix_pos_transactions_external_transaction_id'), 'pos_transactions', ['external_transaction_id'], unique=False)
|
||||
op.create_index(op.f('ix_pos_transactions_id'), 'pos_transactions', ['id'], unique=False)
|
||||
op.create_index(op.f('ix_pos_transactions_is_synced_to_sales'), 'pos_transactions', ['is_synced_to_sales'], unique=False)
|
||||
op.create_index(op.f('ix_pos_transactions_pos_config_id'), 'pos_transactions', ['pos_config_id'], unique=False)
|
||||
op.create_index(op.f('ix_pos_transactions_pos_system'), 'pos_transactions', ['pos_system'], unique=False)
|
||||
op.create_index(op.f('ix_pos_transactions_sales_record_id'), 'pos_transactions', ['sales_record_id'], unique=False)
|
||||
op.create_index(op.f('ix_pos_transactions_tenant_id'), 'pos_transactions', ['tenant_id'], unique=False)
|
||||
op.create_index(op.f('ix_pos_transactions_transaction_date'), 'pos_transactions', ['transaction_date'], unique=False)
|
||||
op.create_table('pos_transaction_items',
|
||||
sa.Column('id', sa.UUID(), nullable=False),
|
||||
sa.Column('transaction_id', sa.UUID(), nullable=False),
|
||||
sa.Column('tenant_id', sa.UUID(), nullable=False),
|
||||
sa.Column('external_item_id', sa.String(length=255), nullable=True),
|
||||
sa.Column('sku', sa.String(length=100), nullable=True),
|
||||
sa.Column('product_name', sa.String(length=255), nullable=False),
|
||||
sa.Column('product_category', sa.String(length=100), nullable=True),
|
||||
sa.Column('product_subcategory', sa.String(length=100), nullable=True),
|
||||
sa.Column('quantity', sa.Numeric(precision=10, scale=3), nullable=False),
|
||||
sa.Column('unit_price', sa.Numeric(precision=10, scale=2), nullable=False),
|
||||
sa.Column('total_price', sa.Numeric(precision=10, scale=2), nullable=False),
|
||||
sa.Column('discount_amount', sa.Numeric(precision=10, scale=2), nullable=False),
|
||||
sa.Column('tax_amount', sa.Numeric(precision=10, scale=2), nullable=False),
|
||||
sa.Column('modifiers', sa.JSON(), nullable=True),
|
||||
sa.Column('inventory_product_id', sa.UUID(), nullable=True),
|
||||
sa.Column('is_mapped_to_inventory', sa.Boolean(), nullable=False),
|
||||
sa.Column('is_synced_to_sales', sa.Boolean(), nullable=False),
|
||||
sa.Column('sync_error', sa.Text(), nullable=True),
|
||||
sa.Column('raw_data', sa.JSON(), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
|
||||
sa.ForeignKeyConstraint(['transaction_id'], ['pos_transactions.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index('idx_pos_item_category', 'pos_transaction_items', ['product_category'], unique=False)
|
||||
op.create_index('idx_pos_item_inventory', 'pos_transaction_items', ['inventory_product_id'], unique=False)
|
||||
op.create_index('idx_pos_item_mapped', 'pos_transaction_items', ['is_mapped_to_inventory'], unique=False)
|
||||
op.create_index('idx_pos_item_product', 'pos_transaction_items', ['product_name'], unique=False)
|
||||
op.create_index('idx_pos_item_sku', 'pos_transaction_items', ['sku'], unique=False)
|
||||
op.create_index('idx_pos_item_sync', 'pos_transaction_items', ['is_synced_to_sales'], unique=False)
|
||||
op.create_index('idx_pos_item_transaction', 'pos_transaction_items', ['transaction_id'], unique=False)
|
||||
op.create_index(op.f('ix_pos_transaction_items_id'), 'pos_transaction_items', ['id'], unique=False)
|
||||
op.create_index(op.f('ix_pos_transaction_items_inventory_product_id'), 'pos_transaction_items', ['inventory_product_id'], unique=False)
|
||||
op.create_index(op.f('ix_pos_transaction_items_product_category'), 'pos_transaction_items', ['product_category'], unique=False)
|
||||
op.create_index(op.f('ix_pos_transaction_items_sku'), 'pos_transaction_items', ['sku'], unique=False)
|
||||
op.create_index(op.f('ix_pos_transaction_items_tenant_id'), 'pos_transaction_items', ['tenant_id'], unique=False)
|
||||
op.create_index(op.f('ix_pos_transaction_items_transaction_id'), 'pos_transaction_items', ['transaction_id'], unique=False)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_index(op.f('ix_pos_transaction_items_transaction_id'), table_name='pos_transaction_items')
|
||||
op.drop_index(op.f('ix_pos_transaction_items_tenant_id'), table_name='pos_transaction_items')
|
||||
op.drop_index(op.f('ix_pos_transaction_items_sku'), table_name='pos_transaction_items')
|
||||
op.drop_index(op.f('ix_pos_transaction_items_product_category'), table_name='pos_transaction_items')
|
||||
op.drop_index(op.f('ix_pos_transaction_items_inventory_product_id'), table_name='pos_transaction_items')
|
||||
op.drop_index(op.f('ix_pos_transaction_items_id'), table_name='pos_transaction_items')
|
||||
op.drop_index('idx_pos_item_transaction', table_name='pos_transaction_items')
|
||||
op.drop_index('idx_pos_item_sync', table_name='pos_transaction_items')
|
||||
op.drop_index('idx_pos_item_sku', table_name='pos_transaction_items')
|
||||
op.drop_index('idx_pos_item_product', table_name='pos_transaction_items')
|
||||
op.drop_index('idx_pos_item_mapped', table_name='pos_transaction_items')
|
||||
op.drop_index('idx_pos_item_inventory', table_name='pos_transaction_items')
|
||||
op.drop_index('idx_pos_item_category', table_name='pos_transaction_items')
|
||||
op.drop_table('pos_transaction_items')
|
||||
op.drop_index(op.f('ix_pos_transactions_transaction_date'), table_name='pos_transactions')
|
||||
op.drop_index(op.f('ix_pos_transactions_tenant_id'), table_name='pos_transactions')
|
||||
op.drop_index(op.f('ix_pos_transactions_sales_record_id'), table_name='pos_transactions')
|
||||
op.drop_index(op.f('ix_pos_transactions_pos_system'), table_name='pos_transactions')
|
||||
op.drop_index(op.f('ix_pos_transactions_pos_config_id'), table_name='pos_transactions')
|
||||
op.drop_index(op.f('ix_pos_transactions_is_synced_to_sales'), table_name='pos_transactions')
|
||||
op.drop_index(op.f('ix_pos_transactions_id'), table_name='pos_transactions')
|
||||
op.drop_index(op.f('ix_pos_transactions_external_transaction_id'), table_name='pos_transactions')
|
||||
op.drop_index(op.f('ix_pos_transactions_external_order_id'), table_name='pos_transactions')
|
||||
op.drop_index('idx_pos_transaction_type', table_name='pos_transactions')
|
||||
op.drop_index('idx_pos_transaction_tenant_date', table_name='pos_transactions')
|
||||
op.drop_index('idx_pos_transaction_sync_status', table_name='pos_transactions')
|
||||
op.drop_index('idx_pos_transaction_status', table_name='pos_transactions')
|
||||
op.drop_index('idx_pos_transaction_processed', table_name='pos_transactions')
|
||||
op.drop_index('idx_pos_transaction_location', table_name='pos_transactions')
|
||||
op.drop_index('idx_pos_transaction_external_id', table_name='pos_transactions')
|
||||
op.drop_index('idx_pos_transaction_duplicate', table_name='pos_transactions')
|
||||
op.drop_index('idx_pos_transaction_customer', table_name='pos_transactions')
|
||||
op.drop_table('pos_transactions')
|
||||
op.drop_index(op.f('ix_pos_webhook_logs_webhook_type'), table_name='pos_webhook_logs')
|
||||
op.drop_index(op.f('ix_pos_webhook_logs_transaction_id'), table_name='pos_webhook_logs')
|
||||
op.drop_index(op.f('ix_pos_webhook_logs_tenant_id'), table_name='pos_webhook_logs')
|
||||
op.drop_index(op.f('ix_pos_webhook_logs_status'), table_name='pos_webhook_logs')
|
||||
op.drop_index(op.f('ix_pos_webhook_logs_received_at'), table_name='pos_webhook_logs')
|
||||
op.drop_index(op.f('ix_pos_webhook_logs_pos_system'), table_name='pos_webhook_logs')
|
||||
op.drop_index(op.f('ix_pos_webhook_logs_order_id'), table_name='pos_webhook_logs')
|
||||
op.drop_index(op.f('ix_pos_webhook_logs_is_duplicate'), table_name='pos_webhook_logs')
|
||||
op.drop_index(op.f('ix_pos_webhook_logs_id'), table_name='pos_webhook_logs')
|
||||
op.drop_index(op.f('ix_pos_webhook_logs_event_id'), table_name='pos_webhook_logs')
|
||||
op.drop_index('idx_webhook_transaction_id', table_name='pos_webhook_logs')
|
||||
op.drop_index('idx_webhook_tenant_received', table_name='pos_webhook_logs')
|
||||
op.drop_index('idx_webhook_status', table_name='pos_webhook_logs')
|
||||
op.drop_index('idx_webhook_signature_valid', table_name='pos_webhook_logs')
|
||||
op.drop_index('idx_webhook_retry', table_name='pos_webhook_logs')
|
||||
op.drop_index('idx_webhook_received_at', table_name='pos_webhook_logs')
|
||||
op.drop_index('idx_webhook_priority', table_name='pos_webhook_logs')
|
||||
op.drop_index('idx_webhook_pos_system_type', table_name='pos_webhook_logs')
|
||||
op.drop_index('idx_webhook_order_id', table_name='pos_webhook_logs')
|
||||
op.drop_index('idx_webhook_event_id', table_name='pos_webhook_logs')
|
||||
op.drop_index('idx_webhook_duplicate', table_name='pos_webhook_logs')
|
||||
op.drop_table('pos_webhook_logs')
|
||||
op.drop_index(op.f('ix_pos_sync_logs_tenant_id'), table_name='pos_sync_logs')
|
||||
op.drop_index(op.f('ix_pos_sync_logs_sync_type'), table_name='pos_sync_logs')
|
||||
op.drop_index(op.f('ix_pos_sync_logs_status'), table_name='pos_sync_logs')
|
||||
op.drop_index(op.f('ix_pos_sync_logs_started_at'), table_name='pos_sync_logs')
|
||||
op.drop_index(op.f('ix_pos_sync_logs_pos_system'), table_name='pos_sync_logs')
|
||||
op.drop_index(op.f('ix_pos_sync_logs_pos_config_id'), table_name='pos_sync_logs')
|
||||
op.drop_index(op.f('ix_pos_sync_logs_id'), table_name='pos_sync_logs')
|
||||
op.drop_index(op.f('ix_pos_sync_logs_data_type'), table_name='pos_sync_logs')
|
||||
op.drop_index('idx_sync_log_webhook', table_name='pos_sync_logs')
|
||||
op.drop_index('idx_sync_log_trigger', table_name='pos_sync_logs')
|
||||
op.drop_index('idx_sync_log_tenant_started', table_name='pos_sync_logs')
|
||||
op.drop_index('idx_sync_log_status', table_name='pos_sync_logs')
|
||||
op.drop_index('idx_sync_log_retry', table_name='pos_sync_logs')
|
||||
op.drop_index('idx_sync_log_pos_system_type', table_name='pos_sync_logs')
|
||||
op.drop_index('idx_sync_log_parent', table_name='pos_sync_logs')
|
||||
op.drop_index('idx_sync_log_external_batch', table_name='pos_sync_logs')
|
||||
op.drop_index('idx_sync_log_duration', table_name='pos_sync_logs')
|
||||
op.drop_index('idx_sync_log_data_type', table_name='pos_sync_logs')
|
||||
op.drop_index('idx_sync_log_completed', table_name='pos_sync_logs')
|
||||
op.drop_table('pos_sync_logs')
|
||||
op.drop_index(op.f('ix_pos_configurations_tenant_id'), table_name='pos_configurations')
|
||||
op.drop_index(op.f('ix_pos_configurations_id'), table_name='pos_configurations')
|
||||
op.drop_index('idx_pos_config_tenant_pos_system', table_name='pos_configurations')
|
||||
op.drop_index('idx_pos_config_sync_enabled', table_name='pos_configurations')
|
||||
op.drop_index('idx_pos_config_health_status', table_name='pos_configurations')
|
||||
op.drop_index('idx_pos_config_created_at', table_name='pos_configurations')
|
||||
op.drop_index('idx_pos_config_connected', table_name='pos_configurations')
|
||||
op.drop_index('idx_pos_config_active', table_name='pos_configurations')
|
||||
op.drop_table('pos_configurations')
|
||||
# ### end Alembic commands ###
|
||||
Reference in New Issue
Block a user