/*==============================================================*/
/* Table: PROJECTS                                              */
/*==============================================================*/
create table PROJECTS (
CATEGORYID           INTEGER                        not null,
EXTERNALCONTACTS     VARCHAR(1024),

constraint PK_PROJECTS primary key (CATEGORYID),
constraint FK_PROJECTS foreign key (CATEGORYID) references CATEGORIES 
(CATEGORYID) ON DELETE CASCADE
);

/*==============================================================*/
/* Table: PROJECTMESSAGES                                       */
/*==============================================================*/
create table PROJECTMESSAGES (

MessageId            INTEGER                        not null,
ProjectId            INTEGER                        not null,
MessageText          VARCHAR(2048),
AssociatedObjectId   INTEGER,
AssociatedObjectType INTEGER,
Created              TIMESTAMP                      not null,
CreatorId            INTEGER,

constraint PK_PROJECTMESSAGES primary key (MESSAGEID),
constraint FK_PROJECTMESSAGES foreign key (PROJECTID) references PROJECTS 
(CATEGORYID) ON DELETE CASCADE
);

CREATE ASC INDEX index_PROJECTMESSAGES ON PROJECTMESSAGES ProjectId;

create generator PROJECTMESSAGES_SEQ;
set generator PROJECTMESSAGES_SEQ to 1;

update SYSPARAMETERS set VALUESTRING = '42' where CONTEXT = 'SYSTEMINFO' and name = 'DBVersionLow';
update SYSPARAMETERS set VALUESTRING = '2004-02-21' where CONTEXT = 'SYSTEMINFO' and name = 'DBCreationDate';
commit;
