refactor: rename database tables for notification entities to improve clarity and consistency

This commit is contained in:
2026-07-02 16:04:18 +08:00
parent c5225d8c97
commit a0d26fa3a3
7 changed files with 51 additions and 51 deletions
+10 -10
View File
@@ -1,4 +1,4 @@
CREATE TABLE source (
CREATE TABLE notification_source (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(64) NOT NULL,
api_key VARCHAR(128) NOT NULL,
@@ -11,7 +11,7 @@ CREATE TABLE source (
UNIQUE KEY uk_api_key (api_key)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE template (
CREATE TABLE notification_template (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(64) NOT NULL,
content TEXT NOT NULL,
@@ -20,7 +20,7 @@ CREATE TABLE template (
UNIQUE KEY uk_name (name)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE channel (
CREATE TABLE notification_channel (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(32) NOT NULL,
type VARCHAR(32) NOT NULL,
@@ -31,7 +31,7 @@ CREATE TABLE channel (
UNIQUE KEY uk_name (name)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE rule (
CREATE TABLE notification_rule (
id INT AUTO_INCREMENT PRIMARY KEY,
source_id INT NOT NULL,
event VARCHAR(64) NOT NULL,
@@ -41,21 +41,21 @@ CREATE TABLE rule (
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
UNIQUE KEY uk_source_event (source_id, event),
FOREIGN KEY (source_id) REFERENCES source(id),
FOREIGN KEY (template_id) REFERENCES template(id)
FOREIGN KEY (source_id) REFERENCES notification_source(id),
FOREIGN KEY (template_id) REFERENCES notification_template(id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE rule_channel (
CREATE TABLE notification_rule_channel (
id INT AUTO_INCREMENT PRIMARY KEY,
rule_id INT NOT NULL,
channel_id INT NOT NULL,
enabled TINYINT NOT NULL DEFAULT 1,
UNIQUE KEY uk_rule_channel (rule_id, channel_id),
FOREIGN KEY (rule_id) REFERENCES rule(id) ON DELETE CASCADE,
FOREIGN KEY (channel_id) REFERENCES channel(id)
FOREIGN KEY (rule_id) REFERENCES notification_rule(id) ON DELETE CASCADE,
FOREIGN KEY (channel_id) REFERENCES notification_channel(id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE message_log (
CREATE TABLE notification_message_log (
id BIGINT AUTO_INCREMENT PRIMARY KEY,
rule_id INT NOT NULL,
channel_id INT NOT NULL,