-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path20250918133522_users.sql
More file actions
51 lines (47 loc) · 1.78 KB
/
20250918133522_users.sql
File metadata and controls
51 lines (47 loc) · 1.78 KB
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
51
-- Migration: Create users-related tables
-- Created: 2025-08-26
-- Author: Osef
-- Description: Schema for managing users, devices, bans, and pending registrations
-- Version: 1.0.0
-- ========================================
-- Table: users
-- Stores registered users
-- ========================================
CREATE TABLE users (
discord_id BIGINT PRIMARY KEY,
username TEXT, -- Optional, for display purposes
created_at TIMESTAMP DEFAULT NOW() NOT NULL,
roles JSONB DEFAULT '["user"]'::jsonb NOT NULL
);
-- ========================================
-- Table: device_tokens
-- Stores tokens tied to user devices
-- ========================================
CREATE TABLE device_tokens (
token UUID PRIMARY KEY,
discord_id BIGINT REFERENCES users(discord_id) ON DELETE CASCADE,
device_name TEXT, -- Optional, device identifier
hwid TEXT, -- Optional, hardware identifier
created_at TIMESTAMP DEFAULT NOW() NOT NULL
);
-- ========================================
-- Table: bans
-- Stores user ban history
-- ========================================
CREATE TABLE bans (
id SERIAL PRIMARY KEY,
discord_id BIGINT REFERENCES users(discord_id) ON DELETE CASCADE,
reason TEXT, -- Optional ban reason
banned_at TIMESTAMP DEFAULT NOW() NOT NULL
);
-- ========================================
-- Table: new_users
-- Temporary table for unvalidated users
-- Prevents multiple accounts before validation
-- ========================================
CREATE TABLE new_users (
discord_id BIGINT PRIMARY KEY,
username TEXT,
token UUID UNIQUE NOT NULL, -- Validation token sent via Discord DM
created_at TIMESTAMP DEFAULT NOW() NOT NULL
);