CREATE TABLE IF NOT EXISTS "accounts" ( "id" text PRIMARY KEY NOT NULL, "user_id" uuid NOT NULL, "account_id" text NOT NULL, "provider_id" varchar(50) NOT NULL, "access_token" text, "refresh_token" text, "access_token_expires_at" timestamp with time zone, "refresh_token_expires_at" timestamp with time zone, "scope" text, "id_token" text, "password" text, "created_at" timestamp with time zone DEFAULT now() NOT NULL, "updated_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE IF NOT EXISTS "brands" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "name" varchar(100) NOT NULL, "slug" varchar(100) NOT NULL, "logo_url" text, "is_active" boolean DEFAULT true NOT NULL, "created_at" timestamp with time zone DEFAULT now() NOT NULL, "updated_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE IF NOT EXISTS "catalog_vehicles" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "source" varchar(20) DEFAULT 'pl24' NOT NULL, "service_name" varchar(100) NOT NULL, "brand_name" varchar(100) NOT NULL, "brand_id" uuid, "model" varchar(255) NOT NULL, "year" varchar(50), "engine" varchar(255), "body_type" varchar(100), "transmission" varchar(100), "market" varchar(100), "service_vehicle_id" varchar(255) NOT NULL, "catalog_path" text, "architecture" varchar(30), "metadata" jsonb, "categories_fetched" boolean DEFAULT false NOT NULL, "created_at" timestamp with time zone DEFAULT now() NOT NULL, "updated_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE IF NOT EXISTS "categories" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "vehicle_id" uuid, "catalog_vehicle_id" uuid, "name" varchar(500) NOT NULL, "name_original" varchar(500), "parent_id" uuid, "external_id" text, "link_path" text, "link_wid" varchar(100), "unavailable" boolean DEFAULT false NOT NULL, "source" varchar(20) DEFAULT 'pl24' NOT NULL, "created_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE IF NOT EXISTS "changelog_entries" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "stage" varchar(10) DEFAULT 'prod' NOT NULL, "title" varchar(255) NOT NULL, "description" text NOT NULL, "published_at" timestamp with time zone NOT NULL, "created_at" timestamp with time zone DEFAULT now() NOT NULL, "updated_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE IF NOT EXISTS "emex_category_translations" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "original_name" varchar(500) NOT NULL, "translated_name" varchar(500) NOT NULL, "is_manual" boolean DEFAULT false NOT NULL, "created_at" timestamp with time zone DEFAULT now() NOT NULL, "updated_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE IF NOT EXISTS "oem_code_copies" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "user_id" uuid NOT NULL, "oem_code" varchar(100) NOT NULL, "part_id" uuid, "vehicle_id" uuid, "category_id" uuid, "created_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE IF NOT EXISTS "parts" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "vehicle_id" uuid, "catalog_vehicle_id" uuid, "category_id" uuid NOT NULL, "oem_code" varchar(100) NOT NULL, "name" varchar(500) NOT NULL, "name_original" varchar(500), "description" text, "quantity" integer, "position" varchar(100), "hotspot_index" integer, "unavailable" boolean DEFAULT false NOT NULL, "remark" text, "model_codes" varchar(500), "presel" boolean DEFAULT false NOT NULL, "price" numeric(10, 2), "currency" varchar(3), "source" varchar(20) DEFAULT 'pl24' NOT NULL, "created_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE IF NOT EXISTS "password_reset_tokens" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "user_id" uuid NOT NULL, "token" text NOT NULL, "expires_at" timestamp with time zone NOT NULL, "used_at" timestamp with time zone, "created_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE IF NOT EXISTS "payments" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "user_id" uuid NOT NULL, "subscription_id" uuid NOT NULL, "amount" integer NOT NULL, "currency" varchar(3) DEFAULT 'TRY' NOT NULL, "method" varchar(20) NOT NULL, "status" varchar(20) DEFAULT 'pending' NOT NULL, "iyzico_payment_id" text, "eft_receipt_url" text, "admin_note" text, "created_at" timestamp with time zone DEFAULT now() NOT NULL, "updated_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE IF NOT EXISTS "plans" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "name" varchar(100) NOT NULL, "brand_count" integer NOT NULL, "price_monthly" integer NOT NULL, "price_yearly" integer NOT NULL, "is_active" boolean DEFAULT true NOT NULL, "created_at" timestamp with time zone DEFAULT now() NOT NULL, "updated_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE IF NOT EXISTS "query_logs" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "user_id" uuid NOT NULL, "vin" varchar(17) NOT NULL, "brand_id" uuid, "source" varchar(20), "success" boolean DEFAULT true NOT NULL, "error_message" text, "response_time_ms" integer, "created_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE IF NOT EXISTS "referrals" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "referrer_id" uuid NOT NULL, "referred_id" uuid NOT NULL, "reward_applied" boolean DEFAULT false NOT NULL, "created_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE IF NOT EXISTS "schema_pics" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "category_id" uuid NOT NULL, "image_url" text NOT NULL, "hotspots" jsonb DEFAULT '[]' NOT NULL, "source" varchar(20) DEFAULT 'pl24' NOT NULL, "created_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE IF NOT EXISTS "sessions" ( "id" text PRIMARY KEY NOT NULL, "user_id" uuid NOT NULL, "token" text NOT NULL, "expires_at" timestamp with time zone NOT NULL, "ip_address" varchar(45), "user_agent" text, "created_at" timestamp with time zone DEFAULT now() NOT NULL, "updated_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE IF NOT EXISTS "user_brands" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "user_id" uuid NOT NULL, "subscription_id" uuid NOT NULL, "brand_id" uuid NOT NULL, "created_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE IF NOT EXISTS "user_subscriptions" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "user_id" uuid NOT NULL, "plan_id" uuid NOT NULL, "status" varchar(20) DEFAULT 'pending' NOT NULL, "billing_period" varchar(10) DEFAULT 'monthly' NOT NULL, "start_date" timestamp with time zone, "end_date" timestamp with time zone, "cancelled_at" timestamp with time zone, "created_at" timestamp with time zone DEFAULT now() NOT NULL, "updated_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE IF NOT EXISTS "user_vehicles" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "user_id" uuid NOT NULL, "vehicle_id" uuid NOT NULL, "created_at" timestamp with time zone DEFAULT now() NOT NULL, "last_accessed_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE IF NOT EXISTS "users" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "name" varchar(255) NOT NULL, "email" varchar(255) NOT NULL, "email_verified" boolean DEFAULT false NOT NULL, "image" text, "role" varchar(20) DEFAULT 'user' NOT NULL, "referral_code" varchar(20), "referred_by" uuid, "created_at" timestamp with time zone DEFAULT now() NOT NULL, "updated_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE IF NOT EXISTS "vehicles" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "vin" varchar(17) NOT NULL, "brand_id" uuid, "brand_name" varchar(100), "model" varchar(255), "year" integer, "engine" varchar(255), "transmission" varchar(100), "body_type" varchar(100), "market" varchar(100), "raw_data" jsonb, "source" varchar(20) DEFAULT 'pl24' NOT NULL, "created_at" timestamp with time zone DEFAULT now() NOT NULL, "updated_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE IF NOT EXISTS "verifications" ( "id" text PRIMARY KEY NOT NULL, "identifier" text NOT NULL, "value" text NOT NULL, "expires_at" timestamp with time zone NOT NULL, "created_at" timestamp with time zone DEFAULT now() NOT NULL, "updated_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE IF NOT EXISTS "emex_catalogs" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "catalog_id" varchar(100) NOT NULL, "code" varchar(50), "brand_name" varchar(100) NOT NULL, "description" text, "source_id" integer, "created_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE IF NOT EXISTS "emex_part_groups" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "emex_catalog_id" uuid, "group_id" varchar(100) NOT NULL, "name" varchar(500) NOT NULL, "name_original" varchar(500), "parent_group_id" varchar(100), "sort_order" integer, "has_parts" boolean DEFAULT false, "has_children" boolean DEFAULT false, "source_id" integer, "created_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE IF NOT EXISTS "emex_part_images" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "emex_part_id" uuid, "image_url" text NOT NULL, "original_url" text, "created_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE IF NOT EXISTS "emex_part_numbers" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "emex_part_id" uuid, "oem_code" varchar(100) NOT NULL, "is_main" boolean DEFAULT true NOT NULL, "created_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE IF NOT EXISTS "emex_parts" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "emex_catalog_id" uuid, "group_id" uuid, "part_id" varchar(100), "part_number" varchar(100), "name" varchar(500) NOT NULL, "name_original" varchar(500), "description" text, "oem_number" varchar(100), "hotspot_index" integer, "raw_data" jsonb, "source_id" integer, "created_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE IF NOT EXISTS "emex_schema_pics" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "group_id" uuid, "image_url" text, "original_url" text, "local_path" varchar(500), "hotspots" jsonb DEFAULT '[]' NOT NULL, "width" integer, "height" integer, "sort_order" integer DEFAULT 0, "created_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE IF NOT EXISTS "emex_scrape_sessions" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "vin" varchar(17) NOT NULL, "status" varchar(20) DEFAULT 'pending' NOT NULL, "job_id" varchar(100), "result" jsonb, "error_message" text, "started_at" timestamp with time zone, "completed_at" timestamp with time zone, "created_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE IF NOT EXISTS "emex_vehicle_group_links" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "emex_vehicle_id" uuid NOT NULL, "emex_group_id" uuid NOT NULL, "ssd" text, "created_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE IF NOT EXISTS "emex_vehicle_part_links" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "emex_vehicle_id" uuid NOT NULL, "emex_part_id" uuid NOT NULL, "emex_group_id" uuid, "quantity" integer, "position" varchar(100), "created_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE IF NOT EXISTS "emex_vehicle_vins" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "emex_vehicle_id" uuid, "vin" varchar(17) NOT NULL, "created_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE IF NOT EXISTS "emex_vehicles" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "catalog_id" uuid, "vehicle_id" varchar(100) NOT NULL, "name" varchar(500), "model_code" varchar(100), "engine" varchar(255), "engine_code" varchar(100), "body_type" varchar(100), "transmission" varchar(100), "drive_type" varchar(100), "fuel_type" varchar(100), "year_from" integer, "year_to" integer, "ssd" text, "options_raw" text, "raw_data" jsonb, "source_id" integer, "created_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE IF NOT EXISTS "pcat_part_groups" ( "id" text PRIMARY KEY NOT NULL, "catalog_id" text NOT NULL, "parent_id" text, "name" text NOT NULL, "img_url" text, "has_subgroups" boolean DEFAULT false NOT NULL, "has_parts" boolean DEFAULT false NOT NULL, "created_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE IF NOT EXISTS "pcat_parts" ( "id" text PRIMARY KEY NOT NULL, "name" text NOT NULL, "notice" text, "description" text, "created_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE IF NOT EXISTS "pcat_schema_pics" ( "id" serial PRIMARY KEY NOT NULL, "group_id" text NOT NULL, "car_id" text NOT NULL, "img_url" text NOT NULL, "img_description" text, "hotspots" jsonb, "created_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE IF NOT EXISTS "pcat_vehicles" ( "id" text PRIMARY KEY NOT NULL, "catalog_id" text NOT NULL, "vin" varchar(17), "name" text NOT NULL, "description" text, "parameters" jsonb, "raw_data" jsonb, "created_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE IF NOT EXISTS "pl24_catalogs" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "catalog_id" varchar(100) NOT NULL, "brand_name" varchar(100) NOT NULL, "description" text, "created_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE IF NOT EXISTS "pl24_part_groups" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "pl24_vehicle_id" uuid, "group_id" varchar(100) NOT NULL, "name" varchar(500) NOT NULL, "parent_group_id" varchar(100), "sort_order" integer, "created_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE IF NOT EXISTS "pl24_part_images" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "pl24_part_id" uuid, "image_url" text NOT NULL, "original_url" text, "created_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE IF NOT EXISTS "pl24_part_numbers" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "pl24_part_id" uuid, "oem_code" varchar(100) NOT NULL, "is_main" boolean DEFAULT true NOT NULL, "created_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE IF NOT EXISTS "pl24_parts" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "pl24_vehicle_id" uuid, "group_id" uuid, "part_id" varchar(100), "name" varchar(500) NOT NULL, "description" text, "quantity" integer, "position" varchar(100), "hotspot_index" integer, "raw_data" jsonb, "created_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE IF NOT EXISTS "pl24_schema_pics" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "group_id" uuid, "image_url" text NOT NULL, "original_url" text, "hotspots" jsonb DEFAULT '[]' NOT NULL, "width" integer, "height" integer, "created_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE IF NOT EXISTS "pl24_vehicle_groups" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "catalog_id" uuid, "group_id" varchar(100) NOT NULL, "name" varchar(500) NOT NULL, "parent_group_id" varchar(100), "created_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE IF NOT EXISTS "pl24_vehicle_parts" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "pl24_vehicle_id" uuid, "pl24_part_id" uuid, "fitment_info" text, "created_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE IF NOT EXISTS "pl24_vehicle_vins" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "pl24_vehicle_id" uuid, "vin" varchar(17) NOT NULL, "created_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE IF NOT EXISTS "pl24_vehicles" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "catalog_id" uuid, "vehicle_id" varchar(100) NOT NULL, "name" varchar(500), "model_code" varchar(100), "engine" varchar(255), "transmission" varchar(100), "body_type" varchar(100), "market" varchar(100), "year_from" integer, "year_to" integer, "raw_data" jsonb, "created_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint DO $$ BEGIN ALTER TABLE "accounts" ADD CONSTRAINT "accounts_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$;--> statement-breakpoint DO $$ BEGIN ALTER TABLE "catalog_vehicles" ADD CONSTRAINT "catalog_vehicles_brand_id_brands_id_fk" FOREIGN KEY ("brand_id") REFERENCES "public"."brands"("id") ON DELETE no action ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$;--> statement-breakpoint DO $$ BEGIN ALTER TABLE "categories" ADD CONSTRAINT "categories_vehicle_id_vehicles_id_fk" FOREIGN KEY ("vehicle_id") REFERENCES "public"."vehicles"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$;--> statement-breakpoint DO $$ BEGIN ALTER TABLE "categories" ADD CONSTRAINT "categories_catalog_vehicle_id_catalog_vehicles_id_fk" FOREIGN KEY ("catalog_vehicle_id") REFERENCES "public"."catalog_vehicles"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$;--> statement-breakpoint DO $$ BEGIN ALTER TABLE "oem_code_copies" ADD CONSTRAINT "oem_code_copies_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$;--> statement-breakpoint DO $$ BEGIN ALTER TABLE "parts" ADD CONSTRAINT "parts_vehicle_id_vehicles_id_fk" FOREIGN KEY ("vehicle_id") REFERENCES "public"."vehicles"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$;--> statement-breakpoint DO $$ BEGIN ALTER TABLE "parts" ADD CONSTRAINT "parts_catalog_vehicle_id_catalog_vehicles_id_fk" FOREIGN KEY ("catalog_vehicle_id") REFERENCES "public"."catalog_vehicles"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$;--> statement-breakpoint DO $$ BEGIN ALTER TABLE "parts" ADD CONSTRAINT "parts_category_id_categories_id_fk" FOREIGN KEY ("category_id") REFERENCES "public"."categories"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$;--> statement-breakpoint DO $$ BEGIN ALTER TABLE "password_reset_tokens" ADD CONSTRAINT "password_reset_tokens_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$;--> statement-breakpoint DO $$ BEGIN ALTER TABLE "payments" ADD CONSTRAINT "payments_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$;--> statement-breakpoint DO $$ BEGIN ALTER TABLE "payments" ADD CONSTRAINT "payments_subscription_id_user_subscriptions_id_fk" FOREIGN KEY ("subscription_id") REFERENCES "public"."user_subscriptions"("id") ON DELETE no action ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$;--> statement-breakpoint DO $$ BEGIN ALTER TABLE "query_logs" ADD CONSTRAINT "query_logs_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$;--> statement-breakpoint DO $$ BEGIN ALTER TABLE "query_logs" ADD CONSTRAINT "query_logs_brand_id_brands_id_fk" FOREIGN KEY ("brand_id") REFERENCES "public"."brands"("id") ON DELETE no action ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$;--> statement-breakpoint DO $$ BEGIN ALTER TABLE "referrals" ADD CONSTRAINT "referrals_referrer_id_users_id_fk" FOREIGN KEY ("referrer_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$;--> statement-breakpoint DO $$ BEGIN ALTER TABLE "referrals" ADD CONSTRAINT "referrals_referred_id_users_id_fk" FOREIGN KEY ("referred_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$;--> statement-breakpoint DO $$ BEGIN ALTER TABLE "schema_pics" ADD CONSTRAINT "schema_pics_category_id_categories_id_fk" FOREIGN KEY ("category_id") REFERENCES "public"."categories"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$;--> statement-breakpoint DO $$ BEGIN ALTER TABLE "sessions" ADD CONSTRAINT "sessions_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$;--> statement-breakpoint DO $$ BEGIN ALTER TABLE "user_brands" ADD CONSTRAINT "user_brands_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$;--> statement-breakpoint DO $$ BEGIN ALTER TABLE "user_brands" ADD CONSTRAINT "user_brands_subscription_id_user_subscriptions_id_fk" FOREIGN KEY ("subscription_id") REFERENCES "public"."user_subscriptions"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$;--> statement-breakpoint DO $$ BEGIN ALTER TABLE "user_brands" ADD CONSTRAINT "user_brands_brand_id_brands_id_fk" FOREIGN KEY ("brand_id") REFERENCES "public"."brands"("id") ON DELETE no action ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$;--> statement-breakpoint DO $$ BEGIN ALTER TABLE "user_subscriptions" ADD CONSTRAINT "user_subscriptions_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$;--> statement-breakpoint DO $$ BEGIN ALTER TABLE "user_subscriptions" ADD CONSTRAINT "user_subscriptions_plan_id_plans_id_fk" FOREIGN KEY ("plan_id") REFERENCES "public"."plans"("id") ON DELETE no action ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$;--> statement-breakpoint DO $$ BEGIN ALTER TABLE "user_vehicles" ADD CONSTRAINT "user_vehicles_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$;--> statement-breakpoint DO $$ BEGIN ALTER TABLE "user_vehicles" ADD CONSTRAINT "user_vehicles_vehicle_id_vehicles_id_fk" FOREIGN KEY ("vehicle_id") REFERENCES "public"."vehicles"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$;--> statement-breakpoint DO $$ BEGIN ALTER TABLE "vehicles" ADD CONSTRAINT "vehicles_brand_id_brands_id_fk" FOREIGN KEY ("brand_id") REFERENCES "public"."brands"("id") ON DELETE no action ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$;--> statement-breakpoint DO $$ BEGIN ALTER TABLE "emex_part_groups" ADD CONSTRAINT "emex_part_groups_emex_catalog_id_emex_catalogs_id_fk" FOREIGN KEY ("emex_catalog_id") REFERENCES "public"."emex_catalogs"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$;--> statement-breakpoint DO $$ BEGIN ALTER TABLE "emex_part_images" ADD CONSTRAINT "emex_part_images_emex_part_id_emex_parts_id_fk" FOREIGN KEY ("emex_part_id") REFERENCES "public"."emex_parts"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$;--> statement-breakpoint DO $$ BEGIN ALTER TABLE "emex_part_numbers" ADD CONSTRAINT "emex_part_numbers_emex_part_id_emex_parts_id_fk" FOREIGN KEY ("emex_part_id") REFERENCES "public"."emex_parts"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$;--> statement-breakpoint DO $$ BEGIN ALTER TABLE "emex_parts" ADD CONSTRAINT "emex_parts_emex_catalog_id_emex_catalogs_id_fk" FOREIGN KEY ("emex_catalog_id") REFERENCES "public"."emex_catalogs"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$;--> statement-breakpoint DO $$ BEGIN ALTER TABLE "emex_parts" ADD CONSTRAINT "emex_parts_group_id_emex_part_groups_id_fk" FOREIGN KEY ("group_id") REFERENCES "public"."emex_part_groups"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$;--> statement-breakpoint DO $$ BEGIN ALTER TABLE "emex_schema_pics" ADD CONSTRAINT "emex_schema_pics_group_id_emex_part_groups_id_fk" FOREIGN KEY ("group_id") REFERENCES "public"."emex_part_groups"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$;--> statement-breakpoint DO $$ BEGIN ALTER TABLE "emex_vehicle_group_links" ADD CONSTRAINT "emex_vehicle_group_links_emex_vehicle_id_emex_vehicles_id_fk" FOREIGN KEY ("emex_vehicle_id") REFERENCES "public"."emex_vehicles"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$;--> statement-breakpoint DO $$ BEGIN ALTER TABLE "emex_vehicle_group_links" ADD CONSTRAINT "emex_vehicle_group_links_emex_group_id_emex_part_groups_id_fk" FOREIGN KEY ("emex_group_id") REFERENCES "public"."emex_part_groups"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$;--> statement-breakpoint DO $$ BEGIN ALTER TABLE "emex_vehicle_part_links" ADD CONSTRAINT "emex_vehicle_part_links_emex_vehicle_id_emex_vehicles_id_fk" FOREIGN KEY ("emex_vehicle_id") REFERENCES "public"."emex_vehicles"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$;--> statement-breakpoint DO $$ BEGIN ALTER TABLE "emex_vehicle_part_links" ADD CONSTRAINT "emex_vehicle_part_links_emex_part_id_emex_parts_id_fk" FOREIGN KEY ("emex_part_id") REFERENCES "public"."emex_parts"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$;--> statement-breakpoint DO $$ BEGIN ALTER TABLE "emex_vehicle_part_links" ADD CONSTRAINT "emex_vehicle_part_links_emex_group_id_emex_part_groups_id_fk" FOREIGN KEY ("emex_group_id") REFERENCES "public"."emex_part_groups"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$;--> statement-breakpoint DO $$ BEGIN ALTER TABLE "emex_vehicle_vins" ADD CONSTRAINT "emex_vehicle_vins_emex_vehicle_id_emex_vehicles_id_fk" FOREIGN KEY ("emex_vehicle_id") REFERENCES "public"."emex_vehicles"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$;--> statement-breakpoint DO $$ BEGIN ALTER TABLE "emex_vehicles" ADD CONSTRAINT "emex_vehicles_catalog_id_emex_catalogs_id_fk" FOREIGN KEY ("catalog_id") REFERENCES "public"."emex_catalogs"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$;--> statement-breakpoint DO $$ BEGIN ALTER TABLE "pl24_part_groups" ADD CONSTRAINT "pl24_part_groups_pl24_vehicle_id_pl24_vehicles_id_fk" FOREIGN KEY ("pl24_vehicle_id") REFERENCES "public"."pl24_vehicles"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$;--> statement-breakpoint DO $$ BEGIN ALTER TABLE "pl24_part_images" ADD CONSTRAINT "pl24_part_images_pl24_part_id_pl24_parts_id_fk" FOREIGN KEY ("pl24_part_id") REFERENCES "public"."pl24_parts"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$;--> statement-breakpoint DO $$ BEGIN ALTER TABLE "pl24_part_numbers" ADD CONSTRAINT "pl24_part_numbers_pl24_part_id_pl24_parts_id_fk" FOREIGN KEY ("pl24_part_id") REFERENCES "public"."pl24_parts"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$;--> statement-breakpoint DO $$ BEGIN ALTER TABLE "pl24_parts" ADD CONSTRAINT "pl24_parts_pl24_vehicle_id_pl24_vehicles_id_fk" FOREIGN KEY ("pl24_vehicle_id") REFERENCES "public"."pl24_vehicles"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$;--> statement-breakpoint DO $$ BEGIN ALTER TABLE "pl24_parts" ADD CONSTRAINT "pl24_parts_group_id_pl24_part_groups_id_fk" FOREIGN KEY ("group_id") REFERENCES "public"."pl24_part_groups"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$;--> statement-breakpoint DO $$ BEGIN ALTER TABLE "pl24_schema_pics" ADD CONSTRAINT "pl24_schema_pics_group_id_pl24_part_groups_id_fk" FOREIGN KEY ("group_id") REFERENCES "public"."pl24_part_groups"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$;--> statement-breakpoint DO $$ BEGIN ALTER TABLE "pl24_vehicle_groups" ADD CONSTRAINT "pl24_vehicle_groups_catalog_id_pl24_catalogs_id_fk" FOREIGN KEY ("catalog_id") REFERENCES "public"."pl24_catalogs"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$;--> statement-breakpoint DO $$ BEGIN ALTER TABLE "pl24_vehicle_parts" ADD CONSTRAINT "pl24_vehicle_parts_pl24_vehicle_id_pl24_vehicles_id_fk" FOREIGN KEY ("pl24_vehicle_id") REFERENCES "public"."pl24_vehicles"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$;--> statement-breakpoint DO $$ BEGIN ALTER TABLE "pl24_vehicle_parts" ADD CONSTRAINT "pl24_vehicle_parts_pl24_part_id_pl24_parts_id_fk" FOREIGN KEY ("pl24_part_id") REFERENCES "public"."pl24_parts"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$;--> statement-breakpoint DO $$ BEGIN ALTER TABLE "pl24_vehicle_vins" ADD CONSTRAINT "pl24_vehicle_vins_pl24_vehicle_id_pl24_vehicles_id_fk" FOREIGN KEY ("pl24_vehicle_id") REFERENCES "public"."pl24_vehicles"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$;--> statement-breakpoint DO $$ BEGIN ALTER TABLE "pl24_vehicles" ADD CONSTRAINT "pl24_vehicles_catalog_id_pl24_catalogs_id_fk" FOREIGN KEY ("catalog_id") REFERENCES "public"."pl24_catalogs"("id") ON DELETE cascade ON UPDATE no action; EXCEPTION WHEN duplicate_object THEN null; END $$;--> statement-breakpoint CREATE INDEX IF NOT EXISTS "accounts_user_id_idx" ON "accounts" USING btree ("user_id");--> statement-breakpoint CREATE UNIQUE INDEX IF NOT EXISTS "brands_slug_idx" ON "brands" USING btree ("slug");--> statement-breakpoint CREATE UNIQUE INDEX IF NOT EXISTS "catalog_vehicles_source_svc_vid_idx" ON "catalog_vehicles" USING btree ("source","service_name","service_vehicle_id");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "catalog_vehicles_brand_name_idx" ON "catalog_vehicles" USING btree ("brand_name");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "catalog_vehicles_service_name_idx" ON "catalog_vehicles" USING btree ("service_name");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "categories_vehicle_id_idx" ON "categories" USING btree ("vehicle_id");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "categories_catalog_vehicle_id_idx" ON "categories" USING btree ("catalog_vehicle_id");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "categories_parent_id_idx" ON "categories" USING btree ("parent_id");--> statement-breakpoint CREATE UNIQUE INDEX IF NOT EXISTS "categories_vehicle_name_source_idx" ON "categories" USING btree ("vehicle_id","catalog_vehicle_id","name","source");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "changelog_entries_published_at_idx" ON "changelog_entries" USING btree ("published_at");--> statement-breakpoint CREATE UNIQUE INDEX IF NOT EXISTS "emex_translations_original_name_idx" ON "emex_category_translations" USING btree ("original_name");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "oem_code_copies_user_id_created_at_idx" ON "oem_code_copies" USING btree ("user_id","created_at");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "oem_code_copies_oem_code_idx" ON "oem_code_copies" USING btree ("oem_code");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "oem_code_copies_created_at_idx" ON "oem_code_copies" USING btree ("created_at");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "parts_vehicle_id_idx" ON "parts" USING btree ("vehicle_id");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "parts_catalog_vehicle_id_idx" ON "parts" USING btree ("catalog_vehicle_id");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "parts_category_id_idx" ON "parts" USING btree ("category_id");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "parts_oem_code_idx" ON "parts" USING btree ("oem_code");--> statement-breakpoint CREATE UNIQUE INDEX IF NOT EXISTS "password_reset_tokens_token_idx" ON "password_reset_tokens" USING btree ("token");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "payments_user_id_idx" ON "payments" USING btree ("user_id");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "payments_status_idx" ON "payments" USING btree ("status");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "query_logs_user_id_created_at_idx" ON "query_logs" USING btree ("user_id","created_at");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "query_logs_vin_idx" ON "query_logs" USING btree ("vin");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "referrals_referrer_id_idx" ON "referrals" USING btree ("referrer_id");--> statement-breakpoint CREATE UNIQUE INDEX IF NOT EXISTS "referrals_referred_id_idx" ON "referrals" USING btree ("referred_id");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "schema_pics_category_id_idx" ON "schema_pics" USING btree ("category_id");--> statement-breakpoint CREATE UNIQUE INDEX IF NOT EXISTS "sessions_token_idx" ON "sessions" USING btree ("token");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "user_brands_user_id_idx" ON "user_brands" USING btree ("user_id");--> statement-breakpoint CREATE UNIQUE INDEX IF NOT EXISTS "user_brands_unique_idx" ON "user_brands" USING btree ("user_id","subscription_id","brand_id");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "user_subscriptions_user_id_idx" ON "user_subscriptions" USING btree ("user_id");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "user_subscriptions_status_idx" ON "user_subscriptions" USING btree ("status");--> statement-breakpoint CREATE UNIQUE INDEX IF NOT EXISTS "user_vehicles_user_vehicle_idx" ON "user_vehicles" USING btree ("user_id","vehicle_id");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "user_vehicles_user_id_idx" ON "user_vehicles" USING btree ("user_id");--> statement-breakpoint CREATE UNIQUE INDEX IF NOT EXISTS "users_email_idx" ON "users" USING btree ("email");--> statement-breakpoint CREATE UNIQUE INDEX IF NOT EXISTS "users_referral_code_idx" ON "users" USING btree ("referral_code");--> statement-breakpoint CREATE UNIQUE INDEX IF NOT EXISTS "vehicles_vin_unique_idx" ON "vehicles" USING btree ("vin");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "verifications_identifier_idx" ON "verifications" USING btree ("identifier");--> statement-breakpoint CREATE UNIQUE INDEX IF NOT EXISTS "emex_catalogs_catalog_id_idx" ON "emex_catalogs" USING btree ("catalog_id");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "emex_catalogs_code_idx" ON "emex_catalogs" USING btree ("code");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "emex_part_groups_catalog_id_idx" ON "emex_part_groups" USING btree ("emex_catalog_id");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "emex_part_groups_group_id_idx" ON "emex_part_groups" USING btree ("group_id");--> statement-breakpoint CREATE UNIQUE INDEX IF NOT EXISTS "emex_part_groups_catalog_group_idx" ON "emex_part_groups" USING btree ("emex_catalog_id","group_id");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "emex_part_images_part_id_idx" ON "emex_part_images" USING btree ("emex_part_id");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "emex_part_numbers_part_id_idx" ON "emex_part_numbers" USING btree ("emex_part_id");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "emex_part_numbers_oem_code_idx" ON "emex_part_numbers" USING btree ("oem_code");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "emex_parts_catalog_id_idx" ON "emex_parts" USING btree ("emex_catalog_id");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "emex_parts_group_id_idx" ON "emex_parts" USING btree ("group_id");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "emex_parts_part_number_idx" ON "emex_parts" USING btree ("part_number");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "emex_parts_oem_number_idx" ON "emex_parts" USING btree ("oem_number");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "emex_schema_pics_group_id_idx" ON "emex_schema_pics" USING btree ("group_id");--> statement-breakpoint CREATE UNIQUE INDEX IF NOT EXISTS "emex_schema_pics_group_path_idx" ON "emex_schema_pics" USING btree ("group_id","local_path");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "emex_scrape_sessions_vin_idx" ON "emex_scrape_sessions" USING btree ("vin");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "emex_scrape_sessions_status_idx" ON "emex_scrape_sessions" USING btree ("status");--> statement-breakpoint CREATE UNIQUE INDEX IF NOT EXISTS "emex_vgl_vehicle_group_idx" ON "emex_vehicle_group_links" USING btree ("emex_vehicle_id","emex_group_id");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "emex_vgl_group_idx" ON "emex_vehicle_group_links" USING btree ("emex_group_id");--> statement-breakpoint CREATE UNIQUE INDEX IF NOT EXISTS "emex_vpl_vehicle_part_group_idx" ON "emex_vehicle_part_links" USING btree ("emex_vehicle_id","emex_part_id","emex_group_id");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "emex_vpl_part_idx" ON "emex_vehicle_part_links" USING btree ("emex_part_id");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "emex_vpl_group_idx" ON "emex_vehicle_part_links" USING btree ("emex_group_id");--> statement-breakpoint CREATE UNIQUE INDEX IF NOT EXISTS "emex_vehicle_vins_vin_idx" ON "emex_vehicle_vins" USING btree ("vin");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "emex_vehicle_vins_vehicle_id_idx" ON "emex_vehicle_vins" USING btree ("emex_vehicle_id");--> statement-breakpoint CREATE UNIQUE INDEX IF NOT EXISTS "emex_vehicles_vehicle_id_idx" ON "emex_vehicles" USING btree ("vehicle_id");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "emex_vehicles_catalog_id_idx" ON "emex_vehicles" USING btree ("catalog_id");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "emex_vehicles_name_idx" ON "emex_vehicles" USING btree ("name");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "emex_vehicles_source_id_idx" ON "emex_vehicles" USING btree ("source_id");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "pcat_part_groups_catalog_id_idx" ON "pcat_part_groups" USING btree ("catalog_id");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "pcat_part_groups_parent_id_idx" ON "pcat_part_groups" USING btree ("parent_id");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "pcat_parts_name_idx" ON "pcat_parts" USING btree ("name");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "pcat_schema_pics_group_car_idx" ON "pcat_schema_pics" USING btree ("group_id","car_id");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "pcat_vehicles_vin_idx" ON "pcat_vehicles" USING btree ("vin");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "pcat_vehicles_catalog_id_idx" ON "pcat_vehicles" USING btree ("catalog_id");--> statement-breakpoint CREATE UNIQUE INDEX IF NOT EXISTS "pl24_catalogs_catalog_id_idx" ON "pl24_catalogs" USING btree ("catalog_id");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "pl24_part_groups_vehicle_id_idx" ON "pl24_part_groups" USING btree ("pl24_vehicle_id");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "pl24_part_groups_group_id_idx" ON "pl24_part_groups" USING btree ("group_id");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "pl24_part_images_part_id_idx" ON "pl24_part_images" USING btree ("pl24_part_id");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "pl24_part_numbers_part_id_idx" ON "pl24_part_numbers" USING btree ("pl24_part_id");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "pl24_part_numbers_oem_code_idx" ON "pl24_part_numbers" USING btree ("oem_code");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "pl24_parts_vehicle_id_idx" ON "pl24_parts" USING btree ("pl24_vehicle_id");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "pl24_parts_group_id_idx" ON "pl24_parts" USING btree ("group_id");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "pl24_schema_pics_group_id_idx" ON "pl24_schema_pics" USING btree ("group_id");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "pl24_vehicle_groups_catalog_id_idx" ON "pl24_vehicle_groups" USING btree ("catalog_id");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "pl24_vehicle_groups_group_id_idx" ON "pl24_vehicle_groups" USING btree ("group_id");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "pl24_vehicle_parts_vehicle_id_idx" ON "pl24_vehicle_parts" USING btree ("pl24_vehicle_id");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "pl24_vehicle_parts_part_id_idx" ON "pl24_vehicle_parts" USING btree ("pl24_part_id");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "pl24_vehicle_vins_vin_idx" ON "pl24_vehicle_vins" USING btree ("vin");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "pl24_vehicle_vins_vehicle_id_idx" ON "pl24_vehicle_vins" USING btree ("pl24_vehicle_id");--> statement-breakpoint CREATE UNIQUE INDEX IF NOT EXISTS "pl24_vehicles_vehicle_id_idx" ON "pl24_vehicles" USING btree ("vehicle_id");--> statement-breakpoint CREATE INDEX IF NOT EXISTS "pl24_vehicles_catalog_id_idx" ON "pl24_vehicles" USING btree ("catalog_id");