mirror of
https://github.com/spacebarchat/server.git
synced 2026-08-27 22:34:11 +00:00
sechema changes+migrations
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -37,6 +37,14 @@ export enum ChannelPermissionOverwriteType {
|
||||
member = 1,
|
||||
group = 2,
|
||||
}
|
||||
export interface threadMetadata {
|
||||
archived: boolean;
|
||||
auto_archive_duration: number;
|
||||
archive_timestamp: string;
|
||||
locked: boolean;
|
||||
invitable?: boolean;
|
||||
create_timestamp: string; //Discord docs say this is optional, but it's only for after a certain date so it's not
|
||||
}
|
||||
|
||||
export interface DMChannel extends Omit<Channel, "type" | "recipients"> {
|
||||
type: ChannelType.DM | ChannelType.GROUP_DM;
|
||||
|
||||
@@ -31,7 +31,7 @@ import { User } from "./User";
|
||||
import { VoiceState } from "./VoiceState";
|
||||
import { Webhook } from "./Webhook";
|
||||
import { Member } from "./Member";
|
||||
import { ChannelPermissionOverwrite, ChannelPermissionOverwriteType, ChannelType, PublicUserProjection } from "@spacebar/schemas";
|
||||
import { ChannelPermissionOverwrite, ChannelPermissionOverwriteType, ChannelType, PublicUserProjection, threadMetadata } from "@spacebar/schemas";
|
||||
|
||||
@Entity({
|
||||
name: "channels",
|
||||
@@ -152,6 +152,18 @@ export class Channel extends BaseClass {
|
||||
@Column({ nullable: true })
|
||||
default_thread_rate_limit_per_user?: number = 0;
|
||||
|
||||
@Column({ type: "simple-json", nullable: true })
|
||||
thread_metadata?: threadMetadata;
|
||||
|
||||
@Column({ nullable: true })
|
||||
member_count?: number;
|
||||
|
||||
@Column({ nullable: true })
|
||||
message_count?: number;
|
||||
|
||||
@Column({ nullable: true })
|
||||
total_message_sent?: number;
|
||||
|
||||
/** Must be calculated Channel.calculatePosition */
|
||||
position: number;
|
||||
|
||||
|
||||
@@ -48,6 +48,16 @@ export class Message extends BaseClass {
|
||||
})
|
||||
channel: Channel;
|
||||
|
||||
@Column({ nullable: true })
|
||||
@RelationId((message: Message) => message.thread)
|
||||
thread_id?: string;
|
||||
|
||||
@JoinColumn({ name: "channel_id" })
|
||||
@ManyToOne(() => Channel, {
|
||||
onDelete: "CASCADE",
|
||||
})
|
||||
thread?: Channel;
|
||||
|
||||
@Column({ nullable: true })
|
||||
@RelationId((message: Message) => message.guild)
|
||||
guild_id?: string;
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class Threads1764609924756 implements MigrationInterface {
|
||||
name = "Threads1764609924756";
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "messages" DROP CONSTRAINT "FK_bb3af7f695d50083e6523290d41"`);
|
||||
await queryRunner.query(`ALTER TABLE "channels" DROP COLUMN "total_message_sent"`);
|
||||
await queryRunner.query(`ALTER TABLE "channels" ADD "total_messsage_sent" integer`);
|
||||
await queryRunner.query(`ALTER TABLE "channels" ALTER COLUMN "thread_metadata" DROP NOT NULL`);
|
||||
await queryRunner.query(`ALTER TABLE "channels" ALTER COLUMN "member_count" DROP NOT NULL`);
|
||||
await queryRunner.query(`ALTER TABLE "channels" ALTER COLUMN "message_count" DROP NOT NULL`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "channels" ALTER COLUMN "message_count" SET NOT NULL`);
|
||||
await queryRunner.query(`ALTER TABLE "channels" ALTER COLUMN "member_count" SET NOT NULL`);
|
||||
await queryRunner.query(`ALTER TABLE "channels" ALTER COLUMN "thread_metadata" SET NOT NULL`);
|
||||
await queryRunner.query(`ALTER TABLE "channels" DROP COLUMN "total_messsage_sent"`);
|
||||
await queryRunner.query(`ALTER TABLE "channels" ADD "total_message_sent" integer NOT NULL`);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "messages" ADD CONSTRAINT "FK_bb3af7f695d50083e6523290d41" FOREIGN KEY ("thread_id") REFERENCES "channels"("id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class Threadtypo1764610059742 implements MigrationInterface {
|
||||
name = "Threadtypo1764610059742";
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "messages" DROP CONSTRAINT "FK_bb3af7f695d50083e6523290d41"`);
|
||||
await queryRunner.query(`ALTER TABLE "channels" DROP COLUMN "total_message_sent"`);
|
||||
await queryRunner.query(`ALTER TABLE "channels" ADD "total_messsage_sent" integer`);
|
||||
await queryRunner.query(`ALTER TABLE "channels" ALTER COLUMN "thread_metadata" DROP NOT NULL`);
|
||||
await queryRunner.query(`ALTER TABLE "channels" ALTER COLUMN "member_count" DROP NOT NULL`);
|
||||
await queryRunner.query(`ALTER TABLE "channels" ALTER COLUMN "message_count" DROP NOT NULL`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "channels" ALTER COLUMN "message_count" SET NOT NULL`);
|
||||
await queryRunner.query(`ALTER TABLE "channels" ALTER COLUMN "member_count" SET NOT NULL`);
|
||||
await queryRunner.query(`ALTER TABLE "channels" ALTER COLUMN "thread_metadata" SET NOT NULL`);
|
||||
await queryRunner.query(`ALTER TABLE "channels" DROP COLUMN "total_messsage_sent"`);
|
||||
await queryRunner.query(`ALTER TABLE "channels" ADD "total_message_sent" integer NOT NULL`);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "messages" ADD CONSTRAINT "FK_bb3af7f695d50083e6523290d41" FOREIGN KEY ("thread_id") REFERENCES "channels"("id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user