gendesign/tradein-mvp/backend/data/sql/035_drop_duplicate_indexes.sql
lekss361 02b48b8d04
All checks were successful
Deploy Trade-In / changes (push) Successful in 5s
Deploy Trade-In / build-frontend (push) Has been skipped
Deploy Trade-In / build-backend (push) Successful in 23s
Deploy Trade-In / deploy (push) Successful in 32s
fix(tradein-sql): rename dup 030, add trade_in_estimates geom, drop dup indexes (#500)
Close 3 SQL schema findings from 2026-05-24 trade-in audit.

- Rename 030_listings_alter_yandex.sql -> 033_*.sql (resolve dup prefix with 030_avito_imv_cache_key_unique.sql).
- New 034_trade_in_estimates_geom.sql: PostGIS geom column + GIST index + backfill + BEFORE INSERT/UPDATE trigger.
- New 035_drop_duplicate_indexes.sql: drop listing_sources_listing_idx2 (dup of 028) and houses_geom_idx2 (dup of 009).

All idempotent. Deploy script uses ls|sort + no tracking table — rename is safe because original 030 already applied (IF NOT EXISTS no-op on re-run as 033).
2026-05-24 10:04:40 +00:00

20 lines
811 B
PL/PgSQL

-- 035_drop_duplicate_indexes.sql
-- Purpose: cleanup of redundant indexes identified in 2026-05-24 schema audit.
-- Dependencies: 028 (listing_sources_listing_idx), 050 (listing_sources_listing_idx2, houses_geom_idx2), 009 (houses_geom_idx).
-- Deploy order: any time after 050.
--
-- Redundancy details:
-- * listing_sources_listing_idx2 (050) — exact duplicate of listing_sources_listing_idx (028).
-- * houses_geom_idx2 (050) — near-duplicate of houses_geom_idx (009); both are GIST on geom (full, non-partial).
-- The (050) variant adds no filter, so it's strictly redundant.
--
-- Keep: listing_sources_listing_idx (028), houses_geom_idx (009).
--
-- Idempotent: DROP INDEX IF EXISTS.
BEGIN;
DROP INDEX IF EXISTS listing_sources_listing_idx2;
DROP INDEX IF EXISTS houses_geom_idx2;
COMMIT;