   UNIQUE ("POSMATCHID","TAG"),
   CONSTRAINT "tagsfk" FOREIGN KEY ("TAG") REFERENCES "tags" ("TAG") ON DELETE CASCADE ON UPDATE CASCADE
 );
-create index "tagsfk_idx" on "postags"("TAG");
+create index if not exists "tagsfk_idx" on "postags"("TAG");
 
-CREATE TABLE "preferences" (
+CREATE TABLE if not exists "preferences"(
   "id" integer primary key,
   "username" varchar(50) NOT NULL,
   "name" varchar(50) NOT NULL,

  CONSTRAINT "rep_posmatchid_fk" FOREIGN KEY ("posmatchid") REFERENCES "posmatchids" ("posmatchid") ON DELETE SET NULL ON UPDATE NO ACTION,
  CONSTRAINT "rep_username_fk" FOREIGN KEY ("username") REFERENCES "users" ("username") ON DELETE NO ACTION ON UPDATE NO ACTION
);
create index "rep_posmatchid_fk_idx" on "reports"("posmatchid");
create index "rep_username_fk_idx" on "reports"("username");

CREATE TABLE "stats" (
  "id" integer primary key,
  "numofpositions" int(11) DEFAULT NULL,
  "numofsubmissionslast24h" int(10) DEFAULT NULL
);

CREATE TABLE "tags" (
  "id" integer primary key,
  "TAG" varchar(30) NOT NULL,
  "DONETAGGING" char(1) DEFAULT NULL,

  CONSTRAINT "usersposmatchids_ibfk_1" FOREIGN KEY ("username") REFERENCES "users" ("username"),
  CONSTRAINT "usersposmatchids_ibfk_2" FOREIGN KEY ("posmatchid") REFERENCES "posmatchids" ("posmatchid") ON DELETE CASCADE
);
create index if not exists "usersposmatchids_idx1" on "usersposmatchids"("eqdiff");
create index if not exists "username" on "usersposmatchids"("username");
