diff --git a/ykval-db.sql b/ykval-db.sql index 0d364bb..ef20211 100644 --- a/ykval-db.sql +++ b/ykval-db.sql @@ -1,49 +1,27 @@ -CREATE DATABASE yubico; -USE yubico; +-- DROP DATABASE ykval; +CREATE DATABASE ykval; +USE ykval; CREATE TABLE clients ( - id int NOT NULL auto_increment, - perm_id int default NULL, - active boolean default true, - created datetime NOT NULL, - email varchar(255) NOT NULL default '', - secret varchar(60) NOT NULL default '', - notes varchar(100) default NULL, - chk_sig boolean default false, - chk_owner boolean default false, - chk_time boolean default true, - PRIMARY KEY (id), - UNIQUE KEY email (email), - KEY perm_id (perm_id), - CONSTRAINT clients_ibfk_1 FOREIGN KEY (perm_id) REFERENCES perms (id) -); - -CREATE TABLE perms ( - id int NOT NULL auto_increment, - verify_otp boolean default false, - add_clients boolean default false, - delete_clients boolean default false, - add_keys boolean default false, - delete_keys boolean default false, - PRIMARY KEY (id) + id INT NOT NULL AUTO_INCREMENT, + active BOOLEAN DEFAULT TRUE, + created DATETIME NOT NULL, + email VARCHAR(255) NOT NULL DEFAULT '', + secret VARCHAR(60) NOT NULL DEFAULT '', + chk_time BOOLEAN DEFAULT TRUE, + PRIMARY KEY (id) ); CREATE TABLE yubikeys ( - id int NOT NULL UNIQUE auto_increment, - client_id int NOT NULL default '0', - active boolean default true, - created datetime NOT NULL, - accessed datetime, - tokenId varchar(60) binary unique not null, - userId varchar(60) NOT NULL, - secret varchar(60) NOT NULL, - counter int, - low int, - high int, - notes varchar(100), - serial varchar(45) UNIQUE, - sessionUse int, - PRIMARY KEY (id), - KEY client_id (client_id), - CONSTRAINT yubikeys_ibfk_1 FOREIGN KEY (client_id) REFERENCES clients (id) + id INT NOT NULL UNIQUE AUTO_INCREMENT, + active BOOLEAN DEFAULT TRUE, + created DATETIME NOT NULL, + accessed DATETIME, + publicName VARCHAR(16) UNIQUE NOT NULL, + internalName VARCHAR(12) NOT NULL, + counter INT, + low INT, + high INT, + sessionUse INT, + PRIMARY KEY (id) );