
CREATE TABLE IF NOT EXISTS migration (
  migration_id TEXT PRIMARY KEY NOT NULL,
  migration_name TEXT NOT NULL UNIQUE,
  created TEXT NOT NULL
);

CREATE TABLE IF NOT EXISTS user_state (
  user_state_id TEXT PRIMARY KEY NOT NULL,
  user_state TEXT NOT NULL
);

CREATE TABLE IF NOT EXISTS role (
  role_id TEXT PRIMARY KEY NOT NULL,
  role TEXT NOT NULL
);

CREATE TABLE IF NOT EXISTS user (
  user_id TEXT PRIMARY KEY NOT NULL,
  created TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
  updated TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
  deleted TEXT DEFAULT NULL,
  email TEXT NOT NULL UNIQUE,
  password_hash TEXT NOT NULL,
  user_state_id TEXT NOT NULL,
  role_id TEXT NOT NULL,
  FOREIGN KEY (user_state_id) REFERENCES user_state(user_state_id),
  FOREIGN KEY (role_id) REFERENCES role(role_id)
);

CREATE TABLE IF NOT EXISTS verification (
  verification_id TEXT PRIMARY KEY NOT NULL,
  user_id TEXT NOT NULL,
  FOREIGN KEY(user_id) REFERENCES user(user_id)
);

CREATE TABLE IF NOT EXISTS session (
  session_id TEXT PRIMARY KEY NOT NULL,
  user_id TEXT NOT NULL,
  FOREIGN KEY(user_id) REFERENCES user(user_id)
);

CREATE TABLE IF NOT EXISTS setting (
  setting_id TEXT PRIMARY KEY NOT NULL,
  setting_name TEXT NOT NULL,
  setting TEXT NOT NULL
);
