alter table Issue drop constraint Issue_reporter;
alter table Issue drop constraint Issue_project;
alter table Issue drop constraint Issue_developer;
alter table HistoryEntry drop constraint Issue_historyEntries;
alter table HistoryEntry drop constraint Comment_editor;
alter table Role drop constraint FK26F49636EBCB;
alter table Role drop constraint FK26F496ED904B19;
alter table Role drop constraint Role_project;
alter table Role drop constraint Role_user;
drop table if exists Issue;
drop table if exists User;
drop table if exists Project;
drop table if exists HistoryEntry;
drop table if exists Role;
create table Issue (
   id integer not null auto_increment,
   description text,
   developer integer,
   name varchar(64),
   priority integer not null,
   project integer not null,
   reporter integer not null,
   status integer not null,
   type integer not null,
   primary key (id)
);
create table User (
   id integer not null auto_increment,
   administrator bit not null,
   email varchar(128),
   enabled bit not null,
   guest bit not null,
   name varchar(64) unique,
   password varchar(64),
   primary key (id)
);
create table Project (
   id integer not null auto_increment,
   enabled bit not null,
   name varchar(64) unique,
   primary key (id)
);
create table HistoryEntry (
   id integer not null auto_increment,
   comment text,
   date datetime,
   editor integer not null,
   status integer not null,
   issue integer,
   position integer,
   primary key (id)
);
create table Role (
   id integer not null auto_increment,
   developer bit not null,
   manager bit not null,
   project integer not null,
   user integer not null,
   reporter bit not null,
   primary key (id)
);
alter table Issue add index Issue_reporter (reporter), add constraint Issue_reporter foreign key (reporter) references User (id);
alter table Issue add index Issue_project (project), add constraint Issue_project foreign key (project) references Project (id);
alter table Issue add index Issue_developer (developer), add constraint Issue_developer foreign key (developer) references User (id);
alter table HistoryEntry add index Issue_historyEntries (issue), add constraint Issue_historyEntries foreign key (issue) references Issue (id);
alter table HistoryEntry add index Comment_editor (editor), add constraint Comment_editor foreign key (editor) references User (id);
alter table Role add index FK26F49636EBCB (user), add constraint FK26F49636EBCB foreign key (user) references User (id);
alter table Role add index FK26F496ED904B19 (project), add constraint FK26F496ED904B19 foreign key (project) references Project (id);
alter table Role add index Role_project (project), add constraint Role_project foreign key (project) references Project (id);
alter table Role add index Role_user (user), add constraint Role_user foreign key (user) references User (id);
