Mysql Geo index
export const property = mysqlTable(
"properties",
{
id: int("id").primaryKey().autoincrement(),
longitude: float("longitude").notNull(),
latitude: float("latitude").notNull(),
primaryImageUrl: varchar("primary_image_url", { length: 255 }),
jsonData: json("json").$type<{ foo: string }>(),
createdAt: timestamp("created_at", { mode: "string" }).defaultNow(),
},
(table) => ({
latIndex: index("lat").on(table.latitude),
longIndex: index("long").on(table.longitude),
})
);
export const property = mysqlTable(
"properties",
{
id: int("id").primaryKey().autoincrement(),
longitude: float("longitude").notNull(),
latitude: float("latitude").notNull(),
primaryImageUrl: varchar("primary_image_url", { length: 255 }),
jsonData: json("json").$type<{ foo: string }>(),
createdAt: timestamp("created_at", { mode: "string" }).defaultNow(),
},
(table) => ({
latIndex: index("lat").on(table.latitude),
longIndex: index("long").on(table.longitude),
})
);
CREATE INDEX `lat` ON `properties` (`latitude`);--> statement-breakpoint
CREATE INDEX `long` ON `properties` (`longitude`);
CREATE INDEX `lat` ON `properties` (`latitude`);--> statement-breakpoint
CREATE INDEX `long` ON `properties` (`longitude`);
alter table properties add index lat(latitude);
alter table properties add index long(longitude);
alter table properties add index lat(latitude);
alter table properties add index long(longitude);
0 Replies