START TRANSACTION;

ALTER TABLE "tblUsers" ALTER COLUMN "pwd" TYPE varchar(255) DEFAULT NULL;

ALTER TABLE "tblUsers" ADD COLUMN "webauthn" TYPE varchar(1024) DEFAULT NULL;

CREATE TABLE "tblAttributeDefinitionGroups" (
  "id" SERIAL UNIQUE,
  "name" varchar(100) default NULL,
  "comment" text,
  UNIQUE ("name")
);

CREATE TABLE "tblAttributeDefinitionGroupAttributeDefinition" (
  "attrdef" INTEGER REFERENCES "tblAttributeDefinitions" ("id") ON DELETE CASCADE,
  "attrgrp" INTEGER REFERENCES "tblAttributeDefinitionGroups" ("id") ON DELETE CASCADE,
  "sequence" REAL NOT NULL default '0',
	"show" INTEGER,
  UNIQUE ("attrdef", "attrgrp")
);

CREATE TABLE "tblFolderAttributeDefinitionGroup" (
  "folder" INTEGER REFERENCES "tblFolders" ("id") ON DELETE CASCADE,
  "attrgrp" INTEGER REFERENCES "tblAttributeDefinitionGroups" ("id") ON DELETE CASCADE,
  "sequence" REAL NOT NULL default '0',
  UNIQUE ("folder", "attrgrp")
);

UPDATE "tblVersion" set "major"=6, "minor"=1, "subminor"=0;

COMMIT;
