CREATE TABLE
    IF NOT EXISTS users (
        id INTEGER PRIMARY KEY NOT NULL,
        username TEXT NOT NULL UNIQUE,
        password TEXT NOT NULL,
        created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
        updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
    );

-- Create a trigger to set created_at and updated_at on INSERT
CREATE TRIGGER IF NOT EXISTS set_created_at AFTER INSERT ON users BEGIN
UPDATE users
SET
    created_at = CURRENT_TIMESTAMP
WHERE
    id = NEW.id;

END;

-- Create a trigger to set updated_at on UPDATE
CREATE TRIGGER IF NOT EXISTS set_updated_at AFTER
UPDATE ON users BEGIN
UPDATE users
SET
    updated_at = CURRENT_TIMESTAMP
WHERE
    id = NEW.id;

END;

CREATE INDEX users_username_index ON users (username);