refactor!: support RUB only (WealthLedger/main#55) (#204)
BREAKING CHANGE: per-currency API fields replaced with single RUB Money.
This commit was merged in pull request #204.
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
-- RedefineTables
|
||||
PRAGMA defer_foreign_keys=ON;
|
||||
PRAGMA foreign_keys=OFF;
|
||||
CREATE TABLE "new_TbankPortfolioValuePoint" (
|
||||
"userId" TEXT NOT NULL,
|
||||
"accountId" TEXT NOT NULL,
|
||||
"attemptId" TEXT NOT NULL,
|
||||
"value" TEXT NOT NULL,
|
||||
"capturedAt" DATETIME NOT NULL,
|
||||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
PRIMARY KEY ("userId", "accountId", "attemptId"),
|
||||
CONSTRAINT "TbankPortfolioValuePoint_userId_accountId_fkey" FOREIGN KEY ("userId", "accountId") REFERENCES "TbankPortfolioValueHistory" ("userId", "accountId") ON DELETE CASCADE ON UPDATE RESTRICT
|
||||
);
|
||||
-- RUB-only: keep the RUB row per key; non-RUB rows are dropped.
|
||||
INSERT INTO "new_TbankPortfolioValuePoint" ("accountId", "attemptId", "capturedAt", "createdAt", "userId", "value")
|
||||
SELECT "accountId", "attemptId", "capturedAt", "createdAt", "userId", "value"
|
||||
FROM "TbankPortfolioValuePoint"
|
||||
WHERE "currency" = 'RUB';
|
||||
DROP TABLE "TbankPortfolioValuePoint";
|
||||
ALTER TABLE "new_TbankPortfolioValuePoint" RENAME TO "TbankPortfolioValuePoint";
|
||||
CREATE INDEX "TbankPortfolioValuePoint_userId_accountId_capturedAt_idx" ON "TbankPortfolioValuePoint"("userId", "accountId", "capturedAt");
|
||||
|
||||
-- RUB-only: persisted JSON payloads written in the old multi-currency shape
|
||||
-- are stale. A missing snapshot/forecast is the app's normal "not synced yet"
|
||||
-- state: reads report availability 'missing' and the hourly walk rebuilds them
|
||||
-- on the next pass. Delete the stale rows instead of failing reads with 500.
|
||||
DELETE FROM "TbankPortfolio";
|
||||
DELETE FROM "TbankForecast";
|
||||
|
||||
PRAGMA foreign_keys=ON;
|
||||
PRAGMA defer_foreign_keys=OFF;
|
||||
Reference in New Issue
Block a user