summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2025-07-27 20:14:23 +0200
committerRory& <root@rory.gay>2025-07-27 20:14:56 +0200
commita245945bed07ed054f6913ce0cd6e1335880d216 (patch)
tree32ddfcb975b4c5d3c6501513ca0f84ffe5f5c958 /src
parentMore cleanup (diff)
downloadserver-ts-a245945bed07ed054f6913ce0cd6e1335880d216.tar.xz
Add automod migration
Diffstat (limited to 'src')
-rw-r--r--src/util/entities/AutomodRule.ts3
-rw-r--r--src/util/migration/postgres/1753639700904-Automod.ts16
2 files changed, 18 insertions, 1 deletions
diff --git a/src/util/entities/AutomodRule.ts b/src/util/entities/AutomodRule.ts

index 7d983ee2b..a45a7c152 100644 --- a/src/util/entities/AutomodRule.ts +++ b/src/util/entities/AutomodRule.ts
@@ -16,9 +16,10 @@ along with this program. If not, see <https://www.gnu.org/licenses/>. */ -import { dbEngine, User } from "@spacebar/util"; +import { dbEngine } from "@spacebar/util"; import { BaseClass } from "./BaseClass"; import { Entity, JoinColumn, ManyToOne, Column } from "typeorm"; +import { User } from "./User"; export class AutomodMentionSpamRule { mention_total_limit: number; diff --git a/src/util/migration/postgres/1753639700904-Automod.ts b/src/util/migration/postgres/1753639700904-Automod.ts new file mode 100644
index 000000000..d12c95636 --- /dev/null +++ b/src/util/migration/postgres/1753639700904-Automod.ts
@@ -0,0 +1,16 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class Automod1753639700904 implements MigrationInterface { + name = 'Automod1753639700904' + + public async up(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(`CREATE TABLE "automod_rules" ("id" character varying NOT NULL, "enabled" boolean NOT NULL, "event_type" integer NOT NULL, "exempt_channels" text NOT NULL, "exempt_roles" text NOT NULL, "guild_id" character varying NOT NULL, "name" character varying NOT NULL, "position" integer NOT NULL, "trigger_type" integer NOT NULL, "trigger_metadata" text, "actions" text NOT NULL, "creator_id" character varying, CONSTRAINT "PK_99789ae863507f5aed9e58d7866" PRIMARY KEY ("id"))`); + await queryRunner.query(`ALTER TABLE "automod_rules" ADD CONSTRAINT "FK_12d3d60b961393d310429c062b7" FOREIGN KEY ("creator_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + } + + public async down(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(`ALTER TABLE "automod_rules" DROP CONSTRAINT "FK_12d3d60b961393d310429c062b7"`); + await queryRunner.query(`DROP TABLE "automod_rules"`); + } + +}