<?php

############################################################

array_push($sql_statements,"
create table netjuke_groups (
    id   int(11) not null auto_increment,
    name varchar(30) not null,
    primary key (id),
    unique index netjuke_groups_webindex (name)
)
");


############################################################

array_push($sql_statements,"
create table netjuke_users (
    email                varchar(75) not null,
    password             varchar(60) not null,
    name                 varchar(100) not null,
    gr_id                int(11) not null references netjuke_groups,
    created              datetime not null,
    updated              datetime not null,
    nickname             varchar(30),
    web_site             varchar(255),
    img_src              text,
    last_login           datetime default null,
    login_cnt            int(11) not null default '0',
    local_music_dir      text,
    primary key (email),
    index netjuke_users_webloginindex (email, password)
)
");


############################################################

array_push($sql_statements,"
create table netjuke_userprefs (
    us_email             varchar(75) not null references netjuke_users on delete cascade on update cascade,
    inv_icn              varchar(1) not null,
    icon_set varchar(100) NOT NULL default 'default',
    language char(2) NOT NULL default 'en',
    explore char(1) NOT NULL default 't',
    theme varchar(100) NOT NULL default 'artekopia',
    primary key (us_email)
)
");

############################################################

array_push($sql_statements,"
create table netjuke_sessions (
    session_id           varchar(40) not null,
    remote_addr          varchar(60) not null,
    created              datetime not null,
    updated              datetime not null,
    email                varchar(75),
    name                 varchar(100),
    gr_id                int(11),
    nickname             varchar(30),
    default_pl           int(11),
    inv_icn              varchar(1) default 'f',
    static		char(1) default 'f',
    icon_set varchar(100) NOT NULL default 'default',
    language char(2) NOT NULL default 'en',
    explore char(1) NOT NULL default 't',
    theme varchar(100) NOT NULL default 'artekopia',
    primary key (session_id)
)
");

############################################################

array_push($sql_statements,"
create table netjuke_plists (
    id                   int(11) not null auto_increment,
    us_email             varchar(75) not null references netjuke_users on delete cascade on update cascade,
    created              datetime not null default 'now',
    sequence             int(11) not null default 1,
    title                varchar(100) not null,
    comment              text,
    shared_list          varchar(1) default 'f',
    primary key (id)
)
");

############################################################

array_push($sql_statements,"
create table netjuke_plists_tracks (
    id                   int(11) not null auto_increment,
    us_email             varchar(75) not null references netjuke_users on delete cascade on update cascade,
    pl_id                int(11) not null references netjuke_plists on delete cascade on update cascade,
    tr_id                int(11) not null references netjuke_tracks on delete cascade on update cascade,
    sequence             int(11) not null default 1,
    comment              varchar(255),
    primary key (id)
)
");

############################################################

array_push($sql_statements,"
create table netjuke_plists_fav (
    id                   int(11) not null auto_increment,
    us_email             varchar(75) not null references netjuke_users on delete cascade on update cascade,
    pl_id                int(11) not null references netjuke_plists on delete cascade on update cascade,
    created              datetime not null default 'now',
    sequence             int(11) not null default 1,
    comment              varchar(255),
    primary key (id)
)
");

array_push($sql_statements,"
CREATE TABLE netjuke_themeprefs (
  us_email varchar(75) NOT NULL default '',
  theme varchar(100) NOT NULL default '',
  setting varchar(100) NOT NULL default '',
  value varchar(200) NOT NULL default '',
  PRIMARY KEY  (us_email,theme,setting)
)
");

############################################################

?>
