2024-01-14 01:07:23 +00:00
|
|
|
// @ts-check
|
2023-12-25 16:33:11 +00:00
|
|
|
import { index, integer, sqliteTable, text } from "drizzle-orm/sqlite-core";
|
2023-12-21 17:00:00 +00:00
|
|
|
|
2023-12-25 16:33:11 +00:00
|
|
|
export const precios = sqliteTable(
|
|
|
|
"precios",
|
|
|
|
{
|
|
|
|
id: integer("id", { mode: "number" }).primaryKey({ autoIncrement: true }),
|
|
|
|
ean: text("ean").notNull(),
|
|
|
|
fetchedAt: integer("fetched_at", { mode: "timestamp" }).notNull(),
|
|
|
|
precioCentavos: integer("precio_centavos"),
|
|
|
|
inStock: integer("in_stock", { mode: "boolean" }),
|
|
|
|
url: text("url").notNull(),
|
|
|
|
warcRecordId: text("warc_record_id"),
|
|
|
|
parserVersion: integer("parser_version"),
|
|
|
|
name: text("name"),
|
|
|
|
imageUrl: text("image_url"),
|
|
|
|
},
|
|
|
|
(precios) => {
|
|
|
|
return {
|
|
|
|
preciosEanIdx: index("precios_ean_idx").on(precios.ean),
|
2024-01-31 01:53:35 +00:00
|
|
|
preciosUrlIdx: index("precios_url_idx").on(precios.url),
|
2024-06-29 22:16:23 +00:00
|
|
|
preciosFetchedAtIdx: index("precios_fetched_at_idx").on(
|
|
|
|
precios.fetchedAt
|
|
|
|
),
|
2023-12-25 16:33:11 +00:00
|
|
|
};
|
2024-01-29 15:06:35 +00:00
|
|
|
}
|
2023-12-25 16:33:11 +00:00
|
|
|
);
|
2023-12-23 23:14:05 +00:00
|
|
|
|
2024-01-14 01:07:23 +00:00
|
|
|
/** @typedef {typeof precios.$inferSelect} Precio */
|
2023-12-30 00:49:32 +00:00
|
|
|
|
|
|
|
export const productoUrls = sqliteTable("producto_urls", {
|
|
|
|
id: integer("id", { mode: "number" }).primaryKey({ autoIncrement: true }),
|
|
|
|
url: text("url").unique().notNull(),
|
|
|
|
firstSeen: integer("first_seen", { mode: "timestamp" }).notNull(),
|
|
|
|
lastSeen: integer("last_seen", { mode: "timestamp" }).notNull(),
|
|
|
|
});
|
|
|
|
|
2024-01-14 01:07:23 +00:00
|
|
|
/** @typedef {typeof productoUrls.$inferSelect} ProductUrl */
|
2024-01-29 15:06:35 +00:00
|
|
|
|
|
|
|
export const bestSelling = sqliteTable("db_best_selling", {
|
|
|
|
id: integer("id", { mode: "number" }).primaryKey({ autoIncrement: true }),
|
|
|
|
fetchedAt: integer("fetched_at", { mode: "timestamp" }).notNull(),
|
|
|
|
category: text("category").notNull(),
|
|
|
|
eansJson: text("eans_json").notNull(),
|
|
|
|
});
|
|
|
|
|
|
|
|
/** @typedef {typeof bestSelling.$inferSelect} BestSelling */
|