-- Your SQL goes here
CREATE TABLE users (
  id                  INTEGER PRIMARY KEY AUTOINCREMENT,
  username            TEXT    NOT NULL UNIQUE,
  password            TEXT    NOT NULL,
  email               TEXT    NOT NULL UNIQUE,

  ldapAuthenticated   BOOLEAN NOT NULL DEFAULT 0 CHECK (ldapAuthenticated IN (0,1)),
  adminRole           BOOLEAN NOT NULL DEFAULT 0 CHECK (adminRole IN (0,1)),
  settingsRole        BOOLEAN NOT NULL DEFAULT 1 CHECK (settingsRole IN (0,1)),
  streamRole          BOOLEAN NOT NULL DEFAULT 1 CHECK (streamRole IN (0,1)),
  jukeboxRole         BOOLEAN NOT NULL DEFAULT 0 CHECK (jukeboxRole IN (0,1)),
  downloadRole        BOOLEAN NOT NULL DEFAULT 0 CHECK (downloadRole IN (0,1)),
  uploadRole          BOOLEAN NOT NULL DEFAULT 0 CHECK (uploadRole IN (0,1)),
  playlistRole        BOOLEAN NOT NULL DEFAULT 0 CHECK (playlistRole IN (0,1)),
  coverArtRole        BOOLEAN NOT NULL DEFAULT 0 CHECK (coverArtRole IN (0,1)),
  commentRole         BOOLEAN NOT NULL DEFAULT 0 CHECK (commentRole IN (0,1)),
  podcastRole         BOOLEAN NOT NULL DEFAULT 0 CHECK (podcastRole IN (0,1)),
  shareRole           BOOLEAN NOT NULL DEFAULT 0 CHECK (shareRole IN (0,1)),
  videoConversionRole BOOLEAN NOT NULL DEFAULT 0 CHECK (videoConversionRole IN (0,1))
);

CREATE TABLE user_music_folders (
  user_id         INTEGER NOT NULL,
  music_folder_id INTEGER NOT NULL,
  PRIMARY KEY (user_id, music_folder_id),
  FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
);
