"""merge_identity_v1 Revision ID: fba92ed020b1 Revises: 5aed26900f0b Create Date: 2026-02-04 21:31:43.854642 """ from typing import Sequence, Union from alembic import op import sqlalchemy as sa from sqlalchemy.dialects import postgresql # revision identifiers, used by Alembic. revision: str = 'fba92ed020b1' down_revision: Union[str, Sequence[str], None] = '5aed26900f0b' branch_labels: Union[str, Sequence[str], None] = None depends_on: Union[str, Sequence[str], None] = None def upgrade() -> None: """Upgrade schema.""" # ### commands auto generated by Alembic - please adjust! ### op.drop_table('user_vehicle_equipment') op.drop_table('credit_logs') op.drop_table('votes') op.drop_table('audit_logs') op.drop_index(op.f('ix_data_level_configs_id'), table_name='level_configs') op.drop_table('level_configs') op.drop_table('vouchers') op.drop_index(op.f('ix_data_verification_tokens_id'), table_name='verification_tokens') op.drop_index(op.f('ix_data_verification_tokens_token'), table_name='verification_tokens') op.drop_index(op.f('ix_verification_tokens_lookup'), table_name='verification_tokens') op.drop_index(op.f('ix_verification_tokens_user'), table_name='verification_tokens') op.drop_index(op.f('uq_verification_tokens_token_hash'), table_name='verification_tokens', postgresql_where='(token_hash IS NOT NULL)') op.drop_table('verification_tokens') op.drop_index(op.f('ix_data_regional_settings_id'), table_name='regional_settings') op.drop_table('regional_settings') op.drop_index(op.f('ix_data_vehicle_ownership_id'), table_name='vehicle_ownership') op.drop_table('vehicle_ownership') op.drop_table('user_scores') op.drop_index(op.f('idx_vm_slug'), table_name='vehicle_models') op.drop_index(op.f('ix_data_vehicle_models_id'), table_name='vehicle_models') op.drop_table('vehicle_models') op.drop_index(op.f('ix_data_email_templates_id'), table_name='email_templates') op.drop_index(op.f('ix_data_email_templates_type'), table_name='email_templates') op.drop_table('email_templates') op.drop_index(op.f('ix_data_points_ledger_id'), table_name='points_ledger') op.drop_table('points_ledger') op.drop_table('bot_discovery_logs') op.drop_table('equipment_items') op.drop_index(op.f('ix_data_organization_members_id'), table_name='organization_members') op.drop_table('organization_members') op.drop_index(op.f('idx_settings_lookup'), table_name='system_settings') op.drop_index(op.f('ix_data_system_settings_key'), table_name='system_settings') op.drop_table('system_settings') op.drop_table('user_credits') op.drop_table('referrals') op.drop_index(op.f('ix_data_vehicle_variants_id'), table_name='vehicle_variants') op.drop_table('vehicle_variants') op.drop_table('subscription_notification_rules') op.drop_index(op.f('ix_data_badges_id'), table_name='badges') op.drop_table('badges') op.drop_index(op.f('ix_data_legal_acceptances_id'), table_name='legal_acceptances') op.drop_table('legal_acceptances') op.drop_table('service_specialties') op.drop_table('competitions') op.drop_table('credit_transactions') op.drop_table('locations') op.drop_index(op.f('ix_data_legal_documents_id'), table_name='legal_documents') op.drop_table('legal_documents') op.drop_table('email_providers') op.drop_table('subscription_tiers') op.drop_index(op.f('ix_data_email_logs_email'), table_name='email_logs') op.drop_index(op.f('ix_data_email_logs_id'), table_name='email_logs') op.drop_table('email_logs') op.drop_table('organization_locations') op.drop_table('vehicle_events') op.drop_table('vehicle_expenses') op.drop_table('credit_rules') op.drop_index(op.f('ix_data_email_provider_configs_id'), table_name='email_provider_configs') op.drop_table('email_provider_configs') op.drop_table('org_subscriptions') op.drop_index(op.f('ix_data_user_badges_id'), table_name='user_badges') op.drop_table('user_badges') op.drop_index(op.f('idx_vc_slug'), table_name='vehicle_categories') op.drop_index(op.f('ix_data_vehicle_categories_id'), table_name='vehicle_categories') op.drop_table('vehicle_categories') op.drop_index(op.f('ix_data_user_vehicles_id'), table_name='user_vehicles') op.drop_index(op.f('ix_data_user_vehicles_license_plate'), table_name='user_vehicles') op.drop_index(op.f('ix_data_user_vehicles_vin'), table_name='user_vehicles') op.drop_table('user_vehicles') op.drop_table('fuel_stations') op.drop_table('alembic_version') op.drop_index(op.f('ix_data_translations_id'), table_name='translations') op.drop_index(op.f('ix_data_translations_key'), table_name='translations') op.drop_index(op.f('ix_data_translations_lang_code'), table_name='translations') op.drop_table('translations') op.drop_table('service_reviews') op.drop_index(op.f('ix_data_user_stats_id'), table_name='user_stats') op.drop_table('user_stats') op.drop_index(op.f('ix_data_point_rules_action_key'), table_name='point_rules') op.drop_index(op.f('ix_data_point_rules_id'), table_name='point_rules') op.drop_table('point_rules') op.drop_index(op.f('ix_companies_owner_person_id'), table_name='companies') op.create_index(op.f('ix_data_companies_id'), 'companies', ['id'], unique=False, schema='data') op.drop_constraint(op.f('fk_companies_owner_person'), 'companies', type_='foreignkey') op.drop_constraint(op.f('companies_owner_id_fkey'), 'companies', type_='foreignkey') op.create_foreign_key(None, 'companies', 'users', ['owner_id'], ['id'], source_schema='data', referent_schema='data') op.drop_column('companies', 'owner_person_id') op.alter_column('company_members', 'role', existing_type=sa.VARCHAR(length=50), type_=postgresql.ENUM('owner', 'manager', 'driver', name='companyrole', schema='data'), nullable=False, existing_server_default=sa.text("'driver'::companyrole")) op.create_index(op.f('ix_data_company_members_id'), 'company_members', ['id'], unique=False, schema='data') op.drop_constraint(op.f('company_members_company_id_fkey'), 'company_members', type_='foreignkey') op.drop_constraint(op.f('company_members_user_id_fkey'), 'company_members', type_='foreignkey') op.create_foreign_key(None, 'company_members', 'users', ['user_id'], ['id'], source_schema='data', referent_schema='data') op.create_foreign_key(None, 'company_members', 'companies', ['company_id'], ['id'], source_schema='data', referent_schema='data') op.drop_index(op.f('idx_engine_code'), table_name='engine_specs') op.create_index(op.f('ix_data_engine_specs_id'), 'engine_specs', ['id'], unique=False, schema='data') op.create_unique_constraint(None, 'engine_specs', ['engine_code'], schema='data') op.drop_column('engine_specs', 'emissions_class') op.drop_column('engine_specs', 'phases') op.drop_column('engine_specs', 'default_service_interval_hours') op.drop_column('engine_specs', 'onboard_charger_kw') op.drop_column('engine_specs', 'battery_capacity_kwh') op.drop_index(op.f('idx_org_slug'), table_name='organizations') op.drop_index(op.f('ix_data_organizations_tax_number'), table_name='organizations') op.drop_constraint(op.f('organizations_owner_id_fkey'), 'organizations', type_='foreignkey') op.create_foreign_key(None, 'organizations', 'users', ['owner_id'], ['id'], source_schema='data', referent_schema='data') op.drop_column('organizations', 'theme') op.drop_column('organizations', 'validation_status') op.drop_column('organizations', 'founded_at') op.drop_column('organizations', 'ui_theme') op.drop_column('organizations', 'tax_number') op.drop_column('organizations', 'slug') op.drop_column('organizations', 'country_code') op.add_column('persons', sa.Column('id_uuid', sa.UUID(), nullable=False)) op.add_column('persons', sa.Column('last_name', sa.String(), nullable=False)) op.add_column('persons', sa.Column('first_name', sa.String(), nullable=False)) op.add_column('persons', sa.Column('mothers_name', sa.String(), nullable=True)) op.add_column('persons', sa.Column('birth_place', sa.String(), nullable=True)) op.add_column('persons', sa.Column('birth_date', sa.DateTime(), nullable=True)) op.add_column('persons', sa.Column('identity_docs', sa.JSON(), server_default=sa.text("'{}'::jsonb"), nullable=True)) op.add_column('persons', sa.Column('medical_emergency', sa.JSON(), server_default=sa.text("'{}'::jsonb"), nullable=True)) op.add_column('persons', sa.Column('ice_contact', sa.JSON(), server_default=sa.text("'{}'::jsonb"), nullable=True)) op.alter_column('persons', 'id', existing_type=sa.BIGINT(), type_=sa.Integer(), existing_nullable=False, autoincrement=True) op.create_index(op.f('ix_data_persons_id'), 'persons', ['id'], unique=False, schema='data') op.create_unique_constraint(None, 'persons', ['id_uuid'], schema='data') op.drop_column('persons', 'updated_at') op.drop_column('persons', 'is_active') op.drop_column('persons', 'reputation_score') op.drop_column('persons', 'created_at') op.drop_column('persons', 'risk_level') op.alter_column('service_providers', 'search_tags', existing_type=sa.TEXT(), type_=sa.String(), existing_nullable=True) op.create_index(op.f('ix_data_service_providers_id'), 'service_providers', ['id'], unique=False, schema='data') op.drop_column('service_providers', 'handled_vehicle_types') op.drop_column('service_providers', 'verification_status') op.drop_column('service_providers', 'specialized_brands') op.drop_constraint(op.f('service_records_provider_id_fkey'), 'service_records', type_='foreignkey') op.drop_constraint(op.f('service_records_vehicle_id_fkey'), 'service_records', type_='foreignkey') op.create_foreign_key(None, 'service_records', 'service_providers', ['provider_id'], ['id'], source_schema='data', referent_schema='data') op.create_foreign_key(None, 'service_records', 'vehicles', ['vehicle_id'], ['id'], source_schema='data', referent_schema='data') op.drop_column('service_records', 'invoice_path') op.drop_column('service_records', 'parts_quality_index') op.drop_column('service_records', 'description') op.drop_column('service_records', 'is_accident_repair') op.drop_column('service_records', 'rating_impact_score') op.alter_column('users', 'hashed_password', existing_type=sa.VARCHAR(), nullable=False) op.alter_column('users', 'role', existing_type=sa.VARCHAR(), type_=sa.Enum('ADMIN', 'USER', 'SERVICE', 'FLEET_MANAGER', name='userrole'), existing_nullable=True, existing_server_default=sa.text("'user'::character varying")) op.alter_column('users', 'is_deleted', existing_type=sa.BOOLEAN(), nullable=True, existing_server_default=sa.text('false')) op.alter_column('users', 'deleted_at', existing_type=postgresql.TIMESTAMP(timezone=True), type_=sa.DateTime(), existing_nullable=True) op.alter_column('users', 'person_id', existing_type=sa.BIGINT(), type_=sa.Integer(), existing_nullable=True) op.drop_index(op.f('idx_user_email_active_only'), table_name='users', postgresql_where='((is_deleted IS FALSE) AND (deleted_at IS NULL))') op.drop_index(op.f('ix_users_is_deleted'), table_name='users') op.drop_index(op.f('ix_users_person_id'), table_name='users') op.create_index(op.f('ix_data_users_email'), 'users', ['email'], unique=True, schema='data') op.drop_constraint(op.f('fk_users_person'), 'users', type_='foreignkey') op.create_foreign_key(None, 'users', 'persons', ['person_id'], ['id'], source_schema='data', referent_schema='data') op.drop_column('users', 'previous_login_count') op.drop_column('users', 'first_name') op.drop_column('users', 'is_gdpr_deleted') op.drop_column('users', 'verified_at') op.drop_column('users', 'is_banned') op.drop_column('users', 'birthday') op.drop_column('users', 'last_name') op.alter_column('vehicle_assignments', 'vehicle_id', existing_type=sa.INTEGER(), type_=sa.UUID(), existing_nullable=False) op.drop_constraint(op.f('vehicle_assignments_company_id_fkey'), 'vehicle_assignments', type_='foreignkey') op.drop_constraint(op.f('vehicle_assignments_vehicle_id_fkey'), 'vehicle_assignments', type_='foreignkey') op.drop_constraint(op.f('vehicle_assignments_driver_id_fkey'), 'vehicle_assignments', type_='foreignkey') op.create_foreign_key(None, 'vehicle_assignments', 'companies', ['company_id'], ['id'], source_schema='data', referent_schema='data') op.create_foreign_key(None, 'vehicle_assignments', 'vehicles', ['vehicle_id'], ['id'], source_schema='data', referent_schema='data') op.create_foreign_key(None, 'vehicle_assignments', 'users', ['driver_id'], ['id'], source_schema='data', referent_schema='data') op.drop_index(op.f('idx_vb_slug'), table_name='vehicle_brands') op.drop_constraint(op.f('vehicle_brands_cat_name_key'), 'vehicle_brands', type_='unique') op.create_unique_constraint(None, 'vehicle_brands', ['slug'], schema='data') op.drop_constraint(op.f('vehicle_brands_category_id_fkey'), 'vehicle_brands', type_='foreignkey') op.drop_column('vehicle_brands', 'country_code') op.drop_column('vehicle_brands', 'category_id') op.drop_column('vehicle_brands', 'origin_country') op.drop_index(op.f('idx_vehicle_company'), table_name='vehicles') op.drop_index(op.f('idx_vehicle_plate'), table_name='vehicles') op.drop_index(op.f('idx_vehicle_vin'), table_name='vehicles') op.drop_constraint(op.f('vehicles_engine_spec_id_fkey'), 'vehicles', type_='foreignkey') op.drop_constraint(op.f('vehicles_current_company_id_fkey'), 'vehicles', type_='foreignkey') op.drop_constraint(op.f('fk_vehicle_brand'), 'vehicles', type_='foreignkey') op.create_foreign_key(None, 'vehicles', 'engine_specs', ['engine_spec_id'], ['id'], source_schema='data', referent_schema='data') op.create_foreign_key(None, 'vehicles', 'vehicle_brands', ['brand_id'], ['id'], source_schema='data', referent_schema='data') op.create_foreign_key(None, 'vehicles', 'companies', ['current_company_id'], ['id'], source_schema='data', referent_schema='data') op.drop_column('vehicles', 'custom_specs') op.drop_column('vehicles', 'odometer_at_last_check') op.drop_column('vehicles', 'factory_snapshot') op.alter_column('wallets', 'id', existing_type=sa.BIGINT(), type_=sa.Integer(), existing_nullable=False, autoincrement=True) op.alter_column('wallets', 'user_id', existing_type=sa.INTEGER(), nullable=True) op.alter_column('wallets', 'xp_balance', existing_type=sa.BIGINT(), type_=sa.Integer(), existing_nullable=True, existing_server_default=sa.text('0')) op.create_index(op.f('ix_data_wallets_id'), 'wallets', ['id'], unique=False, schema='data') op.drop_constraint(op.f('wallets_user_id_fkey'), 'wallets', type_='foreignkey') op.create_foreign_key(None, 'wallets', 'users', ['user_id'], ['id'], source_schema='data', referent_schema='data') op.drop_column('wallets', 'updated_at') op.drop_column('wallets', 'created_at') # ### end Alembic commands ### def downgrade() -> None: """Downgrade schema.""" # ### commands auto generated by Alembic - please adjust! ### op.add_column('wallets', sa.Column('created_at', postgresql.TIMESTAMP(timezone=True), server_default=sa.text('now()'), autoincrement=False, nullable=True)) op.add_column('wallets', sa.Column('updated_at', postgresql.TIMESTAMP(timezone=True), server_default=sa.text('now()'), autoincrement=False, nullable=True)) op.drop_constraint(None, 'wallets', schema='data', type_='foreignkey') op.create_foreign_key(op.f('wallets_user_id_fkey'), 'wallets', 'users', ['user_id'], ['id']) op.drop_index(op.f('ix_data_wallets_id'), table_name='wallets', schema='data') op.alter_column('wallets', 'xp_balance', existing_type=sa.Integer(), type_=sa.BIGINT(), existing_nullable=True, existing_server_default=sa.text('0')) op.alter_column('wallets', 'user_id', existing_type=sa.INTEGER(), nullable=False) op.alter_column('wallets', 'id', existing_type=sa.Integer(), type_=sa.BIGINT(), existing_nullable=False, autoincrement=True) op.add_column('vehicles', sa.Column('factory_snapshot', postgresql.JSONB(astext_type=sa.Text()), autoincrement=False, nullable=True)) op.add_column('vehicles', sa.Column('odometer_at_last_check', sa.NUMERIC(precision=15, scale=2), server_default=sa.text('0'), autoincrement=False, nullable=True)) op.add_column('vehicles', sa.Column('custom_specs', postgresql.JSONB(astext_type=sa.Text()), server_default=sa.text("'{}'::jsonb"), autoincrement=False, nullable=True)) op.drop_constraint(None, 'vehicles', schema='data', type_='foreignkey') op.drop_constraint(None, 'vehicles', schema='data', type_='foreignkey') op.drop_constraint(None, 'vehicles', schema='data', type_='foreignkey') op.create_foreign_key(op.f('fk_vehicle_brand'), 'vehicles', 'vehicle_brands', ['brand_id'], ['id']) op.create_foreign_key(op.f('vehicles_current_company_id_fkey'), 'vehicles', 'companies', ['current_company_id'], ['id']) op.create_foreign_key(op.f('vehicles_engine_spec_id_fkey'), 'vehicles', 'engine_specs', ['engine_spec_id'], ['id']) op.create_index(op.f('idx_vehicle_vin'), 'vehicles', ['identification_number'], unique=False) op.create_index(op.f('idx_vehicle_plate'), 'vehicles', ['license_plate'], unique=False) op.create_index(op.f('idx_vehicle_company'), 'vehicles', ['current_company_id'], unique=False) op.add_column('vehicle_brands', sa.Column('origin_country', sa.VARCHAR(), autoincrement=False, nullable=True)) op.add_column('vehicle_brands', sa.Column('category_id', sa.INTEGER(), autoincrement=False, nullable=True)) op.add_column('vehicle_brands', sa.Column('country_code', sa.VARCHAR(), autoincrement=False, nullable=True)) op.create_foreign_key(op.f('vehicle_brands_category_id_fkey'), 'vehicle_brands', 'vehicle_categories', ['category_id'], ['id']) op.drop_constraint(None, 'vehicle_brands', schema='data', type_='unique') op.create_unique_constraint(op.f('vehicle_brands_cat_name_key'), 'vehicle_brands', ['category_id', 'name'], postgresql_nulls_not_distinct=False) op.create_index(op.f('idx_vb_slug'), 'vehicle_brands', ['slug'], unique=True) op.drop_constraint(None, 'vehicle_assignments', schema='data', type_='foreignkey') op.drop_constraint(None, 'vehicle_assignments', schema='data', type_='foreignkey') op.drop_constraint(None, 'vehicle_assignments', schema='data', type_='foreignkey') op.create_foreign_key(op.f('vehicle_assignments_driver_id_fkey'), 'vehicle_assignments', 'users', ['driver_id'], ['id']) op.create_foreign_key(op.f('vehicle_assignments_vehicle_id_fkey'), 'vehicle_assignments', 'user_vehicles', ['vehicle_id'], ['id']) op.create_foreign_key(op.f('vehicle_assignments_company_id_fkey'), 'vehicle_assignments', 'companies', ['company_id'], ['id']) op.alter_column('vehicle_assignments', 'vehicle_id', existing_type=sa.UUID(), type_=sa.INTEGER(), existing_nullable=False) op.add_column('users', sa.Column('last_name', sa.VARCHAR(), autoincrement=False, nullable=True)) op.add_column('users', sa.Column('birthday', sa.DATE(), autoincrement=False, nullable=True)) op.add_column('users', sa.Column('is_banned', sa.BOOLEAN(), autoincrement=False, nullable=True)) op.add_column('users', sa.Column('verified_at', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=True)) op.add_column('users', sa.Column('is_gdpr_deleted', sa.BOOLEAN(), autoincrement=False, nullable=True)) op.add_column('users', sa.Column('first_name', sa.VARCHAR(), autoincrement=False, nullable=True)) op.add_column('users', sa.Column('previous_login_count', sa.INTEGER(), autoincrement=False, nullable=True)) op.drop_constraint(None, 'users', schema='data', type_='foreignkey') op.create_foreign_key(op.f('fk_users_person'), 'users', 'persons', ['person_id'], ['id']) op.drop_index(op.f('ix_data_users_email'), table_name='users', schema='data') op.create_index(op.f('ix_users_person_id'), 'users', ['person_id'], unique=False) op.create_index(op.f('ix_users_is_deleted'), 'users', ['is_deleted', 'deleted_at'], unique=False) op.create_index(op.f('idx_user_email_active_only'), 'users', ['email'], unique=True, postgresql_where='((is_deleted IS FALSE) AND (deleted_at IS NULL))') op.alter_column('users', 'person_id', existing_type=sa.Integer(), type_=sa.BIGINT(), existing_nullable=True) op.alter_column('users', 'deleted_at', existing_type=sa.DateTime(), type_=postgresql.TIMESTAMP(timezone=True), existing_nullable=True) op.alter_column('users', 'is_deleted', existing_type=sa.BOOLEAN(), nullable=False, existing_server_default=sa.text('false')) op.alter_column('users', 'role', existing_type=sa.Enum('ADMIN', 'USER', 'SERVICE', 'FLEET_MANAGER', name='userrole'), type_=sa.VARCHAR(), existing_nullable=True, existing_server_default=sa.text("'user'::character varying")) op.alter_column('users', 'hashed_password', existing_type=sa.VARCHAR(), nullable=True) op.add_column('service_records', sa.Column('rating_impact_score', sa.INTEGER(), server_default=sa.text('0'), autoincrement=False, nullable=True)) op.add_column('service_records', sa.Column('is_accident_repair', sa.BOOLEAN(), server_default=sa.text('false'), autoincrement=False, nullable=True)) op.add_column('service_records', sa.Column('description', sa.TEXT(), autoincrement=False, nullable=True)) op.add_column('service_records', sa.Column('parts_quality_index', sa.NUMERIC(precision=3, scale=2), server_default=sa.text('1.0'), autoincrement=False, nullable=True)) op.add_column('service_records', sa.Column('invoice_path', sa.TEXT(), autoincrement=False, nullable=True)) op.drop_constraint(None, 'service_records', schema='data', type_='foreignkey') op.drop_constraint(None, 'service_records', schema='data', type_='foreignkey') op.create_foreign_key(op.f('service_records_vehicle_id_fkey'), 'service_records', 'vehicles', ['vehicle_id'], ['id']) op.create_foreign_key(op.f('service_records_provider_id_fkey'), 'service_records', 'service_providers', ['provider_id'], ['id']) op.add_column('service_providers', sa.Column('specialized_brands', postgresql.JSONB(astext_type=sa.Text()), server_default=sa.text("'[]'::jsonb"), autoincrement=False, nullable=True)) op.add_column('service_providers', sa.Column('verification_status', sa.VARCHAR(length=20), server_default=sa.text("'pending'::character varying"), autoincrement=False, nullable=True)) op.add_column('service_providers', sa.Column('handled_vehicle_types', postgresql.JSONB(astext_type=sa.Text()), server_default=sa.text('\'["passenger_car"]\'::jsonb'), autoincrement=False, nullable=True)) op.drop_index(op.f('ix_data_service_providers_id'), table_name='service_providers', schema='data') op.alter_column('service_providers', 'search_tags', existing_type=sa.String(), type_=sa.TEXT(), existing_nullable=True) op.add_column('persons', sa.Column('risk_level', sa.INTEGER(), server_default=sa.text('0'), autoincrement=False, nullable=False)) op.add_column('persons', sa.Column('created_at', postgresql.TIMESTAMP(timezone=True), server_default=sa.text('now()'), autoincrement=False, nullable=False)) op.add_column('persons', sa.Column('reputation_score', sa.NUMERIC(precision=10, scale=2), server_default=sa.text('0'), autoincrement=False, nullable=False)) op.add_column('persons', sa.Column('is_active', sa.BOOLEAN(), server_default=sa.text('true'), autoincrement=False, nullable=False)) op.add_column('persons', sa.Column('updated_at', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=True)) op.drop_constraint(None, 'persons', schema='data', type_='unique') op.drop_index(op.f('ix_data_persons_id'), table_name='persons', schema='data') op.alter_column('persons', 'id', existing_type=sa.Integer(), type_=sa.BIGINT(), existing_nullable=False, autoincrement=True) op.drop_column('persons', 'ice_contact') op.drop_column('persons', 'medical_emergency') op.drop_column('persons', 'identity_docs') op.drop_column('persons', 'birth_date') op.drop_column('persons', 'birth_place') op.drop_column('persons', 'mothers_name') op.drop_column('persons', 'first_name') op.drop_column('persons', 'last_name') op.drop_column('persons', 'id_uuid') op.add_column('organizations', sa.Column('country_code', sa.CHAR(length=2), server_default=sa.text("'HU'::bpchar"), autoincrement=False, nullable=True)) op.add_column('organizations', sa.Column('slug', sa.VARCHAR(length=100), autoincrement=False, nullable=True)) op.add_column('organizations', sa.Column('tax_number', sa.VARCHAR(), autoincrement=False, nullable=True)) op.add_column('organizations', sa.Column('ui_theme', sa.VARCHAR(), autoincrement=False, nullable=True)) op.add_column('organizations', sa.Column('founded_at', sa.DATE(), autoincrement=False, nullable=True)) op.add_column('organizations', sa.Column('validation_status', postgresql.ENUM('NOT_VALIDATED', 'PENDING', 'VALIDATED', 'REJECTED', name='validationstatus'), autoincrement=False, nullable=True)) op.add_column('organizations', sa.Column('theme', sa.VARCHAR(), server_default=sa.text("'system'::character varying"), autoincrement=False, nullable=True)) op.drop_constraint(None, 'organizations', schema='data', type_='foreignkey') op.create_foreign_key(op.f('organizations_owner_id_fkey'), 'organizations', 'users', ['owner_id'], ['id']) op.create_index(op.f('ix_data_organizations_tax_number'), 'organizations', ['tax_number'], unique=False) op.create_index(op.f('idx_org_slug'), 'organizations', ['slug'], unique=True) op.add_column('engine_specs', sa.Column('battery_capacity_kwh', sa.NUMERIC(precision=10, scale=2), autoincrement=False, nullable=True)) op.add_column('engine_specs', sa.Column('onboard_charger_kw', sa.NUMERIC(precision=5, scale=2), autoincrement=False, nullable=True)) op.add_column('engine_specs', sa.Column('default_service_interval_hours', sa.INTEGER(), server_default=sa.text('500'), autoincrement=False, nullable=True)) op.add_column('engine_specs', sa.Column('phases', sa.INTEGER(), server_default=sa.text('3'), autoincrement=False, nullable=True)) op.add_column('engine_specs', sa.Column('emissions_class', sa.VARCHAR(length=20), autoincrement=False, nullable=True)) op.drop_constraint(None, 'engine_specs', schema='data', type_='unique') op.drop_index(op.f('ix_data_engine_specs_id'), table_name='engine_specs', schema='data') op.create_index(op.f('idx_engine_code'), 'engine_specs', ['engine_code'], unique=False) op.drop_constraint(None, 'company_members', schema='data', type_='foreignkey') op.drop_constraint(None, 'company_members', schema='data', type_='foreignkey') op.create_foreign_key(op.f('company_members_user_id_fkey'), 'company_members', 'users', ['user_id'], ['id'], ondelete='CASCADE') op.create_foreign_key(op.f('company_members_company_id_fkey'), 'company_members', 'companies', ['company_id'], ['id'], ondelete='CASCADE') op.drop_index(op.f('ix_data_company_members_id'), table_name='company_members', schema='data') op.alter_column('company_members', 'role', existing_type=postgresql.ENUM('owner', 'manager', 'driver', name='companyrole', schema='data'), type_=sa.VARCHAR(length=50), nullable=True, existing_server_default=sa.text("'driver'::companyrole")) op.add_column('companies', sa.Column('owner_person_id', sa.BIGINT(), autoincrement=False, nullable=True)) op.drop_constraint(None, 'companies', schema='data', type_='foreignkey') op.create_foreign_key(op.f('companies_owner_id_fkey'), 'companies', 'users', ['owner_id'], ['id']) op.create_foreign_key(op.f('fk_companies_owner_person'), 'companies', 'persons', ['owner_person_id'], ['id']) op.drop_index(op.f('ix_data_companies_id'), table_name='companies', schema='data') op.create_index(op.f('ix_companies_owner_person_id'), 'companies', ['owner_person_id'], unique=False) op.create_table('point_rules', sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), sa.Column('action_key', sa.VARCHAR(), autoincrement=False, nullable=False), sa.Column('points', sa.INTEGER(), autoincrement=False, nullable=False), sa.Column('description', sa.VARCHAR(), autoincrement=False, nullable=True), sa.Column('is_active', sa.BOOLEAN(), autoincrement=False, nullable=False), sa.PrimaryKeyConstraint('id', name=op.f('point_rules_pkey')) ) op.create_index(op.f('ix_data_point_rules_id'), 'point_rules', ['id'], unique=False) op.create_index(op.f('ix_data_point_rules_action_key'), 'point_rules', ['action_key'], unique=True) op.create_table('user_stats', sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=False), sa.Column('total_points', sa.INTEGER(), autoincrement=False, nullable=False), sa.Column('current_level', sa.INTEGER(), autoincrement=False, nullable=False), sa.Column('last_activity', postgresql.TIMESTAMP(), autoincrement=False, nullable=False), sa.ForeignKeyConstraint(['user_id'], ['users.id'], name=op.f('user_stats_user_id_fkey')), sa.PrimaryKeyConstraint('id', name=op.f('user_stats_pkey')), sa.UniqueConstraint('user_id', name=op.f('user_stats_user_id_key'), postgresql_include=[], postgresql_nulls_not_distinct=False) ) op.create_index(op.f('ix_data_user_stats_id'), 'user_stats', ['id'], unique=False) op.create_table('service_reviews', sa.Column('id', sa.UUID(), server_default=sa.text('gen_random_uuid()'), autoincrement=False, nullable=False), sa.Column('provider_id', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('service_record_id', sa.UUID(), autoincrement=False, nullable=True), sa.Column('is_anonymous', sa.BOOLEAN(), server_default=sa.text('false'), autoincrement=False, nullable=True), sa.Column('overall_stars', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('detailed_ratings', postgresql.JSONB(astext_type=sa.Text()), server_default=sa.text('\'{"comm": 0, "tech": 0, "clean": 0, "price": 0}\'::jsonb'), autoincrement=False, nullable=True), sa.Column('comment', sa.TEXT(), autoincrement=False, nullable=True), sa.Column('created_at', postgresql.TIMESTAMP(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), autoincrement=False, nullable=True), sa.CheckConstraint('overall_stars >= 1 AND overall_stars <= 5', name=op.f('service_reviews_overall_stars_check')), sa.ForeignKeyConstraint(['provider_id'], ['service_providers.id'], name=op.f('service_reviews_provider_id_fkey')), sa.ForeignKeyConstraint(['service_record_id'], ['service_records.id'], name=op.f('service_reviews_service_record_id_fkey')), sa.ForeignKeyConstraint(['user_id'], ['users.id'], name=op.f('service_reviews_user_id_fkey')), sa.PrimaryKeyConstraint('id', name=op.f('service_reviews_pkey')), sa.UniqueConstraint('user_id', 'provider_id', 'created_at', name=op.f('service_reviews_user_id_provider_id_created_at_key'), postgresql_include=[], postgresql_nulls_not_distinct=False) ) op.create_table('translations', sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), sa.Column('key', sa.VARCHAR(length=100), autoincrement=False, nullable=False), sa.Column('lang_code', sa.VARCHAR(length=5), autoincrement=False, nullable=False), sa.Column('value', sa.TEXT(), autoincrement=False, nullable=False), sa.Column('is_published', sa.BOOLEAN(), autoincrement=False, nullable=True), sa.Column('lang', sa.VARCHAR(length=10), autoincrement=False, nullable=True), sa.PrimaryKeyConstraint('id', name=op.f('translations_pkey')), sa.UniqueConstraint('key', 'lang_code', name=op.f('uq_translation_key_lang'), postgresql_include=[], postgresql_nulls_not_distinct=False) ) op.create_index(op.f('ix_data_translations_lang_code'), 'translations', ['lang_code'], unique=False) op.create_index(op.f('ix_data_translations_key'), 'translations', ['key'], unique=False) op.create_index(op.f('ix_data_translations_id'), 'translations', ['id'], unique=False) op.create_table('alembic_version', sa.Column('version_num', sa.VARCHAR(length=32), autoincrement=False, nullable=False), sa.PrimaryKeyConstraint('version_num', name=op.f('alembic_version_pkc')) ) op.create_table('fuel_stations', sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), sa.Column('name', sa.VARCHAR(length=255), autoincrement=False, nullable=False), sa.Column('brand_name', sa.VARCHAR(length=100), autoincrement=False, nullable=True), sa.Column('location_city', sa.VARCHAR(length=100), autoincrement=False, nullable=True), sa.Column('latitude', sa.NUMERIC(precision=10, scale=8), autoincrement=False, nullable=True), sa.Column('longitude', sa.NUMERIC(precision=11, scale=8), autoincrement=False, nullable=True), sa.Column('amenities', postgresql.JSONB(astext_type=sa.Text()), server_default=sa.text('\'{"food": false, "shop": false, "car_wash": "none"}\'::jsonb'), autoincrement=False, nullable=True), sa.Column('fuel_types', postgresql.JSONB(astext_type=sa.Text()), server_default=sa.text('\'{"diesel": true, "petrol_95": true, "ev_fast_charge": false}\'::jsonb'), autoincrement=False, nullable=True), sa.Column('is_active', sa.BOOLEAN(), server_default=sa.text('true'), autoincrement=False, nullable=True), sa.PrimaryKeyConstraint('id', name=op.f('fuel_stations_pkey')) ) op.create_table('user_vehicles', sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), sa.Column('vin', sa.VARCHAR(), autoincrement=False, nullable=False), sa.Column('license_plate', sa.VARCHAR(), autoincrement=False, nullable=False), sa.Column('variant_id', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('color', sa.VARCHAR(), autoincrement=False, nullable=True), sa.Column('purchase_date', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), sa.Column('purchase_price', sa.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=True), sa.Column('current_odometer', sa.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=True), sa.Column('extras', postgresql.JSON(astext_type=sa.Text()), autoincrement=False, nullable=True), sa.Column('current_org_id', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('created_at', postgresql.TIMESTAMP(timezone=True), server_default=sa.text('now()'), autoincrement=False, nullable=True), sa.Column('is_deleted', sa.BOOLEAN(), autoincrement=False, nullable=True), sa.Column('tire_size_front', sa.VARCHAR(length=50), autoincrement=False, nullable=True), sa.Column('tire_size_rear', sa.VARCHAR(length=50), autoincrement=False, nullable=True), sa.Column('tire_dot_code', sa.VARCHAR(length=10), autoincrement=False, nullable=True), sa.Column('custom_service_interval_km', sa.INTEGER(), server_default=sa.text('20000'), autoincrement=False, nullable=True), sa.Column('last_service_km', sa.INTEGER(), server_default=sa.text('0'), autoincrement=False, nullable=True), sa.Column('vin_verified', sa.BOOLEAN(), server_default=sa.text('false'), autoincrement=False, nullable=True), sa.Column('vin_deadline', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), sa.ForeignKeyConstraint(['current_org_id'], ['organizations.id'], name=op.f('user_vehicles_current_org_id_fkey')), sa.ForeignKeyConstraint(['variant_id'], ['vehicle_variants.id'], name=op.f('user_vehicles_variant_id_fkey')), sa.PrimaryKeyConstraint('id', name=op.f('user_vehicles_pkey')) ) op.create_index(op.f('ix_data_user_vehicles_vin'), 'user_vehicles', ['vin'], unique=True) op.create_index(op.f('ix_data_user_vehicles_license_plate'), 'user_vehicles', ['license_plate'], unique=False) op.create_index(op.f('ix_data_user_vehicles_id'), 'user_vehicles', ['id'], unique=False) op.create_table('vehicle_categories', sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), sa.Column('name', sa.VARCHAR(), autoincrement=False, nullable=False), sa.Column('slug', sa.VARCHAR(), autoincrement=False, nullable=True), sa.PrimaryKeyConstraint('id', name=op.f('vehicle_categories_pkey')), sa.UniqueConstraint('name', name=op.f('vehicle_categories_name_key'), postgresql_include=[], postgresql_nulls_not_distinct=False) ) op.create_index(op.f('ix_data_vehicle_categories_id'), 'vehicle_categories', ['id'], unique=False) op.create_index(op.f('idx_vc_slug'), 'vehicle_categories', ['slug'], unique=True) op.create_table('user_badges', sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=False), sa.Column('badge_id', sa.INTEGER(), autoincrement=False, nullable=False), sa.Column('earned_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=False), sa.ForeignKeyConstraint(['badge_id'], ['badges.id'], name=op.f('user_badges_badge_id_fkey')), sa.ForeignKeyConstraint(['user_id'], ['users.id'], name=op.f('user_badges_user_id_fkey')), sa.PrimaryKeyConstraint('id', name=op.f('user_badges_pkey')) ) op.create_index(op.f('ix_data_user_badges_id'), 'user_badges', ['id'], unique=False) op.create_table('org_subscriptions', sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), sa.Column('org_id', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('tier_id', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('valid_from', postgresql.TIMESTAMP(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), autoincrement=False, nullable=True), sa.Column('valid_until', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=True), sa.Column('is_active', sa.BOOLEAN(), server_default=sa.text('true'), autoincrement=False, nullable=True), sa.Column('auto_renew', sa.BOOLEAN(), server_default=sa.text('true'), autoincrement=False, nullable=True), sa.Column('trial_ends_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), sa.ForeignKeyConstraint(['org_id'], ['organizations.id'], name=op.f('org_subscriptions_org_id_fkey')), sa.ForeignKeyConstraint(['tier_id'], ['subscription_tiers.id'], name=op.f('org_subscriptions_tier_id_fkey')), sa.PrimaryKeyConstraint('id', name=op.f('org_subscriptions_pkey')) ) op.create_table('email_provider_configs', sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), sa.Column('name', sa.VARCHAR(length=50), autoincrement=False, nullable=True), sa.Column('provider_type', sa.VARCHAR(length=20), autoincrement=False, nullable=True), sa.Column('priority', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('settings', postgresql.JSON(astext_type=sa.Text()), autoincrement=False, nullable=False), sa.Column('is_active', sa.BOOLEAN(), autoincrement=False, nullable=True), sa.Column('fail_count', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('max_fail_threshold', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('success_rate', sa.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=True), sa.PrimaryKeyConstraint('id', name=op.f('email_provider_configs_pkey')), sa.UniqueConstraint('name', name=op.f('email_provider_configs_name_key'), postgresql_include=[], postgresql_nulls_not_distinct=False) ) op.create_index(op.f('ix_data_email_provider_configs_id'), 'email_provider_configs', ['id'], unique=False) op.create_table('credit_rules', sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), sa.Column('rule_key', sa.VARCHAR(length=50), autoincrement=False, nullable=False), sa.Column('amount', sa.NUMERIC(precision=15, scale=2), autoincrement=False, nullable=False), sa.Column('label', sa.VARCHAR(length=100), autoincrement=False, nullable=True), sa.Column('is_active', sa.BOOLEAN(), server_default=sa.text('true'), autoincrement=False, nullable=True), sa.PrimaryKeyConstraint('id', name=op.f('credit_rules_pkey')), sa.UniqueConstraint('rule_key', name=op.f('credit_rules_rule_key_key'), postgresql_include=[], postgresql_nulls_not_distinct=False) ) op.create_table('vehicle_expenses', sa.Column('id', sa.UUID(), server_default=sa.text('gen_random_uuid()'), autoincrement=False, nullable=False), sa.Column('vehicle_id', sa.UUID(), autoincrement=False, nullable=False), sa.Column('category', postgresql.ENUM('PURCHASE_PRICE', 'TRANSFER_TAX', 'ADMIN_FEE', 'VEHICLE_TAX', 'INSURANCE', 'REFUELING', 'SERVICE', 'PARKING', 'TOLL', 'FINE', 'TUNING_ACCESSORIES', 'OTHER', name='expense_category_enum'), autoincrement=False, nullable=False), sa.Column('amount', sa.NUMERIC(precision=15, scale=2), autoincrement=False, nullable=False), sa.Column('date', sa.DATE(), server_default=sa.text('CURRENT_DATE'), autoincrement=False, nullable=True), sa.Column('odometer_value', sa.NUMERIC(precision=15, scale=2), autoincrement=False, nullable=True), sa.Column('description', sa.TEXT(), autoincrement=False, nullable=True), sa.Column('created_at', postgresql.TIMESTAMP(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), autoincrement=False, nullable=True), sa.ForeignKeyConstraint(['vehicle_id'], ['vehicles.id'], name=op.f('vehicle_expenses_vehicle_id_fkey')), sa.PrimaryKeyConstraint('id', name=op.f('vehicle_expenses_pkey')) ) op.create_table('vehicle_events', sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), sa.Column('vehicle_id', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('service_provider_id', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('event_type', sa.VARCHAR(length=100), autoincrement=False, nullable=True), sa.Column('description', sa.TEXT(), autoincrement=False, nullable=True), sa.Column('odometer_reading', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('event_date', postgresql.TIMESTAMP(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), autoincrement=False, nullable=True), sa.ForeignKeyConstraint(['vehicle_id'], ['user_vehicles.id'], name=op.f('vehicle_events_vehicle_id_fkey'), ondelete='CASCADE'), sa.PrimaryKeyConstraint('id', name=op.f('vehicle_events_pkey')) ) op.create_table('organization_locations', sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), sa.Column('organization_id', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('label', sa.VARCHAR(length=100), autoincrement=False, nullable=True), sa.Column('address', sa.TEXT(), autoincrement=False, nullable=True), sa.Column('latitude', sa.NUMERIC(precision=10, scale=8), autoincrement=False, nullable=True), sa.Column('longitude', sa.NUMERIC(precision=11, scale=8), autoincrement=False, nullable=True), sa.Column('is_main_location', sa.BOOLEAN(), server_default=sa.text('false'), autoincrement=False, nullable=True), sa.Column('created_at', postgresql.TIMESTAMP(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), autoincrement=False, nullable=True), sa.ForeignKeyConstraint(['organization_id'], ['organizations.id'], name=op.f('organization_locations_organization_id_fkey'), ondelete='CASCADE'), sa.PrimaryKeyConstraint('id', name=op.f('organization_locations_pkey')) ) op.create_table('email_logs', sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), sa.Column('email', sa.VARCHAR(), autoincrement=False, nullable=True), sa.Column('type', sa.VARCHAR(), autoincrement=False, nullable=True), sa.Column('sent_at', postgresql.TIMESTAMP(timezone=True), server_default=sa.text('now()'), autoincrement=False, nullable=True), sa.Column('recipient', sa.VARCHAR(length=255), autoincrement=False, nullable=True), sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('provider_id', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('status', sa.VARCHAR(length=50), server_default=sa.text("'sent'::character varying"), autoincrement=False, nullable=True), sa.Column('email_type', sa.VARCHAR(length=100), autoincrement=False, nullable=True), sa.PrimaryKeyConstraint('id', name=op.f('email_logs_pkey')) ) op.create_index(op.f('ix_data_email_logs_id'), 'email_logs', ['id'], unique=False) op.create_index(op.f('ix_data_email_logs_email'), 'email_logs', ['email'], unique=False) op.create_table('subscription_tiers', sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), sa.Column('name', sa.VARCHAR(length=50), autoincrement=False, nullable=True), sa.Column('rules', postgresql.JSONB(astext_type=sa.Text()), autoincrement=False, nullable=True), sa.Column('is_custom', sa.BOOLEAN(), server_default=sa.text('false'), autoincrement=False, nullable=True), sa.Column('description', sa.TEXT(), autoincrement=False, nullable=True), sa.PrimaryKeyConstraint('id', name=op.f('subscription_tiers_pkey')), sa.UniqueConstraint('name', name=op.f('subscription_tiers_name_key'), postgresql_include=[], postgresql_nulls_not_distinct=False) ) op.create_table('email_providers', sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), sa.Column('name', sa.VARCHAR(length=50), autoincrement=False, nullable=False), sa.Column('priority', sa.INTEGER(), server_default=sa.text('1'), autoincrement=False, nullable=True), sa.Column('provider_type', sa.VARCHAR(length=10), server_default=sa.text("'SMTP'::character varying"), autoincrement=False, nullable=True), sa.Column('host', sa.VARCHAR(length=255), autoincrement=False, nullable=True), sa.Column('port', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('username', sa.VARCHAR(length=255), autoincrement=False, nullable=True), sa.Column('password_hash', sa.VARCHAR(length=255), autoincrement=False, nullable=True), sa.Column('is_active', sa.BOOLEAN(), server_default=sa.text('true'), autoincrement=False, nullable=True), sa.Column('daily_limit', sa.INTEGER(), server_default=sa.text('300'), autoincrement=False, nullable=True), sa.Column('current_daily_usage', sa.INTEGER(), server_default=sa.text('0'), autoincrement=False, nullable=True), sa.PrimaryKeyConstraint('id', name=op.f('email_providers_pkey')), sa.UniqueConstraint('name', name=op.f('unique_provider_name'), postgresql_include=[], postgresql_nulls_not_distinct=False) ) op.create_table('legal_documents', sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), sa.Column('title', sa.VARCHAR(length=255), autoincrement=False, nullable=True), sa.Column('content', sa.TEXT(), autoincrement=False, nullable=False), sa.Column('version', sa.VARCHAR(length=20), autoincrement=False, nullable=False), sa.Column('region_code', sa.VARCHAR(length=5), autoincrement=False, nullable=True), sa.Column('language', sa.VARCHAR(length=5), autoincrement=False, nullable=True), sa.Column('is_active', sa.BOOLEAN(), autoincrement=False, nullable=True), sa.Column('created_at', postgresql.TIMESTAMP(timezone=True), server_default=sa.text('now()'), autoincrement=False, nullable=True), sa.PrimaryKeyConstraint('id', name=op.f('legal_documents_pkey')) ) op.create_index(op.f('ix_data_legal_documents_id'), 'legal_documents', ['id'], unique=False) op.create_table('locations', sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), sa.Column('name', sa.VARCHAR(length=255), autoincrement=False, nullable=True), sa.Column('address', sa.TEXT(), autoincrement=False, nullable=True), sa.Column('latitude', sa.NUMERIC(precision=9, scale=6), autoincrement=False, nullable=True), sa.Column('longitude', sa.NUMERIC(precision=9, scale=6), autoincrement=False, nullable=True), sa.Column('created_at', postgresql.TIMESTAMP(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), autoincrement=False, nullable=True), sa.PrimaryKeyConstraint('id', name=op.f('locations_pkey')) ) op.create_table('credit_transactions', sa.Column('id', sa.UUID(), server_default=sa.text('gen_random_uuid()'), autoincrement=False, nullable=False), sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('amount', sa.NUMERIC(precision=15, scale=2), autoincrement=False, nullable=False), sa.Column('reason', sa.VARCHAR(length=100), autoincrement=False, nullable=True), sa.Column('created_at', postgresql.TIMESTAMP(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), autoincrement=False, nullable=True), sa.ForeignKeyConstraint(['user_id'], ['users.id'], name=op.f('credit_transactions_user_id_fkey')), sa.PrimaryKeyConstraint('id', name=op.f('credit_transactions_pkey')) ) op.create_table('competitions', sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), sa.Column('name', sa.VARCHAR(), autoincrement=False, nullable=False), sa.Column('description', sa.TEXT(), autoincrement=False, nullable=True), sa.Column('start_date', postgresql.TIMESTAMP(), autoincrement=False, nullable=False), sa.Column('end_date', postgresql.TIMESTAMP(), autoincrement=False, nullable=False), sa.Column('is_active', sa.BOOLEAN(), autoincrement=False, nullable=True), sa.PrimaryKeyConstraint('id', name=op.f('competitions_pkey')) ) op.create_table('service_specialties', sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), sa.Column('parent_id', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('name', sa.VARCHAR(length=100), autoincrement=False, nullable=True), sa.Column('slug', sa.VARCHAR(length=100), autoincrement=False, nullable=True), sa.ForeignKeyConstraint(['parent_id'], ['service_specialties.id'], name=op.f('service_specialties_parent_id_fkey')), sa.PrimaryKeyConstraint('id', name=op.f('service_specialties_pkey')), sa.UniqueConstraint('slug', name=op.f('service_specialties_slug_key'), postgresql_include=[], postgresql_nulls_not_distinct=False) ) op.create_table('legal_acceptances', sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('document_id', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('accepted_at', postgresql.TIMESTAMP(timezone=True), server_default=sa.text('now()'), autoincrement=False, nullable=True), sa.Column('ip_address', sa.VARCHAR(length=45), autoincrement=False, nullable=True), sa.Column('user_agent', sa.TEXT(), autoincrement=False, nullable=True), sa.ForeignKeyConstraint(['document_id'], ['legal_documents.id'], name=op.f('legal_acceptances_document_id_fkey')), sa.ForeignKeyConstraint(['user_id'], ['users.id'], name=op.f('legal_acceptances_user_id_fkey')), sa.PrimaryKeyConstraint('id', name=op.f('legal_acceptances_pkey')) ) op.create_index(op.f('ix_data_legal_acceptances_id'), 'legal_acceptances', ['id'], unique=False) op.create_table('badges', sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), sa.Column('name', sa.VARCHAR(), autoincrement=False, nullable=False), sa.Column('description', sa.VARCHAR(), autoincrement=False, nullable=False), sa.Column('icon_url', sa.VARCHAR(), autoincrement=False, nullable=True), sa.PrimaryKeyConstraint('id', name=op.f('badges_pkey')), sa.UniqueConstraint('name', name=op.f('badges_name_key'), postgresql_include=[], postgresql_nulls_not_distinct=False) ) op.create_index(op.f('ix_data_badges_id'), 'badges', ['id'], unique=False) op.create_table('subscription_notification_rules', sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), sa.Column('subscription_type', sa.VARCHAR(length=50), autoincrement=False, nullable=True), sa.Column('days_before', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('template_key', sa.VARCHAR(length=100), autoincrement=False, nullable=True), sa.PrimaryKeyConstraint('id', name=op.f('subscription_notification_rules_pkey')) ) op.create_table('vehicle_variants', sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), sa.Column('model_id', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('engine_size', sa.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=True), sa.Column('power_kw', sa.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=True), sa.Column('spec_data', postgresql.JSON(astext_type=sa.Text()), autoincrement=False, nullable=True), sa.Column('fuel_type', sa.VARCHAR(length=50), autoincrement=False, nullable=True), sa.Column('engine_code', sa.VARCHAR(length=100), autoincrement=False, nullable=True), sa.Column('cylinder_capacity', sa.INTEGER(), autoincrement=False, nullable=True), sa.ForeignKeyConstraint(['model_id'], ['vehicle_models.id'], name=op.f('vehicle_variants_model_id_fkey')), sa.PrimaryKeyConstraint('id', name=op.f('vehicle_variants_pkey')) ) op.create_index(op.f('ix_data_vehicle_variants_id'), 'vehicle_variants', ['id'], unique=False) op.create_table('referrals', sa.Column('id', sa.BIGINT(), autoincrement=True, nullable=False), sa.Column('referrer_id', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('referee_id', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('commission_level', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('commission_percentage', sa.NUMERIC(precision=5, scale=2), autoincrement=False, nullable=True), sa.Column('created_at', postgresql.TIMESTAMP(timezone=True), server_default=sa.text('now()'), autoincrement=False, nullable=True), sa.CheckConstraint('commission_level = ANY (ARRAY[1, 2, 3])', name=op.f('referrals_commission_level_check')), sa.ForeignKeyConstraint(['referee_id'], ['users.id'], name=op.f('referrals_referee_id_fkey')), sa.ForeignKeyConstraint(['referrer_id'], ['users.id'], name=op.f('referrals_referrer_id_fkey')), sa.PrimaryKeyConstraint('id', name=op.f('referrals_pkey')) ) op.create_table('user_credits', sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=False), sa.Column('balance', sa.NUMERIC(precision=15, scale=2), server_default=sa.text('0'), autoincrement=False, nullable=True), sa.Column('updated_at', postgresql.TIMESTAMP(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), autoincrement=False, nullable=True), sa.ForeignKeyConstraint(['user_id'], ['users.id'], name=op.f('user_credits_user_id_fkey')), sa.PrimaryKeyConstraint('user_id', name=op.f('user_credits_pkey')) ) op.create_table('system_settings', sa.Column('key_name', sa.VARCHAR(), autoincrement=False, nullable=False), sa.Column('value_json', postgresql.JSON(astext_type=sa.Text()), autoincrement=False, nullable=False), sa.Column('description', sa.VARCHAR(), autoincrement=False, nullable=True), sa.Column('region_code', sa.VARCHAR(length=5), autoincrement=False, nullable=True), sa.Column('tier_id', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('org_id', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('key', sa.VARCHAR(length=100), autoincrement=False, nullable=True), sa.Column('value', sa.TEXT(), autoincrement=False, nullable=True), sa.PrimaryKeyConstraint('key_name', name=op.f('system_settings_pkey')) ) op.create_index(op.f('ix_data_system_settings_key'), 'system_settings', ['key_name'], unique=False) op.create_index(op.f('idx_settings_lookup'), 'system_settings', ['key_name', sa.literal_column("COALESCE(region_code, ''::character varying)"), sa.literal_column('COALESCE(tier_id, 0)'), sa.literal_column('COALESCE(org_id, 0)')], unique=True) op.create_table('organization_members', sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), sa.Column('organization_id', sa.INTEGER(), autoincrement=False, nullable=False), sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=False), sa.Column('role', postgresql.ENUM('OWNER', 'ADMIN', 'FLEET_MANAGER', 'DRIVER', 'owner', 'manager', 'driver', 'service', name='orguserrole'), autoincrement=False, nullable=True), sa.Column('is_permanent', sa.BOOLEAN(), autoincrement=False, nullable=True), sa.ForeignKeyConstraint(['organization_id'], ['organizations.id'], name=op.f('organization_members_org_id_fkey'), ondelete='CASCADE'), sa.ForeignKeyConstraint(['user_id'], ['users.id'], name=op.f('organization_members_user_id_fkey'), ondelete='CASCADE'), sa.PrimaryKeyConstraint('id', name=op.f('organization_members_pkey')), sa.UniqueConstraint('organization_id', 'user_id', name=op.f('unique_user_org'), postgresql_include=[], postgresql_nulls_not_distinct=False) ) op.create_index(op.f('ix_data_organization_members_id'), 'organization_members', ['id'], unique=False) op.create_table('equipment_items', sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), sa.Column('name', sa.VARCHAR(length=255), autoincrement=False, nullable=False), sa.Column('category', sa.VARCHAR(length=100), autoincrement=False, nullable=True), sa.Column('description', sa.TEXT(), autoincrement=False, nullable=True), sa.PrimaryKeyConstraint('id', name=op.f('equipment_items_pkey')) ) op.create_table('bot_discovery_logs', sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), sa.Column('category', sa.VARCHAR(length=50), autoincrement=False, nullable=True), sa.Column('brand_name', sa.VARCHAR(length=100), autoincrement=False, nullable=True), sa.Column('model_name', sa.VARCHAR(length=100), autoincrement=False, nullable=True), sa.Column('action_taken', sa.VARCHAR(length=50), autoincrement=False, nullable=True), sa.Column('discovered_at', postgresql.TIMESTAMP(), server_default=sa.text('now()'), autoincrement=False, nullable=True), sa.PrimaryKeyConstraint('id', name=op.f('bot_discovery_logs_pkey')) ) op.create_table('points_ledger', sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=False), sa.Column('points', sa.INTEGER(), autoincrement=False, nullable=False), sa.Column('reason', sa.VARCHAR(), autoincrement=False, nullable=False), sa.Column('created_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=False), sa.ForeignKeyConstraint(['user_id'], ['users.id'], name=op.f('points_ledger_user_id_fkey')), sa.PrimaryKeyConstraint('id', name=op.f('points_ledger_pkey')) ) op.create_index(op.f('ix_data_points_ledger_id'), 'points_ledger', ['id'], unique=False) op.create_table('email_templates', sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), sa.Column('type', postgresql.ENUM('REGISTRATION', 'PASSWORD_RESET', 'GDPR_NOTICE', name='emailtype'), autoincrement=False, nullable=True), sa.Column('subject', sa.VARCHAR(length=255), autoincrement=False, nullable=False), sa.Column('body_html', sa.TEXT(), autoincrement=False, nullable=False), sa.Column('key', sa.VARCHAR(length=100), autoincrement=False, nullable=True), sa.Column('lang', sa.VARCHAR(length=10), autoincrement=False, nullable=True), sa.Column('is_active', sa.BOOLEAN(), server_default=sa.text('true'), autoincrement=False, nullable=True), sa.PrimaryKeyConstraint('id', name=op.f('email_templates_pkey')), sa.UniqueConstraint('key', 'lang', name=op.f('unique_email_key_lang'), postgresql_include=[], postgresql_nulls_not_distinct=False) ) op.create_index(op.f('ix_data_email_templates_type'), 'email_templates', ['type'], unique=True) op.create_index(op.f('ix_data_email_templates_id'), 'email_templates', ['id'], unique=False) op.create_table('vehicle_models', sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), sa.Column('brand_id', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('category_id', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('name', sa.VARCHAR(), autoincrement=False, nullable=False), sa.Column('year_start', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('year_end', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('slug', sa.VARCHAR(), autoincrement=False, nullable=True), sa.ForeignKeyConstraint(['brand_id'], ['vehicle_brands.id'], name=op.f('vehicle_models_brand_id_fkey')), sa.ForeignKeyConstraint(['category_id'], ['vehicle_categories.id'], name=op.f('vehicle_models_category_id_fkey')), sa.PrimaryKeyConstraint('id', name=op.f('vehicle_models_pkey')), sa.UniqueConstraint('brand_id', 'name', name=op.f('vehicle_models_brand_name_key'), postgresql_include=[], postgresql_nulls_not_distinct=False) ) op.create_index(op.f('ix_data_vehicle_models_id'), 'vehicle_models', ['id'], unique=False) op.create_index(op.f('idx_vm_slug'), 'vehicle_models', ['brand_id', 'slug'], unique=True) op.create_table('user_scores', sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('competition_id', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('points', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('last_updated', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), sa.ForeignKeyConstraint(['competition_id'], ['competitions.id'], name=op.f('user_scores_competition_id_fkey')), sa.ForeignKeyConstraint(['user_id'], ['users.id'], name=op.f('user_scores_user_id_fkey')), sa.PrimaryKeyConstraint('id', name=op.f('user_scores_pkey')), sa.UniqueConstraint('user_id', 'competition_id', name=op.f('uq_user_competition_score'), postgresql_include=[], postgresql_nulls_not_distinct=False) ) op.create_table('vehicle_ownership', sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), sa.Column('vehicle_id', sa.INTEGER(), autoincrement=False, nullable=False), sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=False), sa.Column('role', sa.VARCHAR(length=20), autoincrement=False, nullable=True), sa.Column('license_plate', sa.VARCHAR(length=20), autoincrement=False, nullable=True), sa.Column('is_active', sa.BOOLEAN(), autoincrement=False, nullable=True), sa.Column('start_date', sa.DATE(), server_default=sa.text('CURRENT_DATE'), autoincrement=False, nullable=True), sa.Column('end_date', sa.DATE(), autoincrement=False, nullable=True), sa.ForeignKeyConstraint(['user_id'], ['users.id'], name=op.f('vehicle_ownership_user_id_fkey'), ondelete='CASCADE'), sa.PrimaryKeyConstraint('id', name=op.f('vehicle_ownership_pkey')) ) op.create_index(op.f('ix_data_vehicle_ownership_id'), 'vehicle_ownership', ['id'], unique=False) op.create_table('regional_settings', sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), sa.Column('country_code', sa.VARCHAR(), autoincrement=False, nullable=False), sa.Column('currency_code', sa.VARCHAR(), autoincrement=False, nullable=False), sa.Column('is_active', sa.BOOLEAN(), autoincrement=False, nullable=False), sa.Column('language_code', sa.CHAR(length=2), server_default=sa.text("'hu'::bpchar"), autoincrement=False, nullable=True), sa.Column('is_eu_member', sa.BOOLEAN(), server_default=sa.text('true'), autoincrement=False, nullable=True), sa.PrimaryKeyConstraint('id', name=op.f('regional_settings_pkey')), sa.UniqueConstraint('country_code', name=op.f('regional_settings_country_code_key'), postgresql_include=[], postgresql_nulls_not_distinct=False) ) op.create_index(op.f('ix_data_regional_settings_id'), 'regional_settings', ['id'], unique=False) op.create_table('verification_tokens', sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('token', sa.VARCHAR(length=255), autoincrement=False, nullable=True), sa.Column('token_type', postgresql.ENUM('email_verify', 'password_reset', 'api_key', name='tokentype'), autoincrement=False, nullable=True), sa.Column('expires_at', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=True), sa.Column('created_at', postgresql.TIMESTAMP(timezone=True), server_default=sa.text('now()'), autoincrement=False, nullable=True), sa.Column('token_hash', sa.TEXT(), autoincrement=False, nullable=True), sa.Column('is_used', sa.BOOLEAN(), server_default=sa.text('false'), autoincrement=False, nullable=True), sa.Column('used_at', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=True), sa.ForeignKeyConstraint(['user_id'], ['users.id'], name=op.f('verification_tokens_user_id_fkey'), ondelete='CASCADE'), sa.PrimaryKeyConstraint('id', name=op.f('verification_tokens_pkey')) ) op.create_index(op.f('uq_verification_tokens_token_hash'), 'verification_tokens', ['token_hash'], unique=True, postgresql_where='(token_hash IS NOT NULL)') op.create_index(op.f('ix_verification_tokens_user'), 'verification_tokens', ['user_id', 'token_type', sa.literal_column('created_at DESC')], unique=False) op.create_index(op.f('ix_verification_tokens_lookup'), 'verification_tokens', ['token_type', 'is_used', 'expires_at'], unique=False) op.create_index(op.f('ix_data_verification_tokens_token'), 'verification_tokens', ['token'], unique=True) op.create_index(op.f('ix_data_verification_tokens_id'), 'verification_tokens', ['id'], unique=False) op.create_table('vouchers', sa.Column('id', sa.UUID(), server_default=sa.text('gen_random_uuid()'), autoincrement=False, nullable=False), sa.Column('code', sa.VARCHAR(length=20), autoincrement=False, nullable=False), sa.Column('value', sa.NUMERIC(precision=15, scale=2), autoincrement=False, nullable=False), sa.Column('created_at', postgresql.TIMESTAMP(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), autoincrement=False, nullable=True), sa.Column('expires_at', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=True), sa.Column('batch_id', sa.VARCHAR(length=50), autoincrement=False, nullable=True), sa.Column('is_used', sa.BOOLEAN(), server_default=sa.text('false'), autoincrement=False, nullable=True), sa.Column('used_by', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('used_at', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=True), sa.ForeignKeyConstraint(['used_by'], ['users.id'], name=op.f('vouchers_used_by_fkey')), sa.PrimaryKeyConstraint('id', name=op.f('vouchers_pkey')), sa.UniqueConstraint('code', name=op.f('vouchers_code_key'), postgresql_include=[], postgresql_nulls_not_distinct=False) ) op.create_table('level_configs', sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), sa.Column('level_number', sa.INTEGER(), autoincrement=False, nullable=False), sa.Column('min_points', sa.INTEGER(), autoincrement=False, nullable=False), sa.Column('rank_name', sa.VARCHAR(), autoincrement=False, nullable=False), sa.PrimaryKeyConstraint('id', name=op.f('level_configs_pkey')), sa.UniqueConstraint('level_number', name=op.f('level_configs_level_number_key'), postgresql_include=[], postgresql_nulls_not_distinct=False) ) op.create_index(op.f('ix_data_level_configs_id'), 'level_configs', ['id'], unique=False) op.create_table('audit_logs', sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('action', sa.VARCHAR(length=100), autoincrement=False, nullable=False), sa.Column('endpoint', sa.VARCHAR(length=255), autoincrement=False, nullable=True), sa.Column('method', sa.VARCHAR(length=10), autoincrement=False, nullable=True), sa.Column('payload', postgresql.JSONB(astext_type=sa.Text()), autoincrement=False, nullable=True), sa.Column('ip_address', sa.VARCHAR(length=45), autoincrement=False, nullable=True), sa.Column('user_agent', sa.TEXT(), autoincrement=False, nullable=True), sa.Column('created_at', postgresql.TIMESTAMP(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), autoincrement=False, nullable=True), sa.ForeignKeyConstraint(['user_id'], ['users.id'], name=op.f('audit_logs_user_id_fkey')), sa.PrimaryKeyConstraint('id', name=op.f('audit_logs_pkey')) ) op.create_table('votes', sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=False), sa.Column('provider_id', sa.INTEGER(), autoincrement=False, nullable=False), sa.Column('vote_value', sa.INTEGER(), autoincrement=False, nullable=False), sa.ForeignKeyConstraint(['user_id'], ['users.id'], name=op.f('votes_user_id_fkey')), sa.PrimaryKeyConstraint('id', name=op.f('votes_pkey')), sa.UniqueConstraint('user_id', 'provider_id', name=op.f('uq_user_provider_vote'), postgresql_include=[], postgresql_nulls_not_distinct=False) ) op.create_table('credit_logs', sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), sa.Column('org_id', sa.INTEGER(), autoincrement=False, nullable=True), sa.Column('amount', sa.NUMERIC(precision=10, scale=2), autoincrement=False, nullable=True), sa.Column('description', sa.TEXT(), autoincrement=False, nullable=True), sa.Column('created_at', postgresql.TIMESTAMP(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), autoincrement=False, nullable=True), sa.ForeignKeyConstraint(['org_id'], ['organizations.id'], name=op.f('credit_logs_org_id_fkey')), sa.PrimaryKeyConstraint('id', name=op.f('credit_logs_pkey')) ) op.create_table('user_vehicle_equipment', sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), sa.Column('user_vehicle_id', sa.INTEGER(), autoincrement=False, nullable=False), sa.Column('equipment_item_id', sa.INTEGER(), autoincrement=False, nullable=False), sa.Column('source', postgresql.ENUM('factory', 'aftermarket', name='equipment_source'), server_default=sa.text("'factory'::equipment_source"), autoincrement=False, nullable=True), sa.Column('installed_at', sa.DATE(), autoincrement=False, nullable=True), sa.Column('notes', sa.TEXT(), autoincrement=False, nullable=True), sa.Column('is_active', sa.BOOLEAN(), server_default=sa.text('true'), autoincrement=False, nullable=True), sa.ForeignKeyConstraint(['equipment_item_id'], ['equipment_items.id'], name=op.f('user_vehicle_equipment_equipment_item_id_fkey')), sa.ForeignKeyConstraint(['user_vehicle_id'], ['user_vehicles.id'], name=op.f('user_vehicle_equipment_user_vehicle_id_fkey'), ondelete='CASCADE'), sa.PrimaryKeyConstraint('id', name=op.f('user_vehicle_equipment_pkey')) ) # ### end Alembic commands ###