CREATE TABLE user_keys (
    user_name VARCHAR(64) UNIQUE NOT NULL PRIMARY KEY,
    user_id INT UNIQUE NOT NULL,
    protected_privatekey TEXT UNIQUE NOT NULL,
    publickey TEXT UNIQUE NOT NULL,
    created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
    updated_at DATETIME ON UPDATE CURRENT_TIMESTAMP
);

CREATE TABLE chat_keys (
    user_name VARCHAR(64) NOT NULL,
    user_id INT NOT NULL,
    chat_id INT NOT NULL,
    protected_symetrickey TEXT UNIQUE NOT NULL,
    created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
    updated_at DATETIME ON UPDATE CURRENT_TIMESTAMP,
    FOREIGN KEY (user_name) REFERENCES user_keys(user_name)
);