index ean para perf

This commit is contained in:
Cat /dev/Nulo 2023-12-25 13:33:11 -03:00
parent 88e3aef8ad
commit 1dce9abe59
4 changed files with 130 additions and 13 deletions

View file

@ -0,0 +1 @@
CREATE INDEX `precios_ean_idx` ON `precios` (`ean`);

View file

@ -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": {}
}
}

View file

@ -22,6 +22,13 @@
"when": 1703452301821,
"tag": "0002_wild_amazoness",
"breakpoints": true
},
{
"idx": 3,
"version": "5",
"when": 1703521964385,
"tag": "0003_abandoned_landau",
"breakpoints": true
}
]
}

View file

@ -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;