15 lines
549 B
SQL
15 lines
549 B
SQL
CREATE TABLE devices (
|
|
id UUID PRIMARY KEY,
|
|
account_id UUID NOT NULL REFERENCES accounts(id) ON DELETE CASCADE,
|
|
name TEXT NOT NULL,
|
|
platform TEXT NOT NULL CHECK (platform IN ('windows', 'linux', 'android', 'ios', 'macos', 'web')),
|
|
public_id TEXT NOT NULL,
|
|
last_seen_at TIMESTAMPTZ,
|
|
revoked_at TIMESTAMPTZ,
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
UNIQUE (account_id, public_id)
|
|
);
|
|
|
|
CREATE INDEX devices_account_id_idx ON devices(account_id);
|