1CREATE TABLE users (
2  uuid                TEXT     NOT NULL PRIMARY KEY,
3  created_at          DATETIME NOT NULL,
4  updated_at          DATETIME NOT NULL,
5  email               TEXT     NOT NULL UNIQUE,
6  name                TEXT     NOT NULL,
7  password_hash       BLOB     NOT NULL,
8  salt                BLOB     NOT NULL,
9  password_iterations INTEGER  NOT NULL,
10  password_hint       TEXT,
11  key                 TEXT     NOT NULL,
12  private_key         TEXT,
13  public_key          TEXT,
14  totp_secret         TEXT,
15  totp_recover        TEXT,
16  security_stamp      TEXT     NOT NULL,
17  equivalent_domains  TEXT     NOT NULL,
18  excluded_globals    TEXT     NOT NULL
19);
20
21CREATE TABLE devices (
22  uuid          TEXT     NOT NULL PRIMARY KEY,
23  created_at    DATETIME NOT NULL,
24  updated_at    DATETIME NOT NULL,
25  user_uuid     TEXT     NOT NULL REFERENCES users (uuid),
26  name          TEXT     NOT NULL,
27  type          INTEGER  NOT NULL,
28  push_token    TEXT,
29  refresh_token TEXT     NOT NULL
30);
31
32CREATE TABLE ciphers (
33  uuid              TEXT     NOT NULL PRIMARY KEY,
34  created_at        DATETIME NOT NULL,
35  updated_at        DATETIME NOT NULL,
36  user_uuid         TEXT     NOT NULL REFERENCES users (uuid),
37  folder_uuid       TEXT REFERENCES folders (uuid),
38  organization_uuid TEXT,
39  type              INTEGER  NOT NULL,
40  name              TEXT     NOT NULL,
41  notes             TEXT,
42  fields            TEXT,
43  data              TEXT     NOT NULL,
44  favorite          BOOLEAN  NOT NULL
45);
46
47CREATE TABLE attachments (
48  id          TEXT    NOT NULL PRIMARY KEY,
49  cipher_uuid TEXT    NOT NULL REFERENCES ciphers (uuid),
50  file_name   TEXT    NOT NULL,
51  file_size   INTEGER NOT NULL
52
53);
54
55CREATE TABLE folders (
56  uuid       TEXT     NOT NULL PRIMARY KEY,
57  created_at DATETIME NOT NULL,
58  updated_at DATETIME NOT NULL,
59  user_uuid  TEXT     NOT NULL REFERENCES users (uuid),
60  name       TEXT     NOT NULL
61);
62