CREATE TABLE user_entity (
  id TEXT PRIMARY KEY,
  name TEXT NOT NULL,
  created_at BIGINT NOT NULL,
  email TEXT NOT NULL UNIQUE,
  password TEXT NOT NULL,
  salt TEXT NOT NULL,
  enabled BOOLEAN NOT NULL,
  company TEXT NOT NULL
);

selectUserByEmail:
SELECT *
FROM user_entity
WHERE email = ?
LIMIT 1;

selectEnabledUserByEmail:
SELECT *
FROM user_entity
WHERE email = ? AND enabled = TRUE
LIMIT 1;

selectUserById:
SELECT *
FROM user_entity
WHERE id = ?
LIMIT 1;

insertUser:
INSERT INTO user_entity(id, name, created_at, email, password, salt, enabled, company)
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
ON CONFLICT(id) DO
UPDATE SET id=excluded.id, name=excluded.name, created_at=excluded.created_at, email=excluded.email, password=excluded.password, salt=excluded.salt, enabled=excluded.enabled, company=excluded.company;

deleteUser:
DELETE
FROM user_entity
WHERE id = ?;

deleteUserByEmail:
DELETE
FROM user_entity
WHERE email = ?;

enableUserByEmail:
UPDATE user_entity
SET enabled = TRUE
WHERE email = ?;

disableUserByEmail:
UPDATE user_entity
SET enabled = FALSE
WHERE email = ?;

