2c30844bf7
- app 'forum': portada (categorías/foros), ver foro y tema (paginado), crear tema, responder, editar/borrar posts y moderación (fijar, bloquear, mover, borrar/restaurar) - lee/escribe la BD acore_web (5ª conexión, DB_NAME_WEB) por SQL directo, tablas forum_categories/forums/forum_topics/forum_posts/forum_reads (portado de NovaWeb-main) - identidad = cuenta de juego en sesión; permisos simplificados por gmlevel (FORUM_MOD_GMLEVEL) en vez de la matriz group_level×permission del original - saneado del HTML de posts con nh3 (evita el XSS del original); POST+CSRF en formularios - plantillas con los partials del sitio; enlace 'FOROS' del menú apunta al foro interno - sql/forum_schema.sql y docs/FORO.md Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
69 lines
2.7 KiB
SQL
69 lines
2.7 KiB
SQL
-- Esquema del foro para la base de datos `acore_web` (NovaWoW).
|
|
-- Extraído de NovaWeb-main. Aplicar sobre acore_web.
|
|
|
|
CREATE TABLE `forum_categories` (
|
|
`id` int unsigned NOT NULL AUTO_INCREMENT,
|
|
`order` int NOT NULL DEFAULT '0',
|
|
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
|
|
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
|
|
PRIMARY KEY (`id`),
|
|
KEY `idx_order` (`order`)
|
|
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
CREATE TABLE `forums` (
|
|
`id` int NOT NULL AUTO_INCREMENT,
|
|
`category_id` int NOT NULL,
|
|
`order` int NOT NULL DEFAULT '0',
|
|
`name` varchar(45) NOT NULL,
|
|
`description` text NOT NULL,
|
|
`icon` varchar(45) DEFAULT NULL,
|
|
`colortitle` varchar(45) DEFAULT NULL,
|
|
`type` int NOT NULL DEFAULT '1',
|
|
`visibility` tinyint(1) NOT NULL DEFAULT '1',
|
|
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
|
|
`updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
`deleted` tinyint(1) NOT NULL DEFAULT '0',
|
|
PRIMARY KEY (`id`)
|
|
) ENGINE=InnoDB AUTO_INCREMENT=44 DEFAULT CHARSET=utf8mb3;
|
|
|
|
CREATE TABLE `forum_topics` (
|
|
`id` int NOT NULL AUTO_INCREMENT,
|
|
`forum_id` int NOT NULL,
|
|
`name` varchar(45) NOT NULL,
|
|
`poster` varchar(32) NOT NULL,
|
|
`poster_id` int unsigned NOT NULL,
|
|
`created` timestamp NOT NULL DEFAULT (now()),
|
|
`sticky` tinyint NOT NULL DEFAULT '0',
|
|
`locked` tinyint NOT NULL DEFAULT '0',
|
|
`deleted` tinyint NOT NULL DEFAULT '0',
|
|
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
|
|
`updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
`moved` tinyint(1) NOT NULL DEFAULT '0',
|
|
PRIMARY KEY (`id`)
|
|
) ENGINE=InnoDB AUTO_INCREMENT=41 DEFAULT CHARSET=utf8mb3;
|
|
|
|
CREATE TABLE `forum_posts` (
|
|
`id` int NOT NULL AUTO_INCREMENT,
|
|
`topic_id` int NOT NULL,
|
|
`poster` varchar(32) COLLATE utf8mb4_general_ci NOT NULL,
|
|
`text` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
|
|
`time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
`deleted` tinyint NOT NULL DEFAULT '0',
|
|
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
|
|
`updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
`poster_id` int unsigned NOT NULL,
|
|
PRIMARY KEY (`id`)
|
|
) ENGINE=InnoDB AUTO_INCREMENT=73 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
|
|
|
CREATE TABLE `forum_reads` (
|
|
`id` int unsigned NOT NULL AUTO_INCREMENT,
|
|
`user_id` int unsigned NOT NULL,
|
|
`topic_id` int unsigned NOT NULL,
|
|
`read_at` datetime NOT NULL,
|
|
PRIMARY KEY (`id`),
|
|
UNIQUE KEY `uniq_user_topic` (`user_id`,`topic_id`),
|
|
KEY `idx_user_id` (`user_id`),
|
|
KEY `idx_topic_id` (`topic_id`)
|
|
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|