Skip to content
This repository was archived by the owner on Jun 29, 2025. It is now read-only.

Commit e9526fc

Browse files
committed
fix: database migration by adding a username
1 parent 6b0b979 commit e9526fc

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

backend/prisma/migrations/20221201220540_config_and_admin_functionalities/migration.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ CREATE TABLE "new_User" (
2828
"password" TEXT NOT NULL,
2929
"isAdmin" BOOLEAN NOT NULL DEFAULT false
3030
);
31-
INSERT INTO "new_User" ("createdAt", "email", "id", "password", "updatedAt") SELECT "createdAt", "email", "id", "password", "updatedAt" FROM "User";
31+
INSERT INTO "new_User" ("createdAt", "email", "id", "password", "updatedAt", "username") SELECT "createdAt", "email", "id", "password", "updatedAt", 'user-' || User.id as "username" FROM "User";
3232
DROP TABLE "User";
3333
ALTER TABLE "new_User" RENAME TO "User";
3434
CREATE UNIQUE INDEX "User_username_key" ON "User"("username");

backend/src/app.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { EmailModule } from "./email/email.module";
1212
import { FileModule } from "./file/file.module";
1313
import { PrismaModule } from "./prisma/prisma.module";
1414
import { ShareModule } from "./share/share.module";
15+
import { UserModule } from "./user/user.module";
1516

1617
@Module({
1718
imports: [
@@ -21,6 +22,7 @@ import { ShareModule } from "./share/share.module";
2122
EmailModule,
2223
PrismaModule,
2324
ConfigModule,
25+
UserModule,
2426
MulterModule.registerAsync({
2527
useFactory: (config: ConfigService) => ({
2628
fileFilter: (req: Request, file, cb) => {

backend/src/user/user.module.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { Module } from "@nestjs/common";
2+
import { UserController } from "./user.controller";
3+
4+
@Module({
5+
controllers: [UserController],
6+
})
7+
export class UserModule {}

0 commit comments

Comments
 (0)