1
0
mirror of https://github.com/stonith404/pingvin-share.git synced 2024-06-30 06:30:11 +02:00

fix: database migration by adding a username

This commit is contained in:
Elias Schneider 2022-12-02 23:00:24 +01:00
parent 6b0b979414
commit e9526fc039
3 changed files with 10 additions and 1 deletions

View File

@ -28,7 +28,7 @@ CREATE TABLE "new_User" (
"password" TEXT NOT NULL,
"isAdmin" BOOLEAN NOT NULL DEFAULT false
);
INSERT INTO "new_User" ("createdAt", "email", "id", "password", "updatedAt") SELECT "createdAt", "email", "id", "password", "updatedAt" FROM "User";
INSERT INTO "new_User" ("createdAt", "email", "id", "password", "updatedAt", "username") SELECT "createdAt", "email", "id", "password", "updatedAt", 'user-' || User.id as "username" FROM "User";
DROP TABLE "User";
ALTER TABLE "new_User" RENAME TO "User";
CREATE UNIQUE INDEX "User_username_key" ON "User"("username");

View File

@ -12,6 +12,7 @@ import { EmailModule } from "./email/email.module";
import { FileModule } from "./file/file.module";
import { PrismaModule } from "./prisma/prisma.module";
import { ShareModule } from "./share/share.module";
import { UserModule } from "./user/user.module";
@Module({
imports: [
@ -21,6 +22,7 @@ import { ShareModule } from "./share/share.module";
EmailModule,
PrismaModule,
ConfigModule,
UserModule,
MulterModule.registerAsync({
useFactory: (config: ConfigService) => ({
fileFilter: (req: Request, file, cb) => {

View File

@ -0,0 +1,7 @@
import { Module } from "@nestjs/common";
import { UserController } from "./user.controller";
@Module({
controllers: [UserController],
})
export class UserModule {}