preciazo/db-datos/schema.ts

34 lines
1.1 KiB
TypeScript
Raw Normal View History

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),
};
}
);
2023-12-23 23:14:05 +00:00
export type Precio = typeof precios.$inferSelect;
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(),
});
export type ProductUrl = typeof productoUrls.$inferSelect;