final touches for beta skymoney (at least i think)
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
-- CreateEnum
|
||||
CREATE TYPE "IncomeType" AS ENUM ('regular', 'irregular');
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "User" ADD COLUMN "budgetPeriod" TEXT NOT NULL DEFAULT 'monthly',
|
||||
ADD COLUMN "incomeType" "IncomeType" NOT NULL DEFAULT 'regular',
|
||||
ADD COLUMN "totalBudgetCents" BIGINT;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "BudgetSession" (
|
||||
"id" TEXT NOT NULL,
|
||||
"userId" TEXT NOT NULL,
|
||||
"periodStart" TIMESTAMP(3) NOT NULL,
|
||||
"periodEnd" TIMESTAMP(3) NOT NULL,
|
||||
"totalBudgetCents" BIGINT NOT NULL,
|
||||
"allocatedCents" BIGINT NOT NULL DEFAULT 0,
|
||||
"fundedCents" BIGINT NOT NULL DEFAULT 0,
|
||||
"availableCents" BIGINT NOT NULL DEFAULT 0,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "BudgetSession_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "BudgetSession_userId_periodStart_idx" ON "BudgetSession"("userId", "periodStart");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "BudgetSession_userId_periodStart_key" ON "BudgetSession"("userId", "periodStart");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "BudgetSession" ADD CONSTRAINT "BudgetSession_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
Reference in New Issue
Block a user