waqfd
f
lter table PERSON add (`KEY_CMS` int default null);
alter table EXECUTION_COURSE add (`KEY_EXECUTION_COURSE_WEBSITE` int default null);

DROP TABLE IF EXISTS `CMS_CMS`;
CREATE TABLE `CMS_CMS` (
	`ID_INTERNAL` int NOT NULL auto_increment, 
	`NAME` text NOT NULL,
	`KEY_CONFIGURATION` int,	
    PRIMARY KEY (`ID_INTERNAL`)
)TYPE=InnoDB;

insert into CMS_CMS(`ID_INTERNAL`,`NAME`,`KEY_CONFIGURATION`) values(1,"FenixCMS",1);

DROP TABLE IF EXISTS `CMS_CONTENT_HIERARCHY`;
CREATE TABLE `CMS_CONTENT_HIERARCHY` (
	`ID_INTERNAL` int NOT NULL auto_increment, 
	`KEY_CHILD` int NOT NULL,
	`KEY_PARENT` int NOT NULL,	
    PRIMARY KEY (`ID_INTERNAL`)
)TYPE=InnoDB;

DROP TABLE IF EXISTS `CMS_MAILING_LIST`;
CREATE TABLE `CMS_MAILING_LIST` (
	`ID_INTERNAL` int NOT NULL auto_increment, 
	`CREATION_DATE` timestamp NOT NULL,	
	`KEY_CREATOR` int NOT NULL,
	`KEY_QUEUE` int,		
	`NAME` text,
	`DESCRIPTION` text,	
	`ADDRESS` text NOT NULL,		
	`CLOSED` bit NOT NULL,	
    `MEMBERS_ONLY` bit NOT NULL,
    `REPLY_TO_LIST` bit NOT NULL,
	`KEY_CMS` int,		
	`KEY_WRITERS_GROUP` int,
	`KEY_READERS_GROUP` int,	
    PRIMARY KEY (`ID_INTERNAL`)
    
)TYPE=InnoDB;

DROP TABLE IF EXISTS `CMS_MAIL_CONVERSATION`;
CREATE TABLE `CMS_MAIL_CONVERSATION` (
	`ID_INTERNAL` int NOT NULL auto_increment, 
	`CREATION_DATE` timestamp NOT NULL,	
	`KEY_CREATOR` int NOT NULL,
	`NAME` text ,
	`SUBJECT` text,	
	`DESCRIPTION` text NOT NULL,	
	`KEY_CMS` int,		
	`KEY_WRITERS_GROUP` int,
	`KEY_READERS_GROUP` int,	
    PRIMARY KEY (`ID_INTERNAL`)
)TYPE=InnoDB;

DROP TABLE IF EXISTS `CMS_MAIL_MESSAGE`;
CREATE TABLE `CMS_MAIL_MESSAGE` (
	`ID_INTERNAL` int NOT NULL auto_increment, 
	`CREATION_DATE` timestamp NOT NULL,	
	`KEY_CREATOR` int NOT NULL,
	`KEY_MAILING_LIST` int,			
	`NAME` text,
	`DESCRIPTION` text ,	
	`BODY` longtext NOT NULL,	
	`KEY_CMS` int,		
	`KEY_WRITERS_GROUP` int,
	`KEY_READERS_GROUP` int,	
    PRIMARY KEY (`ID_INTERNAL`)
)TYPE=InnoDB;

DROP TABLE IF EXISTS `CMS_MAIL_QUEUE`;
CREATE TABLE `CMS_MAIL_QUEUE` (
	`ID_INTERNAL` int NOT NULL auto_increment, 
	`KEY_MAILING_LIST` int,	
    PRIMARY KEY (`ID_INTERNAL`)
)TYPE=InnoDB;

DROP TABLE IF EXISTS `CMS_MAIL_MESSAGE_MAIL_QUEUE`;
CREATE TABLE `CMS_MAIL_MESSAGE_MAIL_QUEUE` (
	`ID_INTERNAL` int NOT NULL auto_increment, 
	`KEY_MAIL_MESSAGE` int NOT NULL,
	`KEY_MAIL_QUEUE` int NOT NULL,
	PRIMARY KEY (`ID_INTERNAL`)
)TYPE=InnoDB;

DROP TABLE IF EXISTS `CMS_CONFIGURATION`;
CREATE TABLE `CMS_CONFIGURATION` (
	`ID_INTERNAL` int NOT NULL auto_increment, 
	`REPLY_TO_MAILING_LIST` boolean NOT NULL,
	`SMTP_SERVER_ADDRESS` text NOT NULL,
	`FILTER_NON_TEXTUAL_ATTACHMENTS` boolean NOT NULL,
	`KEY_CMS` int NOT NULL,
	`MAILING_LIST_HOST` text NOT NULL,
	`CONVERSATION_REPLY_MARKERS` text NOT NULL,	
	`MAX_ATTACHMENT_SIZE` int NOT NULL,
	`MAX_MESSAGE_SIZE` int NOT NULL,
	`SEND_MAIL_TIMEOUT` int NOT NULL,
	 PRIMARY KEY (`ID_INTERNAL`)
)TYPE=InnoDB;
insert into CMS_CONFIGURATION(
`ID_INTERNAL`,
`REPLY_TO_MAILING_LIST`,
`SMTP_SERVER_ADDRESS`,
`FILTER_NON_TEXTUAL_ATTACHMENTS`,
`KEY_CMS`,
`MAILING_LIST_HOST`,
`CONVERSATION_REPLY_MARKERS`,
`MAX_ATTACHMENT_SIZE`,
`MAX_MESSAGE_SIZE`
) 
values(
1,
1,
'mail.adm',
1,
1,
'lists.fenix.ist.utl.pt',
'Re:,Res:,Reply:,Resposta:',
10000000,
10500000
);

DROP TABLE IF EXISTS `CMS_MAIL_ADDRESS_ALIAS`;
CREATE TABLE `CMS_MAIL_ADDRESS_ALIAS` (
	`ID_INTERNAL` int NOT NULL auto_increment, 
	`ADDRESS` text,
	PRIMARY KEY (`ID_INTERNAL`)
)TYPE=InnoDB;

DROP TABLE IF EXISTS `CMS_MAIL_ADDRESS_ALIAS_MAILING_LIST`;
CREATE TABLE `CMS_MAIL_ADDRESS_ALIAS_MAILING_LIST` (
	`ID_INTERNAL` int NOT NULL auto_increment, 
	`KEY_MAIL_ADDRESS_ALIAS` int NOT NULL,
	`KEY_MAILING_LIST` int NOT NULL,
	PRIMARY KEY (`ID_INTERNAL`)
)TYPE=InnoDB;

DROP TABLE IF EXISTS `CMS_CONTENT_OWNERSHIP`;
CREATE TABLE `CMS_CONTENT_OWNERSHIP` (
	`ID_INTERNAL` int NOT NULL auto_increment,
	`KEY_OWNER` int NOT NULL,
	`KEY_CONTENT` int NOT NULL,
	PRIMARY KEY (`ID_INTERNAL`)
)TYPE=InnoDB;

DROP TABLE IF EXISTS `CMS_EXECUTION_COURSE_WEBSITE`;
CREATE TABLE `CMS_EXECUTION_COURSE_WEBSITE` (
	`ID_INTERNAL` int NOT NULL auto_increment,
	`KEY_EXECUTION_COURSE` int NOT NULL,
    `CREATION_DATE` timestamp NOT NULL,
    `KEY_CREATOR` int NOT NULL,
    `NAME` text,
    `DESCRIPTION` text,
    `KEY_CMS` int NOT NULL,
    `KEY_READERS_GROUP` int,
	`KEY_WRITERS_GROUP` int,
	PRIMARY KEY (`ID_INTERNAL`)
)TYPE=InnoDB;
