fix(db): align migrations with entity model and idempotency
This commit is contained in:
@@ -16,7 +16,8 @@ CREATE TABLE IF NOT EXISTS mci_platform_role (
|
||||
role_name VARCHAR(128) NOT NULL COMMENT '角色名称',
|
||||
permissions JSON COMMENT '权限列表',
|
||||
status TINYINT NOT NULL DEFAULT 1,
|
||||
create_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
create_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
update_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='平台角色表';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS mci_user (
|
||||
@@ -41,3 +42,7 @@ CREATE TABLE IF NOT EXISTS mci_user_role (
|
||||
create_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
UNIQUE KEY uk_user_role (user_id, role_id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户角色关系表';
|
||||
|
||||
ALTER TABLE mci_user_role
|
||||
ADD CONSTRAINT fk_user_role_user_id FOREIGN KEY (user_id) REFERENCES mci_user (id),
|
||||
ADD CONSTRAINT fk_user_role_role_id FOREIGN KEY (role_id) REFERENCES mci_platform_role (id);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
INSERT INTO mci_platform_role (role_code, role_name, permissions) VALUES
|
||||
INSERT IGNORE INTO mci_platform_role (role_code, role_name, permissions) VALUES
|
||||
('admin', '租户管理员', '["*"]'),
|
||||
('operator', '运营操作员', '["send:write", "channel:read", "channel:write", "record:read"]'),
|
||||
('viewer', '只读用户', '["record:read", "channel:read"]');
|
||||
|
||||
Reference in New Issue
Block a user