|
@ -13,3 +13,15 @@ CREATE TABLE "AccountBalance" ( |
|
|
|
|
|
|
|
|
-- AddForeignKey |
|
|
-- AddForeignKey |
|
|
ALTER TABLE "AccountBalance" ADD CONSTRAINT "AccountBalance_accountId_userId_fkey" FOREIGN KEY ("accountId", "userId") REFERENCES "Account"("id", "userId") ON DELETE CASCADE ON UPDATE CASCADE; |
|
|
ALTER TABLE "AccountBalance" ADD CONSTRAINT "AccountBalance_accountId_userId_fkey" FOREIGN KEY ("accountId", "userId") REFERENCES "Account"("id", "userId") ON DELETE CASCADE ON UPDATE CASCADE; |
|
|
|
|
|
|
|
|
|
|
|
-- Migrate current account balance to time series (AccountBalance[]) |
|
|
|
|
|
INSERT INTO "AccountBalance" ("accountId", "createdAt", "date", "id", "updatedAt", "userId", "value") |
|
|
|
|
|
SELECT |
|
|
|
|
|
"id", |
|
|
|
|
|
"createdAt", |
|
|
|
|
|
"createdAt", |
|
|
|
|
|
"id", |
|
|
|
|
|
"createdAt", |
|
|
|
|
|
"userId", |
|
|
|
|
|
"balance" |
|
|
|
|
|
FROM "Account"; |
|
|