summary refs log tree commit diff
path: root/src/util/migration/postgres/1675044825710-webauthn.ts
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2023-01-31 23:33:07 +0100
committerTheArcaneBrony <myrainbowdash949@gmail.com>2023-01-31 23:33:07 +0100
commit352ad14e9af1b0a5ef065fac547a24fba32b6f32 (patch)
treef79172fad16976ba731b503ccb010e6eda11ca75 /src/util/migration/postgres/1675044825710-webauthn.ts
parentHotfix postgres connection string to not silently fail migrations (diff)
downloadserver-352ad14e9af1b0a5ef065fac547a24fba32b6f32.tar.xz
Rename postgresql to postgres -> fix silently failing migrations
Signed-off-by: TheArcaneBrony <myrainbowdash949@gmail.com>
Diffstat (limited to 'src/util/migration/postgres/1675044825710-webauthn.ts')
-rw-r--r--src/util/migration/postgres/1675044825710-webauthn.ts27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/util/migration/postgres/1675044825710-webauthn.ts b/src/util/migration/postgres/1675044825710-webauthn.ts
new file mode 100644

index 00000000..ac43c928 --- /dev/null +++ b/src/util/migration/postgres/1675044825710-webauthn.ts
@@ -0,0 +1,27 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class webauthn1675044825710 implements MigrationInterface { + name = "webauthn1675044825710"; + + public async up(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query( + `CREATE TABLE "security_keys" ("id" character varying NOT NULL, "user_id" character varying, "key_id" character varying NOT NULL, "public_key" character varying NOT NULL, "counter" integer NOT NULL, "name" character varying NOT NULL, CONSTRAINT "PK_6e95cdd91779e7cca06d1fff89c" PRIMARY KEY ("id"))`, + ); + await queryRunner.query( + `ALTER TABLE "users" ADD "webauthn_enabled" boolean NOT NULL DEFAULT false`, + ); + await queryRunner.query( + `ALTER TABLE "security_keys" ADD CONSTRAINT "FK_24c97d0771cafedce6d7163eaad" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE NO ACTION`, + ); + } + + public async down(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query( + `ALTER TABLE "security_keys" DROP CONSTRAINT "FK_24c97d0771cafedce6d7163eaad"`, + ); + await queryRunner.query( + `ALTER TABLE "users" DROP COLUMN "webauthn_enabled"`, + ); + await queryRunner.query(`DROP TABLE "security_keys"`); + } +}