Add user isolation mode and transfer features
Introduces user isolation mode, allowing domains, groups, and tags to be visible only to their owners when enabled. Adds user_id fields to domains and notification_groups, updates models and controllers for isolation-aware queries, and provides admin UI and endpoints for transferring domains and groups between users (single and bulk). Includes migration, settings UI, and routes for toggling isolation mode and handling data migration.
This commit is contained in:
36
database/migrations/018_add_user_isolation.sql
Normal file
36
database/migrations/018_add_user_isolation.sql
Normal file
@@ -0,0 +1,36 @@
|
||||
-- Add user isolation support
|
||||
-- This migration adds user_id fields to domains and notification_groups tables
|
||||
-- and adds the user_isolation_mode setting
|
||||
|
||||
-- Add user_id field to domains table
|
||||
ALTER TABLE domains
|
||||
ADD COLUMN user_id INT NULL
|
||||
AFTER is_active;
|
||||
|
||||
-- Add foreign key constraint for domains
|
||||
ALTER TABLE domains
|
||||
ADD CONSTRAINT fk_domains_user_id
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE SET NULL;
|
||||
|
||||
-- Add index for user_id in domains
|
||||
ALTER TABLE domains
|
||||
ADD INDEX idx_domains_user_id (user_id);
|
||||
|
||||
-- Add user_id field to notification_groups table
|
||||
ALTER TABLE notification_groups
|
||||
ADD COLUMN user_id INT NULL
|
||||
AFTER description;
|
||||
|
||||
-- Add foreign key constraint for notification_groups
|
||||
ALTER TABLE notification_groups
|
||||
ADD CONSTRAINT fk_notification_groups_user_id
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE SET NULL;
|
||||
|
||||
-- Add index for user_id in notification_groups
|
||||
ALTER TABLE notification_groups
|
||||
ADD INDEX idx_notification_groups_user_id (user_id);
|
||||
|
||||
-- Add user isolation mode setting
|
||||
INSERT INTO settings (setting_key, setting_value, description) VALUES
|
||||
('user_isolation_mode', 'shared', 'User data visibility mode: shared (all users see all data) or isolated (users see only their own data)')
|
||||
ON DUPLICATE KEY UPDATE setting_key=setting_key;
|
||||
Reference in New Issue
Block a user