CREATE TABLE mdl_netforum (
    id BIGINT(10) unsigned NOT NULL auto_increment,
    course BIGINT(10) unsigned NOT NULL,
    timemodified BIGINT(10) unsigned NOT NULL,
    name VARCHAR(255) NOT NULL DEFAULT '',
    intro LONGTEXT NOT NULL,
    assessed BIGINT(10) unsigned DEFAULT NULL,
    assesstimestart BIGINT(10) unsigned DEFAULT NULL,
    assesstimefinish BIGINT(10) unsigned DEFAULT NULL,
    warnafter BIGINT(10) unsigned DEFAULT NULL,
    blockafter BIGINT(10) unsigned DEFAULT NULL,
    blockperiod BIGINT(10) unsigned DEFAULT NULL,
CONSTRAINT  PRIMARY KEY (id)
);

CREATE TABLE mdl_netforum_post (
    id BIGINT(10) unsigned NOT NULL auto_increment,
    userid BIGINT(10) unsigned NOT NULL,
    created BIGINT(10) unsigned NOT NULL,
    modifiersid BIGINT(10) unsigned DEFAULT NULL,
    modified BIGINT(10) unsigned NOT NULL,
    released BIGINT(10) unsigned DEFAULT NULL,
    subject VARCHAR(255) NOT NULL DEFAULT '',
    message LONGTEXT NOT NULL,
    format TINYINT(2) unsigned NOT NULL,
    grade BIGINT(10) unsigned DEFAULT NULL,
    attachment VARCHAR(100) DEFAULT NULL,
CONSTRAINT  PRIMARY KEY (id)
);

CREATE TABLE mdl_netforum_web (
    id BIGINT(10) unsigned NOT NULL auto_increment,
    parent BIGINT(10) unsigned DEFAULT NULL,
    child BIGINT(10) unsigned DEFAULT NULL,
    value BIGINT(10) unsigned DEFAULT NULL,
CONSTRAINT  PRIMARY KEY (id)
);

CREATE TABLE mdl_netforum_ratings (
    id BIGINT(10) unsigned NOT NULL auto_increment,
    postid BIGINT(10) unsigned NOT NULL,
    userid BIGINT(10) unsigned NOT NULL,
    time BIGINT(10) unsigned NOT NULL,
    rating SMALLINT(4) unsigned DEFAULT NULL,
CONSTRAINT  PRIMARY KEY (id)
);

CREATE TABLE mdl_netforum_read (
    id BIGINT(10) unsigned NOT NULL auto_increment,
    postid BIGINT(10) unsigned NOT NULL,
    userid BIGINT(10) unsigned NOT NULL,
    firstread BIGINT(10) unsigned DEFAULT NULL,
    lastread BIGINT(10) unsigned DEFAULT NULL,
    times SMALLINT(4) unsigned NOT NULL,
CONSTRAINT  PRIMARY KEY (id)
);

CREATE TABLE mdl_netforum_note (
    id BIGINT(10) unsigned NOT NULL auto_increment,
    postid BIGINT(10) unsigned NOT NULL,
    userid BIGINT(10) unsigned NOT NULL,
    link TINYINT(1) unsigned DEFAULT NULL,
    comment LONGTEXT,
CONSTRAINT  PRIMARY KEY (id)
);
