stashing code

This commit is contained in:
user
2025-10-20 17:07:41 +03:00
commit f5b99afc8f
890 changed files with 54823 additions and 0 deletions

View File

@@ -0,0 +1,70 @@
import { SQL, sql } from "drizzle-orm";
import {
pgTable,
serial,
varchar,
decimal,
timestamp,
index,
customType,
} from "drizzle-orm/pg-core";
const tsvector = customType<{ data: unknown }>({
dataType() {
return "tsvector";
},
});
export const airport = pgTable(
"airport",
{
id: serial("id").primaryKey(),
type: varchar("type", { length: 64 }).notNull(),
name: varchar("name", { length: 128 }).notNull(),
gpsCode: varchar("gps_code", { length: 64 }).notNull(),
ident: varchar("ident", { length: 128 }),
latitudeDeg: decimal("latitude_deg", { precision: 10, scale: 2 }),
longitudeDeg: decimal("longitude_deg", {
precision: 10,
scale: 2,
}),
elevationFt: decimal("elevation_ft", { precision: 10, scale: 2 }),
continent: varchar("continent", { length: 64 }),
country: varchar("country", { length: 172 }),
isoCountry: varchar("iso_country", { length: 4 }).notNull(),
isoRegion: varchar("iso_region", { length: 64 }).notNull(),
municipality: varchar("municipality", { length: 64 }),
scheduledService: varchar("scheduled_service", { length: 64 }),
iataCode: varchar("iata_code", { length: 16 }).notNull(),
localCode: varchar("local_code", { length: 16 }).notNull(),
createdAt: timestamp("created_at").defaultNow(),
updatedAt: timestamp("updated_at").defaultNow(),
searchVector: tsvector("search_vector").generatedAlwaysAs(
(): SQL => sql`
setweight(to_tsvector('english', coalesce(${airport.name}, '')), 'A') ||
setweight(to_tsvector('english', coalesce(${airport.iataCode}, '')), 'A') ||
setweight(to_tsvector('english', coalesce(${airport.municipality}, '')), 'B') ||
setweight(to_tsvector('english', coalesce(${airport.country}, '')), 'C')
`,
),
},
(table) => {
return {
nameIdx: index("name_idx").on(table.name),
gpsCodeIdx: index("gps_code_idx").on(table.gpsCode),
searchVectorIdx: index("search_vector_idx").using(
"gin",
table.searchVector,
),
};
},
);