feat: Prisma 用户落库、迁移与启动环境加载

- Prisma 7 + adapter-pg;prisma.config 与 users 初始迁移\n- AppModule 挂载 PrismaModule;PrismaService 仅依赖 DATABASE_URL\n- main 入口 dotenv/config,避免 Prisma 早于 Config 读 env\n- 短信登录 upsert User;默认昵称 Chat+手机号后四位\n- README / project-solution:目录、迁移规范、用户 avatar_url 说明\n- 依赖:dotenv、@prisma/adapter-pg、pg

Made-with: Cursor
This commit is contained in:
2026-04-22 01:21:11 +08:00
parent 6cc89062e1
commit bc13417efd
12 changed files with 325 additions and 21 deletions

View File

@@ -0,0 +1,15 @@
-- CreateTable
CREATE TABLE "users" (
"id" BIGSERIAL NOT NULL,
"phone" VARCHAR(32) NOT NULL,
"nickname" VARCHAR(100),
"avatar_url" VARCHAR(512),
"status" SMALLINT NOT NULL DEFAULT 1,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3) NOT NULL,
CONSTRAINT "users_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "users_phone_key" ON "users"("phone");

View File

@@ -0,0 +1,3 @@
# Please do not edit this file manually
# It should be added in your version-control system (e.g., Git)
provider = "postgresql"

19
prisma/schema.prisma Normal file
View File

@@ -0,0 +1,19 @@
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
}
model User {
id BigInt @id @default(autoincrement())
phone String @unique @db.VarChar(32)
nickname String? @db.VarChar(100)
avatarUrl String? @map("avatar_url") @db.VarChar(512)
status Int @default(1) @db.SmallInt
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
@@map("users")
}