feat: simplify SOP to immediate-effect configuration
This commit is contained in:
18
migrations/000008_scenario_rules.up.sql
Normal file
18
migrations/000008_scenario_rules.up.sql
Normal file
@@ -0,0 +1,18 @@
|
||||
CREATE TABLE scenario_rules (
|
||||
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
tenant_id BIGINT UNSIGNED NOT NULL,
|
||||
scenario_id BIGINT UNSIGNED NOT NULL,
|
||||
rule_key VARCHAR(64) NOT NULL,
|
||||
name VARCHAR(128) NOT NULL,
|
||||
`condition` JSON NOT NULL,
|
||||
actions JSON NOT NULL,
|
||||
priority INT NOT NULL DEFAULT 0,
|
||||
status VARCHAR(24) NOT NULL DEFAULT 'active',
|
||||
created_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
updated_at DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE KEY uk_scenario_rules_key (scenario_id, rule_key),
|
||||
KEY idx_scenario_rules_active (tenant_id, scenario_id, status, priority),
|
||||
CONSTRAINT fk_scenario_rules_tenant FOREIGN KEY (tenant_id) REFERENCES tenants(id),
|
||||
CONSTRAINT fk_scenario_rules_scenario FOREIGN KEY (scenario_id) REFERENCES scenarios(id) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
Reference in New Issue
Block a user