CREATE TABLE IF NOT EXISTS "airport" (
	"id" serial PRIMARY KEY NOT NULL,
	"type" varchar(64) NOT NULL,
	"name" varchar(128) NOT NULL,
	"gps_code" varchar(64) NOT NULL,
	"ident" varchar(128),
	"latitude_deg" numeric(10, 2),
	"longitude_deg" numeric(10, 2),
	"elevation_ft" numeric(10, 2),
	"continent" varchar(64),
	"country" varchar(172),
	"iso_country" varchar(4) NOT NULL,
	"iso_region" varchar(64) NOT NULL,
	"municipality" varchar(64),
	"scheduled_service" varchar(64),
	"iata_code" varchar(16) NOT NULL,
	"local_code" varchar(16) NOT NULL,
	"created_at" timestamp DEFAULT now(),
	"updated_at" timestamp DEFAULT now(),
	"search_vector" "tsvector" GENERATED ALWAYS AS (
          setweight(to_tsvector('english', coalesce("airport"."name", '')), 'A') ||
          setweight(to_tsvector('english', coalesce("airport"."iata_code", '')), 'A') ||
          setweight(to_tsvector('english', coalesce("airport"."municipality", '')), 'B') ||
          setweight(to_tsvector('english', coalesce("airport"."country", '')), 'C')
        ) STORED
);
--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "name_idx" ON "airport" USING btree ("name");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "gps_code_idx" ON "airport" USING btree ("gps_code");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "search_vector_idx" ON "airport" USING gin ("search_vector");