Migration
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -41,6 +41,7 @@ next-env.d.ts
|
|||||||
# docker
|
# docker
|
||||||
docker-compose.override.yml
|
docker-compose.override.yml
|
||||||
*.sql
|
*.sql
|
||||||
|
!prisma/migrations/**/*.sql
|
||||||
/backups/
|
/backups/
|
||||||
|
|
||||||
# logs
|
# logs
|
||||||
|
|||||||
@@ -56,9 +56,12 @@ COPY --from=builder /app/prisma ./prisma
|
|||||||
COPY --from=builder /app/.next/standalone ./
|
COPY --from=builder /app/.next/standalone ./
|
||||||
COPY --from=builder /app/.next/static ./.next/static
|
COPY --from=builder /app/.next/static ./.next/static
|
||||||
COPY --from=builder /app/public ./public
|
COPY --from=builder /app/public ./public
|
||||||
|
COPY --from=builder /app/docker/entrypoint.sh ./docker/entrypoint.sh
|
||||||
|
|
||||||
|
RUN chmod +x ./docker/entrypoint.sh
|
||||||
|
|
||||||
USER nextjs
|
USER nextjs
|
||||||
|
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
|
||||||
CMD ["node", "server.js"]
|
CMD ["./docker/entrypoint.sh"]
|
||||||
|
|||||||
8
docker/entrypoint.sh
Normal file
8
docker/entrypoint.sh
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
echo "Applying Prisma migrations..."
|
||||||
|
npx prisma migrate deploy
|
||||||
|
|
||||||
|
echo "Starting application..."
|
||||||
|
exec node server.js
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "User"
|
||||||
|
ADD COLUMN "activationNudgeSentAt" TIMESTAMP(3),
|
||||||
|
ADD COLUMN "upgradeNudgeSentAt" TIMESTAMP(3);
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "User"
|
||||||
|
ADD COLUMN "thirtyDayNudgeSentAt" TIMESTAMP(3);
|
||||||
@@ -78,7 +78,7 @@ export async function GET(request: NextRequest) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Day-30: signed up > 30 days ago, has ≥1 QR code, still FREE, hasn't received this email yet
|
// Day-30: signed up > 30 days ago, has ≥1 QR code, still FREE, hasn't received this email yet
|
||||||
const thirtyDayCandidates = await (db.user as any).findMany({
|
const thirtyDayCandidates = await db.user.findMany({
|
||||||
where: {
|
where: {
|
||||||
createdAt: { lt: thirtyDaysAgo },
|
createdAt: { lt: thirtyDaysAgo },
|
||||||
thirtyDayNudgeSentAt: null,
|
thirtyDayNudgeSentAt: null,
|
||||||
@@ -93,7 +93,7 @@ export async function GET(request: NextRequest) {
|
|||||||
if (user._count.qrCodes > 0 && user.email) {
|
if (user._count.qrCodes > 0 && user.email) {
|
||||||
try {
|
try {
|
||||||
await sendThirtyDayNudgeEmail(user.email, user.name ?? 'there', user._count.qrCodes);
|
await sendThirtyDayNudgeEmail(user.email, user.name ?? 'there', user._count.qrCodes);
|
||||||
await (db.user as any).update({
|
await db.user.update({
|
||||||
where: { id: user.id },
|
where: { id: user.id },
|
||||||
data: { thirtyDayNudgeSentAt: now },
|
data: { thirtyDayNudgeSentAt: now },
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user