diff --git a/assets/openapi.json b/assets/openapi.json index ee7a4e8..e502af6 100644 --- a/assets/openapi.json +++ b/assets/openapi.json @@ -8767,7 +8767,6 @@ "guild", "guild_id", "id", - "ip", "user", "user_id" ] diff --git a/assets/schemas.json b/assets/schemas.json index 576a9c6..d5b4835 100644 --- a/assets/schemas.json +++ b/assets/schemas.json @@ -9284,7 +9284,6 @@ "guild", "guild_id", "id", - "ip", "user", "user_id" ], diff --git "a/src/api/routes/guilds/\043guild_id/bans.ts" "b/src/api/routes/guilds/\043guild_id/bans.ts" index e253bef..1274c19 100644 --- "a/src/api/routes/guilds/\043guild_id/bans.ts" +++ "b/src/api/routes/guilds/\043guild_id/bans.ts" @@ -215,7 +215,6 @@ const ban = Ban.create({ user_id: banned_user_id, guild_id: guild_id, - ip: getIpAdress(req), executor_id: req.user_id, reason: req.body.reason, // || otherwise empty }); diff --git a/src/util/entities/Ban.ts b/src/util/entities/Ban.ts index d4a7bc1..c3c473f 100644 --- a/src/util/entities/Ban.ts +++ b/src/util/entities/Ban.ts @@ -53,8 +53,8 @@ @ManyToOne(() => User) executor: User; - @Column() - ip: string; + @Column({ nullable: true }) + ip?: string; @Column({ nullable: true }) reason?: string; diff --git a/src/util/migration/postgres/1765143034407-DontIpBanBanner.ts b/src/util/migration/postgres/1765143034407-DontIpBanBanner.ts new file mode 100644 index 0000000..6e8089e --- /dev/null +++ b/src/util/migration/postgres/1765143034407-DontIpBanBanner.ts @@ -0,0 +1,16 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class DontIpBanBanner1765143034407 implements MigrationInterface { + name = 'DontIpBanBanner1765143034407' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "bans" ALTER COLUMN "ip" DROP NOT NULL`); + await queryRunner.query(`UPDATE "bans" SET "ip" = NULL`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`UPDATE "bans" SET "ip" = '0.0.0.0' WHERE "ip" IS NULL`); + await queryRunner.query(`ALTER TABLE "bans" ALTER COLUMN "ip" SET NOT NULL`); + } + +}