Coffee11
Coffee11
Explore posts from servers
DTDrizzle Team
Created by Coffee11 on 8/6/2024 in #help
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),
})
);
this is what I generated
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`);
any idea how can I make drizzle generate this kind of index?
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);
thank you
1 replies