-- Channel sharing and ownership transfer support

CREATE TABLE IF NOT EXISTS user_channels_access (
  user_id BIGINT NOT NULL,
  channel_id BIGINT NOT NULL,
  access_level ENUM('view','edit','manage') NOT NULL DEFAULT 'edit',
  created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (user_id, channel_id),
  CONSTRAINT fk_uca_user FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
  CONSTRAINT fk_uca_channel FOREIGN KEY (channel_id) REFERENCES channels(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
