alter table ACTIVITY_LOG_ENTRY drop foreign key FKE28F464793A39FF3;
alter table ACTIVITY_LOG_ENTRY drop foreign key FKE28F4647231DFDB3;
alter table ACTIVITY_LOG_ENTRY drop foreign key FKE28F4647E845E3D3;
alter table ACTIVITY_LOG_ENTRY drop foreign key FKE28F46471B433615;
alter table MASTER_FILES drop foreign key FK904D723AD1A13715;
alter table MONITORED_DIRECTORY drop foreign key FKB4A078E7D1A13715;
alter table MONITORED_DIRECTORY drop foreign key FKB4A078E71B433615;
alter table REPLICA_FILE drop foreign key FKDF8D68C393A39FF3;
alter table REPLICA_FILE drop foreign key FKDF8D68C3231DFDB3;
alter table REPLICA_MAP drop foreign key FK4104A915DECE3EB3;
alter table SRB_LOCATIONS drop foreign key FK34558BC2DECE3EB3;
alter table SRB_LOCATIONS drop foreign key FK34558BC21B433615;
create table ACTIVITY_LOG_ENTRY (id bigint not null auto_increment, type integer, date datetime, message text, affectedType integer, REPLICAMAP_FK bigint, REPLICAFILE_FK bigint, MASTERFILES_FK bigint, REPLICALOCATION_FK bigint, primary key (id));
create table MASTER_FILES (id bigint not null auto_increment, name varchar(255), checksum varchar(255), firstSeen datetime, lastSeen datetime, fileState char(1), MONITOREDDIRECTORY_FK bigint not null, primary key (id));
create table MONITORED_DIRECTORY (id bigint not null auto_increment, path varchar(255), REPLICAMAP_FK bigint not null, MONITOREDDIRECTORY_FK bigint, primary key (id));
create table REPLICA_FILE (id bigint not null auto_increment, lastSeen datetime, state char(1), REPLICALOCATION_FK bigint not null, MASTERFILES_FK bigint not null, primary key (id));
create table REPLICA_MAP (id bigint not null auto_increment, name varchar(255), path varchar(255), lastSeen datetime, state char(1), SRBRESOURCE_FK bigint not null, primary key (id));
create table SRB_LOCATIONS (id bigint not null auto_increment, path varchar(255), resource varchar(255), lastSeen datetime, state char(1), SRBRESOURCE_FK bigint not null, REPLICAMAP_FK bigint not null, primary key (id));
create table USER_ROLES (id bigint not null auto_increment, username varchar(255), rolename varchar(255), primary key (id));
alter table MASTER_FILES add index FK904D723AD1A13715 (MONITOREDDIRECTORY_FK), add constraint FK904D723AD1A13715 foreign key (MONITOREDDIRECTORY_FK) references MONITORED_DIRECTORY (id);
create index MONITOREDDIRECTORY_PATH on MONITORED_DIRECTORY (path);
create index actlogtypeidx on ACTIVITY_LOG_ENTRY (type) ;
create index nameidx on MASTER_FILES (name);
alter table MONITORED_DIRECTORY add index FKB4A078E7D1A13715 (MONITOREDDIRECTORY_FK), add constraint FKB4A078E7D1A13715 foreign key (MONITOREDDIRECTORY_FK) references MONITORED_DIRECTORY (id);
alter table MONITORED_DIRECTORY add index FKB4A078E71B433615 (REPLICAMAP_FK), add constraint FKB4A078E71B433615 foreign key (REPLICAMAP_FK) references REPLICA_MAP (id);
alter table REPLICA_FILE add index FKDF8D68C393A39FF3 (MASTERFILES_FK), add constraint FKDF8D68C393A39FF3 foreign key (MASTERFILES_FK) references MASTER_FILES (id);
alter table REPLICA_FILE add index FKDF8D68C3231DFDB3 (REPLICALOCATION_FK), add constraint FKDF8D68C3231DFDB3 foreign key (REPLICALOCATION_FK) references SRB_LOCATIONS (id);
alter table REPLICA_MAP add index FK4104A915DECE3EB3 (SRBRESOURCE_FK), add constraint FK4104A915DECE3EB3 foreign key (SRBRESOURCE_FK) references SRB_RESOURCE (id);
alter table SRB_LOCATIONS add index FK34558BC2DECE3EB3 (SRBRESOURCE_FK), add constraint FK34558BC2DECE3EB3 foreign key (SRBRESOURCE_FK) references SRB_RESOURCE (id);
alter table SRB_LOCATIONS add index FK34558BC21B433615 (REPLICAMAP_FK), add constraint FK34558BC21B433615 foreign key (REPLICAMAP_FK) references REPLICA_MAP (id);
insert into USER_ROLES (username, rolename) values ('admin','Administrator');