CREATE TABLE TiberPortal.Users (
    id              MEDIUMINT   NOT NULL AUTO_INCREMENT,
    userlogin       Varchar(80) NOT NULL,
    status          Varchar(1)  NOT NULL,
    timeStamp       BIGINT     NOT NULL,
    passwordHash    Varchar(512)    NULL,
    passwordExpire  DateTime        NULL,
    PRIMARY KEY (id)
)
;

Create Unique Index Users_userlogin
On TiberPortal.Users (userlogin);

Delimiter //
CREATE TRIGGER TiberPortal.BeforeInsert_Users
  BEFORE INSERT ON TiberPortal.Users
  FOR EACH ROW
       BEGIN
           IF NEW.timeStamp is NULL THEN
               SET NEW.timeStamp = UNIX_TIMESTAMP();
           END IF;
       END;
  //
  delimiter ;

Insert into TiberPortal.Users
(userLogin, status, passwordHash, passwordExpire)
values
('admin','A', null, null)
;
