Skip to content

Commit

Permalink
remove comment, format migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
Tschonti committed Mar 29, 2024
1 parent 6c479a9 commit 8462e88
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 45 deletions.
7 changes: 1 addition & 6 deletions packages/functions/src/functions/auth/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,12 @@ export const login = async (req: HttpRequest, context: InvocationContext): Promi

const oauthToken = await getToken(authorizationCode)
const user = await getUser(oauthToken.access_token)
// const dataSource = await Promise.race([getAppDataSource(context), getRedisClient(context)])
const dataSource = await getAppDataSource(context)
let roles = []
if (dataSource instanceof DataSource) {
context.log('Logging in from DB')
roles = (await dataSource.getRepository(UserRoleAssignment).find({ where: { userId: user.szemely_id } })).map((r) => r.role)
} /*else {
context.log('Logging in from cache')
const rawRoles = await dataSource.hGetAll(`ura:${user.szemely_id}`)
roles = rawRoles ? Object.values(rawRoles) : []
}*/
}

const jwtToken = jwt.sign({ ...user, roles }, JWT_SECRET, { expiresIn: '2 days' })
context.log(`User #${user.szemely_id} signed in`)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { MigrationInterface, QueryRunner } from "typeorm";
import { MigrationInterface, QueryRunner } from 'typeorm'

export class MessageToRating1705141629515 implements MigrationInterface {
name = 'MessageToRating1705141629515'
name = 'MessageToRating1705141629515'

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "event_rating" ADD "message" nvarchar(255)`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "event_rating" DROP COLUMN "message"`);
}
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "event_rating" ADD "message" nvarchar(255)`)
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "event_rating" DROP COLUMN "message"`)
}
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,35 @@
import { MigrationInterface, QueryRunner } from "typeorm";
import { MigrationInterface, QueryRunner } from 'typeorm'

export class AddRatingResult1705251815793 implements MigrationInterface {
name = 'AddRatingResult1705251815793'
name = 'AddRatingResult1705251815793'

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`CREATE TABLE "rating_result" ("id" int NOT NULL IDENTITY(1,1), "parentId" int, "eventId" int NOT NULL, "stageId" int, "criterionId" int, "categoryId" int, "items" nvarchar(255) NOT NULL, CONSTRAINT "PK_cdb2f177c64795e2c911de17df7" PRIMARY KEY ("id"))`);
await queryRunner.query(`ALTER TABLE "rating_result" ADD CONSTRAINT "FK_eacb4b10b2b33ef0648a264cd21" FOREIGN KEY ("parentId") REFERENCES "rating_result"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE "rating_result" ADD CONSTRAINT "FK_e1b3811b7603ca79f37c476dfc6" FOREIGN KEY ("eventId") REFERENCES "event"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE "rating_result" ADD CONSTRAINT "FK_637a0e96aa44f923e403b90bf4d" FOREIGN KEY ("stageId") REFERENCES "stage"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE "rating_result" ADD CONSTRAINT "FK_b8e92010b73ef6b5d531066ddb9" FOREIGN KEY ("criterionId") REFERENCES "criterion"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE "rating_result" ADD CONSTRAINT "FK_aac143e39399d12911644288a36" FOREIGN KEY ("categoryId") REFERENCES "category"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "rating_result" DROP CONSTRAINT "FK_aac143e39399d12911644288a36"`);
await queryRunner.query(`ALTER TABLE "rating_result" DROP CONSTRAINT "FK_b8e92010b73ef6b5d531066ddb9"`);
await queryRunner.query(`ALTER TABLE "rating_result" DROP CONSTRAINT "FK_637a0e96aa44f923e403b90bf4d"`);
await queryRunner.query(`ALTER TABLE "rating_result" DROP CONSTRAINT "FK_e1b3811b7603ca79f37c476dfc6"`);
await queryRunner.query(`ALTER TABLE "rating_result" DROP CONSTRAINT "FK_eacb4b10b2b33ef0648a264cd21"`);
await queryRunner.query(`DROP TABLE "rating_result"`);
}
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`CREATE TABLE "rating_result" ("id" int NOT NULL IDENTITY(1,1), "parentId" int, "eventId" int NOT NULL, "stageId" int, "criterionId" int, "categoryId" int, "items" nvarchar(255) NOT NULL, CONSTRAINT "PK_cdb2f177c64795e2c911de17df7" PRIMARY KEY ("id"))`
)
await queryRunner.query(
`ALTER TABLE "rating_result" ADD CONSTRAINT "FK_eacb4b10b2b33ef0648a264cd21" FOREIGN KEY ("parentId") REFERENCES "rating_result"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`
)
await queryRunner.query(
`ALTER TABLE "rating_result" ADD CONSTRAINT "FK_e1b3811b7603ca79f37c476dfc6" FOREIGN KEY ("eventId") REFERENCES "event"("id") ON DELETE CASCADE ON UPDATE NO ACTION`
)
await queryRunner.query(
`ALTER TABLE "rating_result" ADD CONSTRAINT "FK_637a0e96aa44f923e403b90bf4d" FOREIGN KEY ("stageId") REFERENCES "stage"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`
)
await queryRunner.query(
`ALTER TABLE "rating_result" ADD CONSTRAINT "FK_b8e92010b73ef6b5d531066ddb9" FOREIGN KEY ("criterionId") REFERENCES "criterion"("id") ON DELETE CASCADE ON UPDATE NO ACTION`
)
await queryRunner.query(
`ALTER TABLE "rating_result" ADD CONSTRAINT "FK_aac143e39399d12911644288a36" FOREIGN KEY ("categoryId") REFERENCES "category"("id") ON DELETE CASCADE ON UPDATE NO ACTION`
)
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "rating_result" DROP CONSTRAINT "FK_aac143e39399d12911644288a36"`)
await queryRunner.query(`ALTER TABLE "rating_result" DROP CONSTRAINT "FK_b8e92010b73ef6b5d531066ddb9"`)
await queryRunner.query(`ALTER TABLE "rating_result" DROP CONSTRAINT "FK_637a0e96aa44f923e403b90bf4d"`)
await queryRunner.query(`ALTER TABLE "rating_result" DROP CONSTRAINT "FK_e1b3811b7603ca79f37c476dfc6"`)
await queryRunner.query(`ALTER TABLE "rating_result" DROP CONSTRAINT "FK_eacb4b10b2b33ef0648a264cd21"`)
await queryRunner.query(`DROP TABLE "rating_result"`)
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import { MigrationInterface, QueryRunner } from "typeorm";
import { MigrationInterface, QueryRunner } from 'typeorm'

export class RatingResultItemsText1705347424162 implements MigrationInterface {
name = 'RatingResultItemsText1705347424162'
name = 'RatingResultItemsText1705347424162'

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "rating_result" DROP COLUMN "items"`);
await queryRunner.query(`ALTER TABLE "rating_result" ADD "items" text NOT NULL`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "rating_result" DROP COLUMN "items"`);
await queryRunner.query(`ALTER TABLE "rating_result" ADD "items" nvarchar(255) NOT NULL`);
}
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "rating_result" DROP COLUMN "items"`)
await queryRunner.query(`ALTER TABLE "rating_result" ADD "items" text NOT NULL`)
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "rating_result" DROP COLUMN "items"`)
await queryRunner.query(`ALTER TABLE "rating_result" ADD "items" nvarchar(255) NOT NULL`)
}
}

0 comments on commit 8462e88

Please sign in to comment.