Skip to content

Commit

Permalink
Merge pull request #15 from besscroft/dev
Browse files Browse the repository at this point in the history
🐛 修复用户账户未初始化的问题
  • Loading branch information
besscroft authored May 5, 2024
2 parents 2235e76 + 5ce99ad commit e51a670
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 运行时是完美支持的~
Expand Down
7 changes: 7 additions & 0 deletions instrumentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 8 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions prisma/migrations/20240505050304_v2/migration.sql
Original file line number Diff line number Diff line change
@@ -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");
2 changes: 1 addition & 1 deletion prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down

0 comments on commit e51a670

Please sign in to comment.