DROP TABLE IF EXISTS FORUM_BOOKMARK;

DROP TABLE IF EXISTS FORUM_SUBSCRIPTION;
CREATE TABLE FORUM_SUBSCRIPTION (
  ID_INTERNAL INT(11) NOT NULL auto_increment,
  RECEIVE_POSTS_BY_EMAIL TINYINT(1) NOT NULL,
  FAVORITE TINYINT(1) NOT NULL,
  KEY_FORUM INT(11) NOT NULL,
  KEY_PERSON INT(11) NOT NULL,
  KEY_ROOT_DOMAIN_OBJECT INT(11) NOT NULL DEFAULT 1,
  PRIMARY KEY (ID_INTERNAL),
  UNIQUE (KEY_FORUM,KEY_PERSON)
) ENGINE=InnoDB;


DROP TABLE IF EXISTS FORUM;
CREATE TABLE FORUM (
  ID_INTERNAL INT(11) NOT NULL auto_increment,
  CREATION_DATE_DATE_TIME TIMESTAMP NOT NULL,
  NAME VARCHAR(255) NOT NULL,
  DESCRIPTION VARCHAR(255) NOT NULL,
  READERS_GROUP BLOB NULL,
  WRITERS_GROUP BLOB NULL,
  ADMIN_GROUP BLOB NULL,
  OJB_CONCRETE_CLASS VARCHAR(255) NOT NULL,
  KEY_OWNER INT(11) NULL,
  KEY_ROOT_DOMAIN_OBJECT INT(11) NOT NULL DEFAULT 1,
  KEY_EXECUTION_COURSE INT(11) NULL,
  PRIMARY KEY  (ID_INTERNAL)
) ENGINE=InnoDB;


DROP TABLE IF EXISTS CONVERSATION_THREAD;
CREATE TABLE CONVERSATION_THREAD (
  ID_INTERNAL INT(11) NOT NULL auto_increment,
  CREATION_DATE_DATE_TIME TIMESTAMP NOT NULL,
  SUBJECT VARCHAR(255) NOT NULL,
  KEY_FORUM INT(11) NOT NULL,
  KEY_CREATOR INT(11) NOT NULL,
  KEY_ROOT_DOMAIN_OBJECT INT(11) NOT NULL DEFAULT 1,
  PRIMARY KEY (ID_INTERNAL),
  UNIQUE (KEY_FORUM,SUBJECT)
) ENGINE=InnoDB;


DROP TABLE IF EXISTS CONVERSATION_MESSAGE;
CREATE TABLE CONVERSATION_MESSAGE (
  ID_INTERNAL INT(11) NOT NULL auto_increment,
  CREATION_DATE_DATE_TIME TIMESTAMP NOT NULL,
  BODY TEXT NOT NULL,
  KEY_CONVERSATION_THREAD INT(11) NOT NULL,
  KEY_CREATOR INT(11) NOT NULL,
  KEY_ROOT_DOMAIN_OBJECT INT(11) NOT NULL DEFAULT 1,
  PRIMARY KEY (ID_INTERNAL)
) ENGINE=InnoDB;
