"""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')