16 lines
1016 B
SQL
16 lines
1016 B
SQL
CREATE TABLE IF NOT EXISTS platform_user_business_scope (
|
|
user_id BIGINT UNSIGNED NOT NULL PRIMARY KEY,
|
|
scope_level VARCHAR(24) NOT NULL,
|
|
department_ids VARCHAR(1024) NOT NULL DEFAULT '',
|
|
responsible_user_id VARCHAR(96) NOT NULL DEFAULT '',
|
|
enabled TINYINT(1) NOT NULL DEFAULT 1,
|
|
source_system VARCHAR(32) NOT NULL DEFAULT 'oneos',
|
|
source_updated_at DATETIME(3) NULL,
|
|
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),
|
|
CONSTRAINT fk_platform_user_business_scope_user FOREIGN KEY (user_id) REFERENCES platform_user(id) ON DELETE CASCADE,
|
|
CONSTRAINT chk_platform_user_business_scope_level CHECK (scope_level IN ('department', 'responsible')),
|
|
INDEX idx_platform_user_business_scope_level (scope_level, enabled),
|
|
INDEX idx_platform_user_business_scope_responsible (responsible_user_id, enabled)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|