CREATE TABLE users (
    id serial4 NOT NULL,
    name TEXT,
    username TEXT,
    email TEXT,
    password TEXT,
    active BOOLEAN DEFAULT true,

    created_by INT,
    updated_by INT,

    created_at TIMESTAMP DEFAULT now(),
    updated_at TIMESTAMP DEFAULT now(),
    deleted_at TIMESTAMP,
    password_changed_at TIMESTAMP,
    
    CONSTRAINT users_pkey PRIMARY KEY (id)
);
CREATE UNIQUE INDEX users_name_unique_not_deleted ON users(username) WHERE deleted_at IS NULL;
CREATE UNIQUE INDEX users_email_unique_not_deleted ON users(email) WHERE deleted_at IS NULL;

-- seed superadmin, admin
INSERT INTO users (name, username, email, password, active, created_by, updated_by) VALUES
('Super Admin', 'superadmin', 'superadmin@demo.com', '$2b$12$3LuOKz92YyaYiYGV3CRW6OIvfDG07aAc4glp73xORK2r7M.07QW2W', 1, 1, 1),
('Admin', 'admin', 'admin@demo.com', '$2b$12$HbOpyJHL6YOfTOXrHMwqFePEeDV8KZZzm/wMi6fW1g2wbAwc2dUvS',  2, 1, 1);