diff --git a/README.md b/README.md index ae59353..f20ef2a 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,8 @@ PicImpact | DATABASE_URL | Postgre 数据库 url,如:postgres://账号:密码@aws-0-ap-northeast-1.pooler.supabase.com:5432/postgres | | AUTH_SECRET | 权限机密,你可以执行 npx auth secret 生成一个,反正是随机的字符串就行 | +默认账号:`admin@qq.com`,默认密码:`666666`,**登录后请先去设置里面修改密码!** + > 部署就是这么简单,只需要您准备一个干净的数据库就行! > > 不过,不支持 ALL Edge 运行时,毕竟 Vercel 就只给了 Edge 100M 内存,太小了...当然,Node.js 运行时是完美支持的~ diff --git a/instrumentation.ts b/instrumentation.ts index 2accae6..4ff9946 100644 --- a/instrumentation.ts +++ b/instrumentation.ts @@ -7,7 +7,14 @@ export async function register() { } const prisma = new PrismaClient() if (prisma) { + const cuidModule = await import('cuid') + const cuid = cuidModule.default await prisma.$transaction(async (tx) => { + await tx.$executeRaw` + INSERT INTO "public"."User" (id, name, email, password, image) + VALUES (${cuid()}, 'admin', 'admin@qq.com', '51630b15b0cec2da9926af7015db33b7809f9d24959a0d48665b83e9d19216cd5601d08a622a8b2c48709d5bbb62eef6ae76addce5d18703b28965eef62d491b', 'https://bbs-static.miyoushe.com/communityweb/upload/97734c89374997c7c87d5af5f7442171.png') + ON CONFLICT (name) DO NOTHING; + ` await tx.configs.createMany({ data: [ { config_key: 'accesskey_id', config_value: '', detail: '阿里 OSS / AWS S3 AccessKey_ID' }, diff --git a/package.json b/package.json index 25084be..82aa0c1 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "class-variance-authority": "^0.7.0", "clsx": "^2.1.1", "crypto-js": "^4.2.0", + "cuid": "^3.0.0", "dayjs": "^1.11.11", "exifreader": "^4.22.1", "framer-motion": "^11.1.7", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1ea759c..ad96dd4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -47,6 +47,9 @@ dependencies: crypto-js: specifier: ^4.2.0 version: 4.2.0 + cuid: + specifier: ^3.0.0 + version: 3.0.0 dayjs: specifier: ^1.11.11 version: 1.11.11 @@ -5830,6 +5833,11 @@ packages: /csstype@3.1.3: resolution: {integrity: sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==} + /cuid@3.0.0: + resolution: {integrity: sha512-WZYYkHdIDnaxdeP8Misq3Lah5vFjJwGuItJuV+tvMafosMzw0nF297T7mrm8IOWiPJkV6gc7sa8pzx27+w25Zg==} + deprecated: Cuid and other k-sortable and non-cryptographic ids (Ulid, ObjectId, KSUID, all UUIDs) are all insecure. Use @paralleldrive/cuid2 instead. + dev: false + /damerau-levenshtein@1.0.8: resolution: {integrity: sha512-sdQSFB7+llfUcQHUQO3+B8ERRj0Oa4w9POWMI/puGtuf7gFywGmkaLCElnudfTiKZV+NvHqL0ifzdrI8Ro7ESA==} dev: true diff --git a/prisma/migrations/20240505050304_v2/migration.sql b/prisma/migrations/20240505050304_v2/migration.sql new file mode 100644 index 0000000..e083f15 --- /dev/null +++ b/prisma/migrations/20240505050304_v2/migration.sql @@ -0,0 +1,8 @@ +/* + Warnings: + + - A unique constraint covering the columns `[name]` on the table `User` will be added. If there are existing duplicate values, this will fail. + +*/ +-- CreateIndex +CREATE UNIQUE INDEX "User_name_key" ON "User"("name"); diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 1bf76b0..6609dae 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -36,7 +36,7 @@ model Session { model User { id String @id @default(cuid()) - name String? + name String? @unique email String? @unique password String? emailVerified DateTime?