-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.sql
More file actions
55 lines (52 loc) · 2.13 KB
/
Copy pathschema.sql
File metadata and controls
55 lines (52 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
-- version: 0.1.0
-- refurb_watcher schema MariaDB
-- MariaDB backend only: apply once to your database
-- (the default SQLite backend auto-creates these tables).
-- Produits actuellement listés (snapshot courant)
CREATE TABLE IF NOT EXISTS refurb_snapshot (
part_number VARCHAR(64) NOT NULL,
category VARCHAR(64) NOT NULL,
title VARCHAR(512) NOT NULL,
price_cents INT NOT NULL,
list_price_cents INT NULL,
savings_cents INT NULL,
currency CHAR(3) NOT NULL DEFAULT 'EUR',
url VARCHAR(1024) NOT NULL,
ram_gb INT NULL,
storage_gb INT NULL,
chip VARCHAR(64) NULL,
cpu_cores INT NULL,
gpu_cores INT NULL,
raw_specs TEXT NULL,
first_seen DATETIME NOT NULL,
last_seen DATETIME NOT NULL,
PRIMARY KEY (part_number),
INDEX idx_category (category),
INDEX idx_last_seen (last_seen)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- Historique des apparitions (chaque NOUVELLE apparition = 1 ligne)
-- Utile pour l'analyse : combien de temps un produit reste dispo, fréquence d'apparition, etc.
CREATE TABLE IF NOT EXISTS refurb_events (
id BIGINT NOT NULL AUTO_INCREMENT,
part_number VARCHAR(64) NOT NULL,
event_type ENUM('appeared', 'disappeared', 'price_changed') NOT NULL,
seen_at DATETIME NOT NULL,
price_cents INT NULL,
title VARCHAR(512) NULL,
notified TINYINT(1) NOT NULL DEFAULT 0,
PRIMARY KEY (id),
INDEX idx_part (part_number),
INDEX idx_seen (seen_at)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- Santé du scraper (un poll = 1 ligne)
CREATE TABLE IF NOT EXISTS refurb_polls (
id BIGINT NOT NULL AUTO_INCREMENT,
polled_at DATETIME NOT NULL,
url VARCHAR(1024) NOT NULL,
http_status INT NULL,
products_found INT NULL,
error TEXT NULL,
duration_ms INT NULL,
PRIMARY KEY (id),
INDEX idx_polled (polled_at)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;