feat(mining-admin): add migration for contribution records and network progress tables
- Add synced_contribution_records table for tracking contribution ledger - Add synced_network_progress table for tracking network-wide stats - Revert Dockerfile to use prisma migrate deploy Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
1c33dd7bf3
commit
e337a1dda4
|
|
@ -53,8 +53,8 @@ RUN DATABASE_URL="postgresql://user:pass@localhost:5432/db" npx prisma generate
|
|||
# 复制构建产物
|
||||
COPY --chown=nestjs:nodejs --from=builder /app/dist ./dist
|
||||
|
||||
# 创建启动脚本 - 使用 db push 而不是 migrate deploy(此服务不使用迁移文件)
|
||||
RUN printf '#!/bin/sh\nset -e\necho "Syncing database schema..."\nnpx prisma db push --accept-data-loss\necho "Starting application..."\nexec node dist/main.js\n' > /app/start.sh && chmod +x /app/start.sh
|
||||
# 创建启动脚本
|
||||
RUN printf '#!/bin/sh\nset -e\necho "Running database migrations..."\nnpx prisma migrate deploy\necho "Starting application..."\nexec node dist/main.js\n' > /app/start.sh && chmod +x /app/start.sh
|
||||
|
||||
ENV NODE_ENV=production
|
||||
ENV TZ=Asia/Shanghai
|
||||
|
|
|
|||
|
|
@ -0,0 +1,57 @@
|
|||
-- CreateTable
|
||||
CREATE TABLE "synced_contribution_records" (
|
||||
"id" TEXT NOT NULL,
|
||||
"originalRecordId" BIGINT NOT NULL,
|
||||
"accountSequence" TEXT NOT NULL,
|
||||
"sourceType" TEXT NOT NULL,
|
||||
"sourceAdoptionId" BIGINT NOT NULL,
|
||||
"sourceAccountSequence" TEXT NOT NULL,
|
||||
"treeCount" INTEGER NOT NULL,
|
||||
"baseContribution" DECIMAL(20,10) NOT NULL,
|
||||
"distributionRate" DECIMAL(10,6) NOT NULL,
|
||||
"levelDepth" INTEGER,
|
||||
"bonusTier" INTEGER,
|
||||
"amount" DECIMAL(30,10) NOT NULL,
|
||||
"effectiveDate" DATE NOT NULL,
|
||||
"expireDate" DATE NOT NULL,
|
||||
"isExpired" BOOLEAN NOT NULL DEFAULT false,
|
||||
"syncedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "synced_contribution_records_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "synced_network_progress" (
|
||||
"id" TEXT NOT NULL,
|
||||
"totalTreeCount" INTEGER NOT NULL DEFAULT 0,
|
||||
"totalAdoptionOrders" INTEGER NOT NULL DEFAULT 0,
|
||||
"totalAdoptedUsers" INTEGER NOT NULL DEFAULT 0,
|
||||
"currentUnit" INTEGER NOT NULL DEFAULT 0,
|
||||
"currentMultiplier" DECIMAL(10,6) NOT NULL DEFAULT 1.0,
|
||||
"currentContributionPerTree" DECIMAL(20,10) NOT NULL DEFAULT 22617,
|
||||
"nextUnitTreeCount" INTEGER NOT NULL DEFAULT 1000,
|
||||
"syncedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "synced_network_progress_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "synced_contribution_records_originalRecordId_key" ON "synced_contribution_records"("originalRecordId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "synced_contribution_records_accountSequence_idx" ON "synced_contribution_records"("accountSequence");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "synced_contribution_records_sourceAccountSequence_idx" ON "synced_contribution_records"("sourceAccountSequence");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "synced_contribution_records_sourceAdoptionId_idx" ON "synced_contribution_records"("sourceAdoptionId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "synced_contribution_records_sourceType_idx" ON "synced_contribution_records"("sourceType");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "synced_contribution_records_createdAt_idx" ON "synced_contribution_records"("createdAt" DESC);
|
||||
Loading…
Reference in New Issue