From 747884c3b99bd7217015dbe55a51850ab3b414a4 Mon Sep 17 00:00:00 2001 From: Oliver Levay Date: Mon, 9 Dec 2024 23:32:20 +0100 Subject: [PATCH 1/2] prepare database for coming work to be done --- .../20241209223044_meetings/migration.sql | 124 ++ src/database/prisma/schema.prisma | 102 +- src/database/schema.zmodel | 102 +- src/database/seed/.snaplet/dataModel.json | 1052 +++++++++++++++-- 4 files changed, 1278 insertions(+), 102 deletions(-) create mode 100644 src/database/prisma/migrations/20241209223044_meetings/migration.sql diff --git a/src/database/prisma/migrations/20241209223044_meetings/migration.sql b/src/database/prisma/migrations/20241209223044_meetings/migration.sql new file mode 100644 index 000000000..cc2bcfc5b --- /dev/null +++ b/src/database/prisma/migrations/20241209223044_meetings/migration.sql @@ -0,0 +1,124 @@ +/* + Warnings: + + - You are about to drop the column `date` on the `meetings` table. All the data in the column will be lost. + - You are about to drop the column `url` on the `meetings` table. All the data in the column will be lost. + - A unique constraint covering the columns `[notice_id]` on the table `meetings` will be added. If there are existing duplicate values, this will fail. + - A unique constraint covering the columns `[agenda_id]` on the table `meetings` will be added. If there are existing duplicate values, this will fail. + - A unique constraint covering the columns `[minutes_id]` on the table `meetings` will be added. If there are existing duplicate values, this will fail. + - Added the required column `end` to the `meetings` table without a default value. This is not possible if the table is not empty. + - Added the required column `start` to the `meetings` table without a default value. This is not possible if the table is not empty. + - Added the required column `type` to the `meetings` table without a default value. This is not possible if the table is not empty. + +*/ +-- DropIndex +DROP INDEX "meetings_url_key"; + +-- AlterTable +ALTER TABLE "meetings" DROP COLUMN "date", +DROP COLUMN "url", +ADD COLUMN "agenda_id" UUID, +ADD COLUMN "created_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP, +ADD COLUMN "description" VARCHAR(255), +ADD COLUMN "end" TIMESTAMPTZ(6) NOT NULL, +ADD COLUMN "minutes_id" UUID, +ADD COLUMN "notice_id" UUID, +ADD COLUMN "start" TIMESTAMPTZ(6) NOT NULL, +ADD COLUMN "type" VARCHAR(255) NOT NULL, +ADD COLUMN "updated_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP; + +-- CreateTable +CREATE TABLE "meeting_agenda_items" ( + "id" UUID NOT NULL DEFAULT gen_random_uuid(), + "title" VARCHAR(255) NOT NULL, + "description" VARCHAR(255), + "type" VARCHAR(255) NOT NULL, + "created_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP, + "updated_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP, + "start" TIMESTAMPTZ(6) NOT NULL, + "end" TIMESTAMPTZ(6) NOT NULL, + "meeting_id" UUID NOT NULL, + + CONSTRAINT "meeting_agenda_items_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "MeetingAgendaAttachment" ( + "id" UUID NOT NULL DEFAULT gen_random_uuid(), + "file_url" VARCHAR(255) NOT NULL, + "order" INTEGER NOT NULL DEFAULT 0, + "meetingAgendaItemId" UUID NOT NULL, + + CONSTRAINT "MeetingAgendaAttachment_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "MeetingAttachment" ( + "id" UUID NOT NULL DEFAULT gen_random_uuid(), + "file_url" VARCHAR(255) NOT NULL, + "order" INTEGER NOT NULL DEFAULT 0, + + CONSTRAINT "MeetingAttachment_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "speakers" ( + "id" UUID NOT NULL DEFAULT gen_random_uuid(), + "meeting_id" UUID NOT NULL, + "member_id" UUID NOT NULL, + "start" TIMESTAMPTZ(6) NOT NULL, + "end" TIMESTAMPTZ(6) NOT NULL, + "createdAt" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "speakers_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "meeting_logs" ( + "id" UUID NOT NULL DEFAULT gen_random_uuid(), + "meeting_id" UUID NOT NULL, + "member_id" UUID NOT NULL, + "createdAt" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "comment" TEXT NOT NULL, + "happenedAt" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "meeting_logs_pkey" PRIMARY KEY ("id") +); + +-- CreateIndex +CREATE UNIQUE INDEX "meetings_notice_id_key" ON "meetings"("notice_id"); + +-- CreateIndex +CREATE UNIQUE INDEX "meetings_agenda_id_key" ON "meetings"("agenda_id"); + +-- CreateIndex +CREATE UNIQUE INDEX "meetings_minutes_id_key" ON "meetings"("minutes_id"); + +-- AddForeignKey +ALTER TABLE "meetings" ADD CONSTRAINT "meetings_notice_id_fkey" FOREIGN KEY ("notice_id") REFERENCES "MeetingAttachment"("id") ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "meetings" ADD CONSTRAINT "meetings_agenda_id_fkey" FOREIGN KEY ("agenda_id") REFERENCES "MeetingAttachment"("id") ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "meetings" ADD CONSTRAINT "meetings_minutes_id_fkey" FOREIGN KEY ("minutes_id") REFERENCES "MeetingAttachment"("id") ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "meeting_agenda_items" ADD CONSTRAINT "meeting_agenda_items_meeting_id_foreign" FOREIGN KEY ("meeting_id") REFERENCES "meetings"("id") ON DELETE CASCADE ON UPDATE NO ACTION; + +-- AddForeignKey +ALTER TABLE "MeetingAgendaAttachment" ADD CONSTRAINT "MeetingAgendaAttachment_meetingAgendaItemId_fkey" FOREIGN KEY ("meetingAgendaItemId") REFERENCES "meeting_agenda_items"("id") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "speakers" ADD CONSTRAINT "speakers_meeting_id_foreign" FOREIGN KEY ("meeting_id") REFERENCES "meetings"("id") ON DELETE CASCADE ON UPDATE NO ACTION; + +-- AddForeignKey +ALTER TABLE "speakers" ADD CONSTRAINT "speakers_member_id_foreign" FOREIGN KEY ("member_id") REFERENCES "members"("id") ON DELETE CASCADE ON UPDATE NO ACTION; + +-- AddForeignKey +ALTER TABLE "meeting_logs" ADD CONSTRAINT "meeting_logs_meeting_id_foreign" FOREIGN KEY ("meeting_id") REFERENCES "meetings"("id") ON DELETE CASCADE ON UPDATE NO ACTION; + +-- AddForeignKey +ALTER TABLE "meeting_logs" ADD CONSTRAINT "meeting_logs_member_id_foreign" FOREIGN KEY ("member_id") REFERENCES "members"("id") ON DELETE CASCADE ON UPDATE NO ACTION; diff --git a/src/database/prisma/schema.prisma b/src/database/prisma/schema.prisma index b2756b2d4..077f5bd63 100644 --- a/src/database/prisma/schema.prisma +++ b/src/database/prisma/schema.prisma @@ -539,19 +539,6 @@ model Markdown { @@map("markdowns") } -/// @@allow('create', has(auth().policies, 'fileHandler:documents:create')) -/// @@allow('read', has(auth().policies, 'fileHandler:documents:read')) -/// @@allow('update', has(auth().policies, 'fileHandler:documents:update')) -/// @@allow('delete', has(auth().policies, 'fileHandler:documents:delete')) -model Meeting { - id String @id() @default(dbgenerated("gen_random_uuid()")) @db.Uuid() - title String @db.VarChar(255) - date DateTime @db.Date() - url String @unique() @db.VarChar(255) - - @@map("meetings") -} - /// @@allow('create', has(auth().policies, 'core:member:create')) /// @@allow('create', auth().studentId == studentId) /// @@allow('read', has(auth().policies, 'core:member:read')) @@ -600,6 +587,8 @@ model Member { shopReservations ConsumableReservation[] bookingRequests BookingRequest[] recurringEvent RecurringEvent[] + speaker Speaker[] + meetingLog MeetingLog[] @@map("members") } @@ -1073,4 +1062,91 @@ model ShoppableAccessPolicy { createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6) @@map("shoppable_access_policies") +} + +/// @@allow('create', has(auth().policies, 'fileHandler:documents:create')) +/// @@allow('read', has(auth().policies, 'fileHandler:documents:read')) +/// @@allow('update', has(auth().policies, 'fileHandler:documents:update')) +/// @@allow('delete', has(auth().policies, 'fileHandler:documents:delete')) +model Meeting { + id String @id() @default(dbgenerated("gen_random_uuid()")) @db.Uuid() + title String @db.VarChar(255) + description String? @db.VarChar(255) + type String @db.VarChar(255) + createdAt DateTime? @default(now()) @map("created_at") @db.Timestamptz(6) + updatedAt DateTime? @default(now()) @map("updated_at") @db.Timestamptz(6) @updatedAt() + start DateTime @db.Timestamptz(6) + end DateTime @db.Timestamptz(6) + items MeetingAgendaItem[] + notice MeetingAttachment? @relation("meeting_notice", fields: [noticeId], references: [id]) + noticeId String? @map("notice_id") @db.Uuid() @unique() + agenda MeetingAttachment? @relation("meeting_agenda", fields: [agendaId], references: [id]) + agendaId String? @map("agenda_id") @db.Uuid() @unique() + minutes MeetingAttachment? @relation("meeting_minutes", fields: [minutesId], references: [id]) + minutesId String? @map("minutes_id") @db.Uuid() @unique() + speakersList Speaker[] + meetingLog MeetingLog[] + + @@map("meetings") +} + +model MeetingAgendaItem { + id String @id() @default(dbgenerated("gen_random_uuid()")) @db.Uuid() + title String @db.VarChar(255) + description String? @db.VarChar(255) + type String @db.VarChar(255) + createdAt DateTime? @default(now()) @map("created_at") @db.Timestamptz(6) + updatedAt DateTime? @default(now()) @map("updated_at") @db.Timestamptz(6) @updatedAt() + start DateTime @db.Timestamptz(6) + end DateTime @db.Timestamptz(6) + meetingId String @map("meeting_id") @db.Uuid() + meeting Meeting @relation(fields: [meetingId], references: [id], onDelete: Cascade, onUpdate: NoAction, map: "meeting_agenda_items_meeting_id_foreign") + attachments MeetingAgendaAttachment[] + + @@map("meeting_agenda_items") +} + +model MeetingAgendaAttachment { + id String @id() @default(dbgenerated("gen_random_uuid()")) @db.Uuid() + fileUrl String @map("file_url") @db.VarChar(255) + order Int @default(0) + meetingAgendaItem MeetingAgendaItem @relation(fields: [meetingAgendaItemId], references: [id]) + meetingAgendaItemId String @db.Uuid() +} + +model MeetingAttachment { + id String @id() @default(dbgenerated("gen_random_uuid()")) @db.Uuid() + fileUrl String @map("file_url") @db.VarChar(255) + order Int @default(0) + noticeFor Meeting[] @relation("meeting_notice") + minutesFor Meeting[] @relation("meeting_minutes") + agendaFor Meeting[] @relation("meeting_agenda") +} + +model Speaker { + id String @id() @default(dbgenerated("gen_random_uuid()")) @db.Uuid() + meetingId String @map("meeting_id") @db.Uuid() + memberId String @map("member_id") @db.Uuid() + meeting Meeting @relation(fields: [meetingId], references: [id], onDelete: Cascade, onUpdate: NoAction, map: "speakers_meeting_id_foreign") + member Member @relation(fields: [memberId], references: [id], onDelete: Cascade, onUpdate: NoAction, map: "speakers_member_id_foreign") + start DateTime @db.Timestamptz(6) + end DateTime @db.Timestamptz(6) + createdAt DateTime @default(now()) @db.Timestamptz(6) + updatedAt DateTime @default(now()) @db.Timestamptz(6) @updatedAt() + + @@map("speakers") +} + +model MeetingLog { + id String @id() @default(dbgenerated("gen_random_uuid()")) @db.Uuid() + meetingId String @map("meeting_id") @db.Uuid() + memberId String @map("member_id") @db.Uuid() + meeting Meeting @relation(fields: [meetingId], references: [id], onDelete: Cascade, onUpdate: NoAction, map: "meeting_logs_meeting_id_foreign") + member Member @relation(fields: [memberId], references: [id], onDelete: Cascade, onUpdate: NoAction, map: "meeting_logs_member_id_foreign") + createdAt DateTime @default(now()) @db.Timestamptz(6) + updatedAt DateTime @default(now()) @db.Timestamptz(6) @updatedAt() + comment String @db.Text() + happenedAt DateTime @default(now()) @db.Timestamptz(6) + + @@map("meeting_logs") } \ No newline at end of file diff --git a/src/database/schema.zmodel b/src/database/schema.zmodel index 51c7bf6a4..9e74074bd 100644 --- a/src/database/schema.zmodel +++ b/src/database/schema.zmodel @@ -536,19 +536,6 @@ model Markdown { @@map("markdowns") } -model Meeting { - id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid - title String @db.VarChar(255) - date DateTime @db.Date - url String @unique @db.VarChar(255) - - @@allow("create", has(auth().policies, "fileHandler:documents:create")) - @@allow("read", has(auth().policies, "fileHandler:documents:read")) - @@allow("update", has(auth().policies, "fileHandler:documents:update")) - @@allow("delete", has(auth().policies, "fileHandler:documents:delete")) - @@map("meetings") -} - /// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-commentsmodel Members{ model Member { id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid @@ -599,6 +586,10 @@ model Member { @@allow('update', has(auth().policies, "core:member:update")) @@allow('delete', has(auth().policies, "core:member:delete")) @@map("members") + + speaker Speaker[] + + meetingLog MeetingLog[] } /// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-commentsmodel Notifications{ @@ -1152,4 +1143,89 @@ model ShoppableAccessPolicy { // only managers can delete (should very rarely be done) @@allow("delete", auth().memberId == shoppable.authorId || has(auth().policies, "webshop:manage")) @@map("shoppable_access_policies") +} + +abstract model MeetingBase { + id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid + title String @db.VarChar(255) + description String? @db.VarChar(255) + type String @db.VarChar(255) + createdAt DateTime? @default(now()) @map("created_at") @db.Timestamptz(6) + updatedAt DateTime? @default(now()) @map("updated_at") @db.Timestamptz(6) @updatedAt() + start DateTime @db.Timestamptz(6) + end DateTime @db.Timestamptz(6) +} + +model Meeting extends MeetingBase { + + items MeetingAgendaItem[] + // Remove the "notice" field from the "Meeting" model + notice MeetingAttachment? @relation("meeting_notice", fields: [noticeId], references: [id]) + noticeId String? @map("notice_id") @db.Uuid @unique + agenda MeetingAttachment? @relation("meeting_agenda", fields: [agendaId], references: [id]) + agendaId String? @map("agenda_id") @db.Uuid @unique + minutes MeetingAttachment? @relation("meeting_minutes", fields: [minutesId], references: [id]) + minutesId String? @map("minutes_id") @db.Uuid @unique + + @@allow("create", has(auth().policies, "fileHandler:documents:create")) + @@allow("read", has(auth().policies, "fileHandler:documents:read")) + @@allow("update", has(auth().policies, "fileHandler:documents:update")) + @@allow("delete", has(auth().policies, "fileHandler:documents:delete")) + @@map("meetings") + + speakersList Speaker[] + + meetingLog MeetingLog[] +} + +// These are the bullet points of a meeting, equal to the ones in the meeting agenda document +model MeetingAgendaItem extends MeetingBase { + meetingId String @map("meeting_id") @db.Uuid + meeting Meeting @relation(fields: [meetingId], references: [id], onDelete: Cascade, onUpdate: NoAction, map: "meeting_agenda_items_meeting_id_foreign") + attachments MeetingAgendaAttachment[] + @@map("meeting_agenda_items") +} + +// An attachment to either an item or a meeting +abstract model MeetingAttachmentBase { + id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid + fileUrl String @map("file_url") @db.VarChar(255) + order Int @default(0) +} + +model MeetingAgendaAttachment extends MeetingAttachmentBase { + meetingAgendaItem MeetingAgendaItem @relation(fields: [meetingAgendaItemId], references: [id]) + meetingAgendaItemId String @db.Uuid +} + +model MeetingAttachment extends MeetingAttachmentBase { + noticeFor Meeting[] @relation("meeting_notice") + minutesFor Meeting[] @relation("meeting_minutes") + agendaFor Meeting[] @relation("meeting_agenda") +} + +model Speaker { + id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid + meetingId String @map("meeting_id") @db.Uuid + memberId String @map("member_id") @db.Uuid + meeting Meeting @relation(fields: [meetingId], references: [id], onDelete: Cascade, onUpdate: NoAction, map: "speakers_meeting_id_foreign") + member Member @relation(fields: [memberId], references: [id], onDelete: Cascade, onUpdate: NoAction, map: "speakers_member_id_foreign") + start DateTime @db.Timestamptz(6) + end DateTime @db.Timestamptz(6) + createdAt DateTime @default(now()) @db.Timestamptz(6) + updatedAt DateTime @default(now()) @db.Timestamptz(6) @updatedAt() + @@map("speakers") +} + +model MeetingLog { + id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid + meetingId String @map("meeting_id") @db.Uuid + memberId String @map("member_id") @db.Uuid + meeting Meeting @relation(fields: [meetingId], references: [id], onDelete: Cascade, onUpdate: NoAction, map: "meeting_logs_meeting_id_foreign") + member Member @relation(fields: [memberId], references: [id], onDelete: Cascade, onUpdate: NoAction, map: "meeting_logs_member_id_foreign") + createdAt DateTime @default(now()) @db.Timestamptz(6) + updatedAt DateTime @default(now()) @db.Timestamptz(6) @updatedAt() + comment String @db.Text + happenedAt DateTime @default(now()) @db.Timestamptz(6) + @@map("meeting_logs") } \ No newline at end of file diff --git a/src/database/seed/.snaplet/dataModel.json b/src/database/seed/.snaplet/dataModel.json index 04012fac5..ef5c82109 100644 --- a/src/database/seed/.snaplet/dataModel.json +++ b/src/database/seed/.snaplet/dataModel.json @@ -1,5 +1,195 @@ { "models": { + "MeetingAgendaAttachment": { + "id": "public.MeetingAgendaAttachment", + "schemaName": "public", + "tableName": "MeetingAgendaAttachment", + "fields": [ + { + "id": "public.MeetingAgendaAttachment.id", + "name": "id", + "columnName": "id", + "type": "uuid", + "isRequired": true, + "kind": "scalar", + "isList": false, + "isGenerated": false, + "sequence": false, + "hasDefaultValue": true, + "isId": true, + "maxLength": null + }, + { + "id": "public.MeetingAgendaAttachment.file_url", + "name": "file_url", + "columnName": "file_url", + "type": "varchar", + "isRequired": true, + "kind": "scalar", + "isList": false, + "isGenerated": false, + "sequence": false, + "hasDefaultValue": false, + "isId": false, + "maxLength": 255 + }, + { + "id": "public.MeetingAgendaAttachment.order", + "name": "order", + "columnName": "order", + "type": "int4", + "isRequired": true, + "kind": "scalar", + "isList": false, + "isGenerated": false, + "sequence": false, + "hasDefaultValue": true, + "isId": false, + "maxLength": null + }, + { + "id": "public.MeetingAgendaAttachment.meetingAgendaItemId", + "name": "meetingAgendaItemId", + "columnName": "meetingAgendaItemId", + "type": "uuid", + "isRequired": true, + "kind": "scalar", + "isList": false, + "isGenerated": false, + "sequence": false, + "hasDefaultValue": false, + "isId": false, + "maxLength": null + }, + { + "name": "meeting_agenda_items", + "type": "meeting_agenda_items", + "isRequired": true, + "kind": "object", + "relationName": "MeetingAgendaAttachmentTomeeting_agenda_items", + "relationFromFields": [ + "meetingAgendaItemId" + ], + "relationToFields": [ + "id" + ], + "isList": false, + "isId": false, + "isGenerated": false, + "sequence": false, + "hasDefaultValue": false + } + ], + "uniqueConstraints": [ + { + "name": "MeetingAgendaAttachment_pkey", + "fields": [ + "id" + ], + "nullNotDistinct": false + } + ] + }, + "MeetingAttachment": { + "id": "public.MeetingAttachment", + "schemaName": "public", + "tableName": "MeetingAttachment", + "fields": [ + { + "id": "public.MeetingAttachment.id", + "name": "id", + "columnName": "id", + "type": "uuid", + "isRequired": true, + "kind": "scalar", + "isList": false, + "isGenerated": false, + "sequence": false, + "hasDefaultValue": true, + "isId": true, + "maxLength": null + }, + { + "id": "public.MeetingAttachment.file_url", + "name": "file_url", + "columnName": "file_url", + "type": "varchar", + "isRequired": true, + "kind": "scalar", + "isList": false, + "isGenerated": false, + "sequence": false, + "hasDefaultValue": false, + "isId": false, + "maxLength": 255 + }, + { + "id": "public.MeetingAttachment.order", + "name": "order", + "columnName": "order", + "type": "int4", + "isRequired": true, + "kind": "scalar", + "isList": false, + "isGenerated": false, + "sequence": false, + "hasDefaultValue": true, + "isId": false, + "maxLength": null + }, + { + "name": "meetings_meetings_agenda_idToMeetingAttachment", + "type": "meetings", + "isRequired": false, + "kind": "object", + "relationName": "meetings_agenda_idToMeetingAttachment", + "relationFromFields": [], + "relationToFields": [], + "isList": true, + "isId": false, + "isGenerated": false, + "sequence": false, + "hasDefaultValue": false + }, + { + "name": "meetings_meetings_minutes_idToMeetingAttachment", + "type": "meetings", + "isRequired": false, + "kind": "object", + "relationName": "meetings_minutes_idToMeetingAttachment", + "relationFromFields": [], + "relationToFields": [], + "isList": true, + "isId": false, + "isGenerated": false, + "sequence": false, + "hasDefaultValue": false + }, + { + "name": "meetings_meetings_notice_idToMeetingAttachment", + "type": "meetings", + "isRequired": false, + "kind": "object", + "relationName": "meetings_notice_idToMeetingAttachment", + "relationFromFields": [], + "relationToFields": [], + "isList": true, + "isId": false, + "isGenerated": false, + "sequence": false, + "hasDefaultValue": false + } + ], + "uniqueConstraints": [ + { + "name": "MeetingAttachment_pkey", + "fields": [ + "id" + ], + "nullNotDistinct": false + } + ] + }, "RecurringEvent": { "id": "public.RecurringEvent", "schemaName": "public", @@ -5396,13 +5586,13 @@ } ] }, - "meetings": { - "id": "public.meetings", + "meeting_agenda_items": { + "id": "public.meeting_agenda_items", "schemaName": "public", - "tableName": "meetings", + "tableName": "meeting_agenda_items", "fields": [ { - "id": "public.meetings.id", + "id": "public.meeting_agenda_items.id", "name": "id", "columnName": "id", "type": "uuid", @@ -5416,7 +5606,7 @@ "maxLength": null }, { - "id": "public.meetings.title", + "id": "public.meeting_agenda_items.title", "name": "title", "columnName": "title", "type": "varchar", @@ -5430,23 +5620,23 @@ "maxLength": 255 }, { - "id": "public.meetings.date", - "name": "date", - "columnName": "date", - "type": "date", - "isRequired": true, + "id": "public.meeting_agenda_items.description", + "name": "description", + "columnName": "description", + "type": "varchar", + "isRequired": false, "kind": "scalar", "isList": false, "isGenerated": false, "sequence": false, "hasDefaultValue": false, "isId": false, - "maxLength": null + "maxLength": 255 }, { - "id": "public.meetings.url", - "name": "url", - "columnName": "url", + "id": "public.meeting_agenda_items.type", + "name": "type", + "columnName": "type", "type": "varchar", "isRequired": true, "kind": "scalar", @@ -5456,110 +5646,642 @@ "hasDefaultValue": false, "isId": false, "maxLength": 255 - } - ], - "uniqueConstraints": [ - { - "name": "meetings_pkey", - "fields": [ - "id" - ], - "nullNotDistinct": false }, { - "name": "meetings_url_key", - "fields": [ - "url" - ], - "nullNotDistinct": false - } - ] - }, - "members": { - "id": "public.members", - "schemaName": "public", - "tableName": "members", - "fields": [ - { - "id": "public.members.id", - "name": "id", - "columnName": "id", - "type": "uuid", - "isRequired": true, + "id": "public.meeting_agenda_items.created_at", + "name": "created_at", + "columnName": "created_at", + "type": "timestamptz", + "isRequired": false, "kind": "scalar", "isList": false, "isGenerated": false, "sequence": false, "hasDefaultValue": true, - "isId": true, + "isId": false, "maxLength": null }, { - "id": "public.members.student_id", - "name": "student_id", - "columnName": "student_id", - "type": "varchar", + "id": "public.meeting_agenda_items.updated_at", + "name": "updated_at", + "columnName": "updated_at", + "type": "timestamptz", "isRequired": false, "kind": "scalar", "isList": false, "isGenerated": false, "sequence": false, - "hasDefaultValue": false, + "hasDefaultValue": true, "isId": false, - "maxLength": 255 + "maxLength": null }, { - "id": "public.members.first_name", - "name": "first_name", - "columnName": "first_name", - "type": "varchar", - "isRequired": false, + "id": "public.meeting_agenda_items.start", + "name": "start", + "columnName": "start", + "type": "timestamptz", + "isRequired": true, "kind": "scalar", "isList": false, "isGenerated": false, "sequence": false, "hasDefaultValue": false, "isId": false, - "maxLength": 255 + "maxLength": null }, { - "id": "public.members.nickname", - "name": "nickname", - "columnName": "nickname", - "type": "varchar", - "isRequired": false, + "id": "public.meeting_agenda_items.end", + "name": "end", + "columnName": "end", + "type": "timestamptz", + "isRequired": true, "kind": "scalar", "isList": false, "isGenerated": false, "sequence": false, "hasDefaultValue": false, "isId": false, - "maxLength": 255 + "maxLength": null }, { - "id": "public.members.last_name", - "name": "last_name", - "columnName": "last_name", - "type": "varchar", - "isRequired": false, + "id": "public.meeting_agenda_items.meeting_id", + "name": "meeting_id", + "columnName": "meeting_id", + "type": "uuid", + "isRequired": true, "kind": "scalar", "isList": false, "isGenerated": false, "sequence": false, "hasDefaultValue": false, "isId": false, - "maxLength": 255 + "maxLength": null }, { - "id": "public.members.picture_path", - "name": "picture_path", - "columnName": "picture_path", - "type": "text", - "isRequired": false, - "kind": "scalar", - "isList": false, - "isGenerated": false, - "sequence": false, + "name": "meetings", + "type": "meetings", + "isRequired": true, + "kind": "object", + "relationName": "meeting_agenda_itemsTomeetings", + "relationFromFields": [ + "meeting_id" + ], + "relationToFields": [ + "id" + ], + "isList": false, + "isId": false, + "isGenerated": false, + "sequence": false, + "hasDefaultValue": false + }, + { + "name": "MeetingAgendaAttachment", + "type": "MeetingAgendaAttachment", + "isRequired": false, + "kind": "object", + "relationName": "MeetingAgendaAttachmentTomeeting_agenda_items", + "relationFromFields": [], + "relationToFields": [], + "isList": true, + "isId": false, + "isGenerated": false, + "sequence": false, + "hasDefaultValue": false + } + ], + "uniqueConstraints": [ + { + "name": "meeting_agenda_items_pkey", + "fields": [ + "id" + ], + "nullNotDistinct": false + } + ] + }, + "meeting_logs": { + "id": "public.meeting_logs", + "schemaName": "public", + "tableName": "meeting_logs", + "fields": [ + { + "id": "public.meeting_logs.id", + "name": "id", + "columnName": "id", + "type": "uuid", + "isRequired": true, + "kind": "scalar", + "isList": false, + "isGenerated": false, + "sequence": false, + "hasDefaultValue": true, + "isId": true, + "maxLength": null + }, + { + "id": "public.meeting_logs.meeting_id", + "name": "meeting_id", + "columnName": "meeting_id", + "type": "uuid", + "isRequired": true, + "kind": "scalar", + "isList": false, + "isGenerated": false, + "sequence": false, + "hasDefaultValue": false, + "isId": false, + "maxLength": null + }, + { + "id": "public.meeting_logs.member_id", + "name": "member_id", + "columnName": "member_id", + "type": "uuid", + "isRequired": true, + "kind": "scalar", + "isList": false, + "isGenerated": false, + "sequence": false, + "hasDefaultValue": false, + "isId": false, + "maxLength": null + }, + { + "id": "public.meeting_logs.createdAt", + "name": "createdAt", + "columnName": "createdAt", + "type": "timestamptz", + "isRequired": true, + "kind": "scalar", + "isList": false, + "isGenerated": false, + "sequence": false, + "hasDefaultValue": true, + "isId": false, + "maxLength": null + }, + { + "id": "public.meeting_logs.updatedAt", + "name": "updatedAt", + "columnName": "updatedAt", + "type": "timestamptz", + "isRequired": true, + "kind": "scalar", + "isList": false, + "isGenerated": false, + "sequence": false, + "hasDefaultValue": true, + "isId": false, + "maxLength": null + }, + { + "id": "public.meeting_logs.comment", + "name": "comment", + "columnName": "comment", + "type": "text", + "isRequired": true, + "kind": "scalar", + "isList": false, + "isGenerated": false, + "sequence": false, + "hasDefaultValue": false, + "isId": false, + "maxLength": null + }, + { + "id": "public.meeting_logs.happenedAt", + "name": "happenedAt", + "columnName": "happenedAt", + "type": "timestamptz", + "isRequired": true, + "kind": "scalar", + "isList": false, + "isGenerated": false, + "sequence": false, + "hasDefaultValue": true, + "isId": false, + "maxLength": null + }, + { + "name": "meetings", + "type": "meetings", + "isRequired": true, + "kind": "object", + "relationName": "meeting_logsTomeetings", + "relationFromFields": [ + "meeting_id" + ], + "relationToFields": [ + "id" + ], + "isList": false, + "isId": false, + "isGenerated": false, + "sequence": false, + "hasDefaultValue": false + }, + { + "name": "members", + "type": "members", + "isRequired": true, + "kind": "object", + "relationName": "meeting_logsTomembers", + "relationFromFields": [ + "member_id" + ], + "relationToFields": [ + "id" + ], + "isList": false, + "isId": false, + "isGenerated": false, + "sequence": false, + "hasDefaultValue": false + } + ], + "uniqueConstraints": [ + { + "name": "meeting_logs_pkey", + "fields": [ + "id" + ], + "nullNotDistinct": false + } + ] + }, + "meetings": { + "id": "public.meetings", + "schemaName": "public", + "tableName": "meetings", + "fields": [ + { + "id": "public.meetings.id", + "name": "id", + "columnName": "id", + "type": "uuid", + "isRequired": true, + "kind": "scalar", + "isList": false, + "isGenerated": false, + "sequence": false, + "hasDefaultValue": true, + "isId": true, + "maxLength": null + }, + { + "id": "public.meetings.title", + "name": "title", + "columnName": "title", + "type": "varchar", + "isRequired": true, + "kind": "scalar", + "isList": false, + "isGenerated": false, + "sequence": false, + "hasDefaultValue": false, + "isId": false, + "maxLength": 255 + }, + { + "id": "public.meetings.agenda_id", + "name": "agenda_id", + "columnName": "agenda_id", + "type": "uuid", + "isRequired": false, + "kind": "scalar", + "isList": false, + "isGenerated": false, + "sequence": false, + "hasDefaultValue": false, + "isId": false, + "maxLength": null + }, + { + "id": "public.meetings.created_at", + "name": "created_at", + "columnName": "created_at", + "type": "timestamptz", + "isRequired": false, + "kind": "scalar", + "isList": false, + "isGenerated": false, + "sequence": false, + "hasDefaultValue": true, + "isId": false, + "maxLength": null + }, + { + "id": "public.meetings.description", + "name": "description", + "columnName": "description", + "type": "varchar", + "isRequired": false, + "kind": "scalar", + "isList": false, + "isGenerated": false, + "sequence": false, + "hasDefaultValue": false, + "isId": false, + "maxLength": 255 + }, + { + "id": "public.meetings.end", + "name": "end", + "columnName": "end", + "type": "timestamptz", + "isRequired": true, + "kind": "scalar", + "isList": false, + "isGenerated": false, + "sequence": false, + "hasDefaultValue": false, + "isId": false, + "maxLength": null + }, + { + "id": "public.meetings.minutes_id", + "name": "minutes_id", + "columnName": "minutes_id", + "type": "uuid", + "isRequired": false, + "kind": "scalar", + "isList": false, + "isGenerated": false, + "sequence": false, + "hasDefaultValue": false, + "isId": false, + "maxLength": null + }, + { + "id": "public.meetings.notice_id", + "name": "notice_id", + "columnName": "notice_id", + "type": "uuid", + "isRequired": false, + "kind": "scalar", + "isList": false, + "isGenerated": false, + "sequence": false, + "hasDefaultValue": false, + "isId": false, + "maxLength": null + }, + { + "id": "public.meetings.start", + "name": "start", + "columnName": "start", + "type": "timestamptz", + "isRequired": true, + "kind": "scalar", + "isList": false, + "isGenerated": false, + "sequence": false, + "hasDefaultValue": false, + "isId": false, + "maxLength": null + }, + { + "id": "public.meetings.type", + "name": "type", + "columnName": "type", + "type": "varchar", + "isRequired": true, + "kind": "scalar", + "isList": false, + "isGenerated": false, + "sequence": false, + "hasDefaultValue": false, + "isId": false, + "maxLength": 255 + }, + { + "id": "public.meetings.updated_at", + "name": "updated_at", + "columnName": "updated_at", + "type": "timestamptz", + "isRequired": false, + "kind": "scalar", + "isList": false, + "isGenerated": false, + "sequence": false, + "hasDefaultValue": true, + "isId": false, + "maxLength": null + }, + { + "name": "MeetingAttachment_meetings_agenda_idToMeetingAttachment", + "type": "MeetingAttachment", + "isRequired": false, + "kind": "object", + "relationName": "meetings_agenda_idToMeetingAttachment", + "relationFromFields": [ + "agenda_id" + ], + "relationToFields": [ + "id" + ], + "isList": false, + "isId": false, + "isGenerated": false, + "sequence": false, + "hasDefaultValue": false + }, + { + "name": "MeetingAttachment_meetings_minutes_idToMeetingAttachment", + "type": "MeetingAttachment", + "isRequired": false, + "kind": "object", + "relationName": "meetings_minutes_idToMeetingAttachment", + "relationFromFields": [ + "minutes_id" + ], + "relationToFields": [ + "id" + ], + "isList": false, + "isId": false, + "isGenerated": false, + "sequence": false, + "hasDefaultValue": false + }, + { + "name": "MeetingAttachment_meetings_notice_idToMeetingAttachment", + "type": "MeetingAttachment", + "isRequired": false, + "kind": "object", + "relationName": "meetings_notice_idToMeetingAttachment", + "relationFromFields": [ + "notice_id" + ], + "relationToFields": [ + "id" + ], + "isList": false, + "isId": false, + "isGenerated": false, + "sequence": false, + "hasDefaultValue": false + }, + { + "name": "meeting_agenda_items", + "type": "meeting_agenda_items", + "isRequired": false, + "kind": "object", + "relationName": "meeting_agenda_itemsTomeetings", + "relationFromFields": [], + "relationToFields": [], + "isList": true, + "isId": false, + "isGenerated": false, + "sequence": false, + "hasDefaultValue": false + }, + { + "name": "meeting_logs", + "type": "meeting_logs", + "isRequired": false, + "kind": "object", + "relationName": "meeting_logsTomeetings", + "relationFromFields": [], + "relationToFields": [], + "isList": true, + "isId": false, + "isGenerated": false, + "sequence": false, + "hasDefaultValue": false + }, + { + "name": "speakers", + "type": "speakers", + "isRequired": false, + "kind": "object", + "relationName": "speakersTomeetings", + "relationFromFields": [], + "relationToFields": [], + "isList": true, + "isId": false, + "isGenerated": false, + "sequence": false, + "hasDefaultValue": false + } + ], + "uniqueConstraints": [ + { + "name": "meetings_pkey", + "fields": [ + "id" + ], + "nullNotDistinct": false + }, + { + "name": "meetings_agenda_id_key", + "fields": [ + "agenda_id" + ], + "nullNotDistinct": false + }, + { + "name": "meetings_minutes_id_key", + "fields": [ + "minutes_id" + ], + "nullNotDistinct": false + }, + { + "name": "meetings_notice_id_key", + "fields": [ + "notice_id" + ], + "nullNotDistinct": false + } + ] + }, + "members": { + "id": "public.members", + "schemaName": "public", + "tableName": "members", + "fields": [ + { + "id": "public.members.id", + "name": "id", + "columnName": "id", + "type": "uuid", + "isRequired": true, + "kind": "scalar", + "isList": false, + "isGenerated": false, + "sequence": false, + "hasDefaultValue": true, + "isId": true, + "maxLength": null + }, + { + "id": "public.members.student_id", + "name": "student_id", + "columnName": "student_id", + "type": "varchar", + "isRequired": false, + "kind": "scalar", + "isList": false, + "isGenerated": false, + "sequence": false, + "hasDefaultValue": false, + "isId": false, + "maxLength": 255 + }, + { + "id": "public.members.first_name", + "name": "first_name", + "columnName": "first_name", + "type": "varchar", + "isRequired": false, + "kind": "scalar", + "isList": false, + "isGenerated": false, + "sequence": false, + "hasDefaultValue": false, + "isId": false, + "maxLength": 255 + }, + { + "id": "public.members.nickname", + "name": "nickname", + "columnName": "nickname", + "type": "varchar", + "isRequired": false, + "kind": "scalar", + "isList": false, + "isGenerated": false, + "sequence": false, + "hasDefaultValue": false, + "isId": false, + "maxLength": 255 + }, + { + "id": "public.members.last_name", + "name": "last_name", + "columnName": "last_name", + "type": "varchar", + "isRequired": false, + "kind": "scalar", + "isList": false, + "isGenerated": false, + "sequence": false, + "hasDefaultValue": false, + "isId": false, + "maxLength": 255 + }, + { + "id": "public.members.picture_path", + "name": "picture_path", + "columnName": "picture_path", + "type": "text", + "isRequired": false, + "kind": "scalar", + "isList": false, + "isGenerated": false, + "sequence": false, "hasDefaultValue": false, "isId": false, "maxLength": null @@ -5918,6 +6640,20 @@ "sequence": false, "hasDefaultValue": false }, + { + "name": "meeting_logs", + "type": "meeting_logs", + "isRequired": false, + "kind": "object", + "relationName": "meeting_logsTomembers", + "relationFromFields": [], + "relationToFields": [], + "isList": true, + "isId": false, + "isGenerated": false, + "sequence": false, + "hasDefaultValue": false + }, { "name": "notifications", "type": "notifications", @@ -5988,6 +6724,20 @@ "sequence": false, "hasDefaultValue": false }, + { + "name": "speakers", + "type": "speakers", + "isRequired": false, + "kind": "object", + "relationName": "speakersTomembers", + "relationFromFields": [], + "relationToFields": [], + "isList": true, + "isId": false, + "isGenerated": false, + "sequence": false, + "hasDefaultValue": false + }, { "name": "subscription_settings", "type": "subscription_settings", @@ -8391,6 +9141,156 @@ } ] }, + "speakers": { + "id": "public.speakers", + "schemaName": "public", + "tableName": "speakers", + "fields": [ + { + "id": "public.speakers.id", + "name": "id", + "columnName": "id", + "type": "uuid", + "isRequired": true, + "kind": "scalar", + "isList": false, + "isGenerated": false, + "sequence": false, + "hasDefaultValue": true, + "isId": true, + "maxLength": null + }, + { + "id": "public.speakers.meeting_id", + "name": "meeting_id", + "columnName": "meeting_id", + "type": "uuid", + "isRequired": true, + "kind": "scalar", + "isList": false, + "isGenerated": false, + "sequence": false, + "hasDefaultValue": false, + "isId": false, + "maxLength": null + }, + { + "id": "public.speakers.member_id", + "name": "member_id", + "columnName": "member_id", + "type": "uuid", + "isRequired": true, + "kind": "scalar", + "isList": false, + "isGenerated": false, + "sequence": false, + "hasDefaultValue": false, + "isId": false, + "maxLength": null + }, + { + "id": "public.speakers.start", + "name": "start", + "columnName": "start", + "type": "timestamptz", + "isRequired": true, + "kind": "scalar", + "isList": false, + "isGenerated": false, + "sequence": false, + "hasDefaultValue": false, + "isId": false, + "maxLength": null + }, + { + "id": "public.speakers.end", + "name": "end", + "columnName": "end", + "type": "timestamptz", + "isRequired": true, + "kind": "scalar", + "isList": false, + "isGenerated": false, + "sequence": false, + "hasDefaultValue": false, + "isId": false, + "maxLength": null + }, + { + "id": "public.speakers.createdAt", + "name": "createdAt", + "columnName": "createdAt", + "type": "timestamptz", + "isRequired": true, + "kind": "scalar", + "isList": false, + "isGenerated": false, + "sequence": false, + "hasDefaultValue": true, + "isId": false, + "maxLength": null + }, + { + "id": "public.speakers.updatedAt", + "name": "updatedAt", + "columnName": "updatedAt", + "type": "timestamptz", + "isRequired": true, + "kind": "scalar", + "isList": false, + "isGenerated": false, + "sequence": false, + "hasDefaultValue": true, + "isId": false, + "maxLength": null + }, + { + "name": "meetings", + "type": "meetings", + "isRequired": true, + "kind": "object", + "relationName": "speakersTomeetings", + "relationFromFields": [ + "meeting_id" + ], + "relationToFields": [ + "id" + ], + "isList": false, + "isId": false, + "isGenerated": false, + "sequence": false, + "hasDefaultValue": false + }, + { + "name": "members", + "type": "members", + "isRequired": true, + "kind": "object", + "relationName": "speakersTomembers", + "relationFromFields": [ + "member_id" + ], + "relationToFields": [ + "id" + ], + "isList": false, + "isId": false, + "isGenerated": false, + "sequence": false, + "hasDefaultValue": false + } + ], + "uniqueConstraints": [ + { + "name": "speakers_pkey", + "fields": [ + "id" + ], + "nullNotDistinct": false + } + ] + }, "special_receivers": { "id": "public.special_receivers", "schemaName": "public", From 00435e4e267e9c2a68886d649052c4eccca1cc0b Mon Sep 17 00:00:00 2001 From: Oliver Levay Date: Tue, 17 Dec 2024 08:20:40 +0100 Subject: [PATCH 2/2] reinstate date --- .../prisma/migrations/20241209223044_meetings/migration.sql | 3 +-- src/database/schema.zmodel | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/database/prisma/migrations/20241209223044_meetings/migration.sql b/src/database/prisma/migrations/20241209223044_meetings/migration.sql index cc2bcfc5b..6ea4a9513 100644 --- a/src/database/prisma/migrations/20241209223044_meetings/migration.sql +++ b/src/database/prisma/migrations/20241209223044_meetings/migration.sql @@ -15,8 +15,7 @@ DROP INDEX "meetings_url_key"; -- AlterTable -ALTER TABLE "meetings" DROP COLUMN "date", -DROP COLUMN "url", +ALTER TABLE "meetings" DROP COLUMN "url", ADD COLUMN "agenda_id" UUID, ADD COLUMN "created_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP, ADD COLUMN "description" VARCHAR(255), diff --git a/src/database/schema.zmodel b/src/database/schema.zmodel index 9e74074bd..21651e27f 100644 --- a/src/database/schema.zmodel +++ b/src/database/schema.zmodel @@ -1166,6 +1166,7 @@ model Meeting extends MeetingBase { agendaId String? @map("agenda_id") @db.Uuid @unique minutes MeetingAttachment? @relation("meeting_minutes", fields: [minutesId], references: [id]) minutesId String? @map("minutes_id") @db.Uuid @unique + date DateTime @db.Date @@allow("create", has(auth().policies, "fileHandler:documents:create")) @@allow("read", has(auth().policies, "fileHandler:documents:read"))