-
-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ add column githubUsername to users table
- Loading branch information
Showing
2 changed files
with
53 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { MigrationInterface, QueryRunner } from "typeorm" | ||
|
||
export class AddGithubUsernameToUsers1731317168994 | ||
implements MigrationInterface | ||
{ | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
// Add 'githubUsername' column using raw SQL | ||
await queryRunner.query(` | ||
ALTER TABLE users ADD COLUMN githubUsername VARCHAR(255) NULL; | ||
`) | ||
|
||
// Set 'githubUsername' = 'fullName' by default | ||
await queryRunner.query(` | ||
UPDATE users | ||
SET githubUsername = fullName; | ||
`) | ||
|
||
// Update 'githubUsername' for specific users | ||
await queryRunner.query(` | ||
UPDATE users | ||
SET githubUsername = 'Tuna' WHERE fullName = 'Tuna Acisu'; | ||
UPDATE users | ||
SET githubUsername = 'bastianherre' WHERE fullName = 'Bastian Herre'; | ||
UPDATE users | ||
SET githubUsername = 'JoeHasell' WHERE fullName = 'Joe Hasell'; | ||
UPDATE users | ||
SET githubUsername = 'mrwbkrm' WHERE fullName = 'Marwa Boukarim'; | ||
UPDATE users | ||
SET githubUsername = 'veronikasamborska1994' WHERE fullName = 'Veronika Samborska'; | ||
`) | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
// Remove 'githubUsername' column using raw SQL | ||
await queryRunner.query(` | ||
ALTER TABLE users DROP COLUMN githubUsername; | ||
`) | ||
} | ||
} |