Skip to content

Commit

Permalink
refactor: adjust user field
Browse files Browse the repository at this point in the history
  • Loading branch information
a20688392 committed Apr 16, 2023
1 parent c19d7d3 commit cc2fab5
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
25 changes: 25 additions & 0 deletions src/database/migrations/1681641687260-AdjustUserFieldMigration.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { MigrationInterface, QueryRunner } from "typeorm";

export class AdjustUserFieldMigration1681641687260
implements MigrationInterface
{
name = "AdjustUserFieldMigration1681641687260";

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`DROP INDEX \`IDX_51b8b26ac168fbe7d6f5653e6c\` ON \`users\``,
);
await queryRunner.query(
`ALTER TABLE \`users\` MODIFY \`password\` varchar(60) NOT NULL`,
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE \`users\` MODIFY \`password\` varchar(255) NOT NULL`,
);
await queryRunner.query(
`CREATE UNIQUE INDEX \`IDX_51b8b26ac168fbe7d6f5653e6c\` ON \`users\` (\`name\`)`,
);
}
}
6 changes: 4 additions & 2 deletions src/users/entities/user.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ export class UserEntity extends BaseEntity {
@Column({ unique: true })
email: string;

@Column({ unique: true })
@Column()
name: string;

@Column({ unique: true })
account: string;

@Column()
@Column({
length: 60,
})
password: string;

@CreateDateColumn()
Expand Down

0 comments on commit cc2fab5

Please sign in to comment.