@@ 9,35 9,30 @@ CREATE TABLE Client (
id INTEGER PRIMARY KEY,
client_id TEXT NOT NULL UNIQUE,
client_secret_hash BLOB,
- owner INTEGER,
+ owner INTEGER REFERENCES User(id),
redirect_uris TEXT,
client_name TEXT,
- client_uri TEXT,
- FOREIGN KEY(owner) REFERENCES User(id)
+ client_uri TEXT
);
CREATE TABLE AccessToken (
id INTEGER PRIMARY KEY,
hash BLOB NOT NULL UNIQUE,
- user INTEGER NOT NULL,
- client INTEGER,
+ user INTEGER NOT NULL REFERENCES User(id),
+ client INTEGER REFERENCES Client(id),
scope TEXT,
issued_at datetime NOT NULL,
expires_at datetime NOT NULL,
refresh_hash BLOB UNIQUE,
- refresh_expires_at datetime,
- FOREIGN KEY(user) REFERENCES User(id),
- FOREIGN KEY(client) REFERENCES Client(id)
+ refresh_expires_at datetime
);
CREATE TABLE AuthCode (
id INTEGER PRIMARY KEY,
hash BLOB NOT NULL UNIQUE,
created_at datetime NOT NULL,
- user INTEGER NOT NULL,
- client INTEGER NOT NULL,
+ user INTEGER NOT NULL REFERENCES User(id),
+ client INTEGER NOT NULL REFERENCES Client(id),
redirect_uri TEXT,
- scope TEXT,
- FOREIGN KEY(user) REFERENCES User(id),
- FOREIGN KEY(client) REFERENCES Client(id)
+ scope TEXT
);