-- CreateTable
CREATE TABLE "raw_vendor_prices" (
    "id" TEXT NOT NULL,
    "timestamp" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "vendor" TEXT NOT NULL,
    "seller_name" TEXT,
    "usd_price" DECIMAL(12,2) NOT NULL,
    "auec_amount" BIGINT NOT NULL,
    "usd_per_million" DECIMAL(12,8) NOT NULL,
    "delivery_time" TEXT,
    "url" TEXT NOT NULL,

    CONSTRAINT "raw_vendor_prices_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "price_index" (
    "id" TEXT NOT NULL,
    "timestamp" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "lowest_price" DECIMAL(12,8) NOT NULL,
    "vendor" TEXT NOT NULL,
    "seller_name" TEXT,

    CONSTRAINT "price_index_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "scrape_log" (
    "id" TEXT NOT NULL,
    "timestamp" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "status" TEXT NOT NULL,
    "message" TEXT,
    "runtime_ms" INTEGER,

    CONSTRAINT "scrape_log_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE INDEX "raw_vendor_prices_timestamp_idx" ON "raw_vendor_prices"("timestamp");

-- CreateIndex
CREATE INDEX "raw_vendor_prices_vendor_idx" ON "raw_vendor_prices"("vendor");

-- CreateIndex
CREATE INDEX "raw_vendor_prices_seller_name_idx" ON "raw_vendor_prices"("seller_name");

-- CreateIndex
CREATE INDEX "raw_vendor_prices_usd_per_million_idx" ON "raw_vendor_prices"("usd_per_million");

-- CreateIndex
CREATE INDEX "price_index_timestamp_idx" ON "price_index"("timestamp");

-- CreateIndex
CREATE INDEX "scrape_log_timestamp_idx" ON "scrape_log"("timestamp");
