KI-AGENT: Matrix durch nativen FEDEO-Chat ersetzen
This commit is contained in:
@@ -8,9 +8,6 @@ CREATE TABLE "communication_rooms" (
|
||||
"entity_type" text,
|
||||
"entity_id" bigint,
|
||||
"entity_uuid" uuid,
|
||||
"matrix_room_id" text,
|
||||
"matrix_alias" text,
|
||||
"parent_space_room_id" text,
|
||||
"archived" boolean DEFAULT false NOT NULL,
|
||||
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||
"updated_at" timestamp with time zone,
|
||||
|
||||
@@ -8,9 +8,6 @@ CREATE TABLE IF NOT EXISTS "communication_rooms" (
|
||||
"entity_type" text,
|
||||
"entity_id" bigint,
|
||||
"entity_uuid" uuid,
|
||||
"matrix_room_id" text,
|
||||
"matrix_alias" text,
|
||||
"parent_space_room_id" text,
|
||||
"archived" boolean DEFAULT false NOT NULL,
|
||||
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||
"updated_at" timestamp with time zone,
|
||||
|
||||
42
backend/db/migrations/0070_native_communication_chat.sql
Normal file
42
backend/db/migrations/0070_native_communication_chat.sql
Normal file
@@ -0,0 +1,42 @@
|
||||
ALTER TABLE "communication_rooms" DROP COLUMN IF EXISTS "matrix_room_id";
|
||||
ALTER TABLE "communication_rooms" DROP COLUMN IF EXISTS "matrix_alias";
|
||||
ALTER TABLE "communication_rooms" DROP COLUMN IF EXISTS "parent_space_room_id";
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "communication_room_members" (
|
||||
"room_id" uuid NOT NULL REFERENCES "communication_rooms"("id") ON DELETE cascade,
|
||||
"user_id" uuid NOT NULL REFERENCES "auth_users"("id") ON DELETE cascade,
|
||||
"joined_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||
CONSTRAINT "communication_room_members_room_id_user_id_pk" PRIMARY KEY ("room_id", "user_id")
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS "communication_room_members_user_idx"
|
||||
ON "communication_room_members" ("user_id");
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "communication_messages" (
|
||||
"id" bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
"tenant_id" bigint NOT NULL REFERENCES "tenants"("id") ON DELETE cascade,
|
||||
"room_id" uuid NOT NULL REFERENCES "communication_rooms"("id") ON DELETE cascade,
|
||||
"author_user_id" uuid NOT NULL REFERENCES "auth_users"("id"),
|
||||
"body" text NOT NULL,
|
||||
"created_at" timestamp with time zone DEFAULT now() NOT NULL
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS "communication_messages_room_message_idx"
|
||||
ON "communication_messages" ("room_id", "id");
|
||||
CREATE INDEX IF NOT EXISTS "communication_messages_tenant_idx"
|
||||
ON "communication_messages" ("tenant_id");
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "communication_room_reads" (
|
||||
"room_id" uuid NOT NULL REFERENCES "communication_rooms"("id") ON DELETE cascade,
|
||||
"user_id" uuid NOT NULL REFERENCES "auth_users"("id") ON DELETE cascade,
|
||||
"last_read_message_id" bigint,
|
||||
"read_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||
CONSTRAINT "communication_room_reads_room_id_user_id_pk" PRIMARY KEY ("room_id", "user_id")
|
||||
);
|
||||
|
||||
INSERT INTO "communication_room_members" ("room_id", "user_id")
|
||||
SELECT room.id, tenant_user.user_id
|
||||
FROM "communication_rooms" room
|
||||
JOIN "auth_tenant_users" tenant_user ON tenant_user.tenant_id = room.tenant_id
|
||||
WHERE room.type IN ('general', 'room')
|
||||
ON CONFLICT DO NOTHING;
|
||||
@@ -470,6 +470,13 @@
|
||||
"when": 1788803000000,
|
||||
"tag": "0069_reset_email_entity_suggestions",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 67,
|
||||
"version": "7",
|
||||
"when": 1788850800000,
|
||||
"tag": "0070_native_communication_chat",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
34
backend/db/schema/communication_messages.ts
Normal file
34
backend/db/schema/communication_messages.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { bigint, index, pgTable, text, timestamp, uuid } from "drizzle-orm/pg-core"
|
||||
|
||||
import { authUsers } from "./auth_users"
|
||||
import { communicationRooms } from "./communication_rooms"
|
||||
import { tenants } from "./tenants"
|
||||
|
||||
export const communicationMessages = pgTable(
|
||||
"communication_messages",
|
||||
{
|
||||
id: bigint("id", { mode: "number" })
|
||||
.primaryKey()
|
||||
.generatedByDefaultAsIdentity(),
|
||||
tenantId: bigint("tenant_id", { mode: "number" })
|
||||
.notNull()
|
||||
.references(() => tenants.id, { onDelete: "cascade" }),
|
||||
roomId: uuid("room_id")
|
||||
.notNull()
|
||||
.references(() => communicationRooms.id, { onDelete: "cascade" }),
|
||||
authorUserId: uuid("author_user_id")
|
||||
.notNull()
|
||||
.references(() => authUsers.id),
|
||||
body: text("body").notNull(),
|
||||
createdAt: timestamp("created_at", { withTimezone: true })
|
||||
.notNull()
|
||||
.defaultNow(),
|
||||
},
|
||||
(table) => ({
|
||||
roomMessageIdx: index("communication_messages_room_message_idx").on(table.roomId, table.id),
|
||||
tenantIdx: index("communication_messages_tenant_idx").on(table.tenantId),
|
||||
})
|
||||
)
|
||||
|
||||
export type CommunicationMessage = typeof communicationMessages.$inferSelect
|
||||
export type NewCommunicationMessage = typeof communicationMessages.$inferInsert
|
||||
26
backend/db/schema/communication_room_members.ts
Normal file
26
backend/db/schema/communication_room_members.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { index, pgTable, primaryKey, timestamp, uuid } from "drizzle-orm/pg-core"
|
||||
|
||||
import { authUsers } from "./auth_users"
|
||||
import { communicationRooms } from "./communication_rooms"
|
||||
|
||||
export const communicationRoomMembers = pgTable(
|
||||
"communication_room_members",
|
||||
{
|
||||
roomId: uuid("room_id")
|
||||
.notNull()
|
||||
.references(() => communicationRooms.id, { onDelete: "cascade" }),
|
||||
userId: uuid("user_id")
|
||||
.notNull()
|
||||
.references(() => authUsers.id, { onDelete: "cascade" }),
|
||||
joinedAt: timestamp("joined_at", { withTimezone: true })
|
||||
.notNull()
|
||||
.defaultNow(),
|
||||
},
|
||||
(table) => ({
|
||||
pk: primaryKey({ columns: [table.roomId, table.userId] }),
|
||||
userIdx: index("communication_room_members_user_idx").on(table.userId),
|
||||
})
|
||||
)
|
||||
|
||||
export type CommunicationRoomMember = typeof communicationRoomMembers.$inferSelect
|
||||
export type NewCommunicationRoomMember = typeof communicationRoomMembers.$inferInsert
|
||||
26
backend/db/schema/communication_room_reads.ts
Normal file
26
backend/db/schema/communication_room_reads.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { bigint, pgTable, primaryKey, timestamp, uuid } from "drizzle-orm/pg-core"
|
||||
|
||||
import { authUsers } from "./auth_users"
|
||||
import { communicationRooms } from "./communication_rooms"
|
||||
|
||||
export const communicationRoomReads = pgTable(
|
||||
"communication_room_reads",
|
||||
{
|
||||
roomId: uuid("room_id")
|
||||
.notNull()
|
||||
.references(() => communicationRooms.id, { onDelete: "cascade" }),
|
||||
userId: uuid("user_id")
|
||||
.notNull()
|
||||
.references(() => authUsers.id, { onDelete: "cascade" }),
|
||||
lastReadMessageId: bigint("last_read_message_id", { mode: "number" }),
|
||||
readAt: timestamp("read_at", { withTimezone: true })
|
||||
.notNull()
|
||||
.defaultNow(),
|
||||
},
|
||||
(table) => ({
|
||||
pk: primaryKey({ columns: [table.roomId, table.userId] }),
|
||||
})
|
||||
)
|
||||
|
||||
export type CommunicationRoomRead = typeof communicationRoomReads.$inferSelect
|
||||
export type NewCommunicationRoomRead = typeof communicationRoomReads.$inferInsert
|
||||
@@ -30,10 +30,6 @@ export const communicationRooms = pgTable(
|
||||
entityId: bigint("entity_id", { mode: "number" }),
|
||||
entityUuid: uuid("entity_uuid"),
|
||||
|
||||
matrixRoomId: text("matrix_room_id"),
|
||||
matrixAlias: text("matrix_alias"),
|
||||
parentSpaceRoomId: text("parent_space_room_id"),
|
||||
|
||||
archived: boolean("archived").notNull().default(false),
|
||||
|
||||
createdAt: timestamp("created_at", { withTimezone: true })
|
||||
|
||||
@@ -16,6 +16,9 @@ export * from "./checkexecutions"
|
||||
export * from "./checks"
|
||||
export * from "./citys"
|
||||
export * from "./communication_rooms"
|
||||
export * from "./communication_room_members"
|
||||
export * from "./communication_messages"
|
||||
export * from "./communication_room_reads"
|
||||
export * from "./contacts"
|
||||
export * from "./contracts"
|
||||
export * from "./contracttypes"
|
||||
|
||||
Reference in New Issue
Block a user