CREATE TABLE "ShopeeWalletTransaction" (
  "id" TEXT NOT NULL PRIMARY KEY,
  "shopId" TEXT NOT NULL,
  "transactionKey" TEXT NOT NULL,
  "transactionType" TEXT,
  "moneyFlow" TEXT,
  "walletType" TEXT,
  "status" TEXT,
  "amount" REAL,
  "currentBalance" REAL,
  "orderSn" TEXT,
  "reason" TEXT,
  "transactionTime" DATETIME NOT NULL,
  "rawJson" JSONB,
  "syncedAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  "updatedAt" DATETIME NOT NULL
);

CREATE UNIQUE INDEX "ShopeeWalletTransaction_shopId_transactionKey_key"
ON "ShopeeWalletTransaction"("shopId", "transactionKey");

CREATE INDEX "ShopeeWalletTransaction_shopId_transactionTime_idx"
ON "ShopeeWalletTransaction"("shopId", "transactionTime");

CREATE INDEX "ShopeeWalletTransaction_transactionType_idx"
ON "ShopeeWalletTransaction"("transactionType");

CREATE INDEX "ShopeeWalletTransaction_orderSn_idx"
ON "ShopeeWalletTransaction"("orderSn");
