diff --git a/db-datos/drizzle/0003_abandoned_landau.sql b/db-datos/drizzle/0003_abandoned_landau.sql new file mode 100644 index 0000000..2500591 --- /dev/null +++ b/db-datos/drizzle/0003_abandoned_landau.sql @@ -0,0 +1 @@ +CREATE INDEX `precios_ean_idx` ON `precios` (`ean`); \ No newline at end of file diff --git a/db-datos/drizzle/meta/0003_snapshot.json b/db-datos/drizzle/meta/0003_snapshot.json new file mode 100644 index 0000000..582d5e2 --- /dev/null +++ b/db-datos/drizzle/meta/0003_snapshot.json @@ -0,0 +1,101 @@ +{ + "version": "5", + "dialect": "sqlite", + "id": "e1217fdb-6f54-44c5-a04b-c5aebf202102", + "prevId": "cbd90a60-7568-489f-ac45-95bd8818ffbd", + "tables": { + "precios": { + "name": "precios", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "ean": { + "name": "ean", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "fetched_at": { + "name": "fetched_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "precio_centavos": { + "name": "precio_centavos", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "in_stock": { + "name": "in_stock", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "warc_record_id": { + "name": "warc_record_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "parser_version": { + "name": "parser_version", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "image_url": { + "name": "image_url", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "precios_ean_idx": { + "name": "precios_ean_idx", + "columns": [ + "ean" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + } + }, + "enums": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + } +} \ No newline at end of file diff --git a/db-datos/drizzle/meta/_journal.json b/db-datos/drizzle/meta/_journal.json index 708d59d..754b339 100644 --- a/db-datos/drizzle/meta/_journal.json +++ b/db-datos/drizzle/meta/_journal.json @@ -22,6 +22,13 @@ "when": 1703452301821, "tag": "0002_wild_amazoness", "breakpoints": true + }, + { + "idx": 3, + "version": "5", + "when": 1703521964385, + "tag": "0003_abandoned_landau", + "breakpoints": true } ] } \ No newline at end of file diff --git a/db-datos/schema.ts b/db-datos/schema.ts index 0c58c08..3c5a833 100644 --- a/db-datos/schema.ts +++ b/db-datos/schema.ts @@ -1,16 +1,24 @@ -import { integer, sqliteTable, text } from "drizzle-orm/sqlite-core"; +import { index, integer, sqliteTable, text } from "drizzle-orm/sqlite-core"; -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"), -}); +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), + }; + } +); export type Precio = typeof precios.$inferSelect;