aboutsummaryrefslogtreecommitdiff
path: root/migrations/2018-01-14-171611_create_tables/up.sql
blob: 6f4d31fa6980a1ce988a93a0c5355b25b34cc060 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
CREATE TABLE users (
  uuid                TEXT        NOT NULL PRIMARY KEY,
  created_at          DATETIME    NOT NULL,
  updated_at          DATETIME    NOT NULL,
  email               TEXT UNIQUE NOT NULL,
  name                TEXT        NOT NULL,
  password_hash       BLOB        NOT NULL,
  salt                BLOB        NOT NULL,
  password_iterations INTEGER     NOT NULL,
  password_hint       TEXT,
  key                 TEXT        NOT NULL,
  private_key         TEXT,
  public_key          TEXT,
  totp_secret         TEXT,
  totp_recover        TEXT,
  security_stamp      TEXT        NOT NULL
);

CREATE TABLE devices (
  uuid          TEXT        NOT NULL PRIMARY KEY,
  created_at    DATETIME    NOT NULL,
  updated_at    DATETIME    NOT NULL,
  user_uuid     TEXT        NOT NULL REFERENCES users (uuid),
  name          TEXT        NOT NULL,
  type          INTEGER     NOT NULL,
  push_token    TEXT UNIQUE,
  refresh_token TEXT UNIQUE NOT NULL
);

CREATE TABLE ciphers (
  uuid              TEXT     NOT NULL PRIMARY KEY,
  created_at        DATETIME NOT NULL,
  updated_at        DATETIME NOT NULL,
  user_uuid         TEXT     NOT NULL REFERENCES users (uuid),
  folder_uuid       TEXT REFERENCES folders (uuid),
  organization_uuid TEXT,
  type              INTEGER  NOT NULL,
  data              TEXT     NOT NULL,
  favorite          BOOLEAN  NOT NULL,
  attachments       BLOB
);

CREATE TABLE folders (
  uuid       TEXT     NOT NULL PRIMARY KEY,
  created_at DATETIME NOT NULL,
  updated_at DATETIME NOT NULL,
  user_uuid  TEXT     NOT NULL REFERENCES users (uuid),
  name       TEXT     NOT NULL
);