~emersion/sinwon

619a38a2e72c72ec7c822ae6e11b5fa7e6e6b6c8 — Simon Ser 6 months ago b23dd4c
Inline foreign key definitions in DB schema
1 files changed, 8 insertions(+), 13 deletions(-)

M schema.sql
M schema.sql => schema.sql +8 -13
@@ 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
);