CREATE DATABASE IF NOT EXISTS SAZDB;
use SAZDB;
CREATE TABLE IF NOT EXISTS admin(
	dn CHAR(255) NOT NULL PRIMARY KEY,
	principal CHAR(255) NOT NULL,
	enabled ENUM('Y','N') NOT NULL,
	changedAt TIMESTAMP
	);

CREATE TABLE user (
	user_name CHAR(255) NOT NULL PRIMARY KEY,
	enabled ENUM('Y','N') NOT NULL,
	trusted ENUM('Y','N') NOT NULL, 
	changeAt TIMESTAMP
	);

CREATE TABLE vo (
	vo_name CHAR(255) NOT NULL PRIMARY KEY,
	enabled ENUM('Y','N') NOT NULL,
	trusted ENUM('Y','N') NOT NULL,
	changeAt TIMESTAMP
);

CREATE TABLE ca (
	ca_name CHAR(255) NOT NULL PRIMARY KEY,
	enabled ENUM('Y','N') NOT NULL,
        trusted ENUM('Y','N') NOT NULL,
        changeAt TIMESTAMP
);

CREATE TABLE role (
        role_name CHAR(255) NOT NULL PRIMARY KEY,
        enabled ENUM('Y','N') NOT NULL,
        trusted ENUM('Y','N') NOT NULL,
        changeAt TIMESTAMP
);


GRANT ALL ON SAZDB.* TO sazdbuser@localhost IDENTIFIED BY '12345';
GRANT ALL ON SAZDB.* TO sazdbuser@localhost.localdomain IDENTIFIED BY '12345';
FLUSH PRIVILEGES;

--rights ENUM('all','add','del','ls','enable','disable','prin') DEFAULT 'all',
