6066f27ba0
Menu Calendario (Mes/Semana/Dia/Agenda) para agendar reuniones con participantes internos y externos, RSVP, vinculo a proyecto, vencimientos de actividades, invitaciones iCalendar por correo, recurrencia con excepciones, recordatorios in-app y aviso de choques. Migracion 034_meetings.sql. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
66 lines
3.0 KiB
SQL
66 lines
3.0 KiB
SQL
SET NAMES utf8mb4;
|
|
|
|
CREATE TABLE IF NOT EXISTS meetings (
|
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
uid CHAR(36) NOT NULL UNIQUE,
|
|
title VARCHAR(160) NOT NULL,
|
|
description TEXT NULL,
|
|
starts_at DATETIME NOT NULL,
|
|
ends_at DATETIME NOT NULL,
|
|
all_day TINYINT(1) NOT NULL DEFAULT 0,
|
|
location VARCHAR(255) NULL,
|
|
video_url VARCHAR(2048) NULL,
|
|
project_id INT NULL,
|
|
organizer_id INT NOT NULL,
|
|
reminder_minutes SMALLINT UNSIGNED NULL,
|
|
recurrence_json TEXT NULL,
|
|
sequence_number INT UNSIGNED NOT NULL DEFAULT 0,
|
|
edit_version INT UNSIGNED NOT NULL DEFAULT 1,
|
|
cancelled_at DATETIME NULL,
|
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
INDEX idx_meetings_range (starts_at, ends_at, cancelled_at),
|
|
INDEX idx_meetings_project (project_id, starts_at),
|
|
INDEX idx_meetings_organizer (organizer_id, starts_at),
|
|
CONSTRAINT fk_meetings_project FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE SET NULL,
|
|
CONSTRAINT fk_meetings_organizer FOREIGN KEY (organizer_id) REFERENCES users(id) ON DELETE CASCADE
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
CREATE TABLE IF NOT EXISTS meeting_participants (
|
|
meeting_id INT NOT NULL,
|
|
user_id INT NOT NULL,
|
|
rsvp ENUM('pending','accepted','declined','tentative') NOT NULL DEFAULT 'pending',
|
|
responded_at DATETIME NULL,
|
|
PRIMARY KEY (meeting_id, user_id),
|
|
INDEX idx_meeting_participants_user (user_id, meeting_id),
|
|
CONSTRAINT fk_mp_meeting FOREIGN KEY (meeting_id) REFERENCES meetings(id) ON DELETE CASCADE,
|
|
CONSTRAINT fk_mp_user FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
CREATE TABLE IF NOT EXISTS meeting_external_participants (
|
|
meeting_id INT NOT NULL,
|
|
email VARCHAR(160) NOT NULL,
|
|
PRIMARY KEY (meeting_id, email),
|
|
CONSTRAINT fk_mep_meeting FOREIGN KEY (meeting_id) REFERENCES meetings(id) ON DELETE CASCADE
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
CREATE TABLE IF NOT EXISTS meeting_exceptions (
|
|
meeting_id INT NOT NULL,
|
|
occurrence_start DATETIME NOT NULL,
|
|
created_by INT NULL,
|
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
PRIMARY KEY (meeting_id, occurrence_start),
|
|
CONSTRAINT fk_mex_meeting FOREIGN KEY (meeting_id) REFERENCES meetings(id) ON DELETE CASCADE,
|
|
CONSTRAINT fk_mex_user FOREIGN KEY (created_by) REFERENCES users(id) ON DELETE SET NULL
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
CREATE TABLE IF NOT EXISTS meeting_reminders (
|
|
meeting_id INT NOT NULL,
|
|
occurrence_start DATETIME NOT NULL,
|
|
sent_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
PRIMARY KEY (meeting_id, occurrence_start),
|
|
CONSTRAINT fk_mr_meeting FOREIGN KEY (meeting_id) REFERENCES meetings(id) ON DELETE CASCADE
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
ALTER TABLE notifications MODIFY COLUMN entity_type ENUM('project','activity','meeting') NULL;
|