shellcoreDB made... n shi
This commit is contained in:
1 parent
244bd918d6
commit
bcc9894062
19 files changed
+493
-22
No files matched your search
@@ -0,0 +1,39 @@
|
||||
CREATE TABLE IF NOT EXISTS accounts (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid (),
|
||||
username VARCHAR(32) NOT NULL,
|
||||
displayName VARCHAR(64),
|
||||
avatarURL TEXT,
|
||||
status TEXT NOT NULL DEFAULT 'active' CHECK (status in ('active', 'suspended', 'disabled')),
|
||||
createdAt TIMESTAMPTZ NOT NULL DEFAULT NOW (),
|
||||
updatedAt TIMESTAMPTZ NOT NULL DEFAULT NOW (),
|
||||
lastLoginAt TIMESTAMPTZ
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS localCredentials (
|
||||
accountId UUID PRIMARY KEY REFERENCES accounts (id) ON DELETE CASCADE,
|
||||
passwordHash TEXT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE externalAccounts (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid (),
|
||||
accountId UUID NOT NULL REFERENCES accounts (id) ON DELETE CASCADE,
|
||||
provider TEXT NOT NULL,
|
||||
providerUserId TEXT NOT NULL,
|
||||
linkedAt TIMESTAMPTZ NOT NULL DEFAULT NOW (),
|
||||
UNIQUE (provider, providerUserId),
|
||||
UNIQUE (accountId, provider)
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS accountsUsernameUnique ON accounts (LOWER(username));
|
||||
|
||||
CREATE TABLE IF NOT EXISTS sessions (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid (),
|
||||
accountId UUID NOT NULL REFERENCES accounts (id) ON DELETE CASCADE,
|
||||
tokenHash TEXT NOT NULL UNIQUE,
|
||||
createdAt TIMESTAMPTZ NOT NULL DEFAULT NOW (),
|
||||
expiresAt TIMESTAMPTZ NOT NULL,
|
||||
lastUsedAt TIMESTAMPTZ,
|
||||
revokedAt TIMESTAMPTZ
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS lookUp ON sessions (accountId);
|
||||
Reference in new issue
Block a user