You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{
"sampleRate": 48000, // 48000 or 44100"bitDepth": 16, // 16 or 24"bufferSize": 256, // 32, 64, 128, 256, 512, or 1024"autoJitterBuffer": true, // Auto-adjust jitter buffer"backingTrackVolume": 1.0, // 0.0 to 1.0"masterVolume": 1.0, // 0.0 to 1.0"networkMode": "auto", // "auto" (P2P mesh) or "sfu" (force Cloudflare SFU)"maxPerformers": 8, // Max performers allowed (default: 8)"allowListeners": true// Whether to allow listen-only users
}
saved_rooms
Persistent room configurations.
Column
Type
Nullable
Default
Description
id
uuid
NO
uuid_generate_v4()
Primary key
owner_id
uuid
YES
-
FK to user_profiles
code
varchar
NO
-
Unique room code
name
varchar
NO
-
Room name
description
text
YES
''
Description
room_type
varchar
YES
'private'
Room type
max_users
int4
YES
10
Max users
genre
varchar
YES
-
Genre
skill_level
varchar
YES
-
Skill level
min_level
int4
YES
0
Min user level
min_reputation
numeric
YES
0
Min reputation
theme
varchar
YES
'default'
Visual theme
banner_url
varchar
YES
-
Banner image
welcome_message
text
YES
-
Welcome message
rules
text
YES
-
Room rules
tags
text[]
YES
'{}'
Tags array
settings
jsonb
YES
(see rooms.settings)
Room settings (same structure as rooms.settings)
total_sessions
int4
YES
0
Total sessions
total_unique_visitors
int4
YES
0
Unique visitors
total_jam_seconds
int8
YES
0
Total jam time
created_at
timestamptz
YES
now()
Created
updated_at
timestamptz
YES
now()
Updated
last_active_at
timestamptz
YES
-
Last activity
room_members
Room membership and roles.
Column
Type
Nullable
Default
Description
id
uuid
NO
gen_random_uuid()
Primary key
room_id
text
NO
-
FK to rooms
user_id
text
NO
-
User ID
user_name
text
NO
-
Display name
user_avatar
text
YES
-
Avatar URL
role
text
NO
'member'
Role (owner/admin/member)
custom_permissions
jsonb
YES
-
Permission overrides
joined_at
timestamptz
YES
now()
Join time
last_active_at
timestamptz
YES
now()
Last active
invited_by
text
YES
-
Inviter user ID
is_banned
bool
YES
false
Ban status
ban_reason
text
YES
-
Ban reason
room_bans
Room-level bans.
Column
Type
Nullable
Default
Description
id
uuid
NO
gen_random_uuid()
Primary key
room_id
text
NO
-
FK to rooms
user_id
text
NO
-
Banned user ID
reason
text
YES
-
Ban reason
banned_by
text
NO
-
Admin who banned
banned_at
timestamptz
YES
now()
Ban time
expires_at
timestamptz
YES
-
Expiration (null=permanent)
room_invitations
Room invite system.
Column
Type
Nullable
Default
Description
id
uuid
NO
gen_random_uuid()
Primary key
room_id
text
NO
-
FK to rooms
invited_user_id
text
YES
-
Invited user ID
invited_email
text
YES
-
Invited email
invited_by
text
NO
-
Inviter user ID
status
text
NO
'pending'
Status
invite_code
text
YES
-
Unique invite code
message
text
YES
-
Personal message
expires_at
timestamptz
YES
-
Expiration
created_at
timestamptz
YES
now()
Created
updated_at
timestamptz
YES
now()
Updated
room_permission_logs
Permission change audit log.
Column
Type
Nullable
Default
Description
id
uuid
NO
gen_random_uuid()
Primary key
room_id
text
NO
-
FK to rooms
target_user_id
text
NO
-
Affected user
action
text
NO
-
Action type
old_value
jsonb
YES
-
Previous value
new_value
jsonb
YES
-
New value
performed_by
text
NO
-
Admin user ID
created_at
timestamptz
YES
now()
Action time
room_chat_messages
Room chat history.
Column
Type
Nullable
Default
Description
id
uuid
NO
uuid_generate_v4()
Primary key
room_id
varchar
NO
-
Room ID
user_id
uuid
YES
-
FK to user_profiles
content
text
NO
-
Message content
message_type
varchar
YES
'text'
Type (text/reaction/system)
reaction_type
varchar
YES
-
Reaction type if reaction
target_user_id
uuid
YES
-
Target for reactions
created_at
timestamptz
YES
now()
Sent time
is_deleted
bool
YES
false
Soft delete flag
deleted_at
timestamptz
YES
-
Deletion time
deleted_by
uuid
YES
-
Deleter user ID
room_webrtc_sessions
WebRTC session tracking. Stores one row per published Cloudflare Calls track, allowing a user to publish multiple independently pullable tracks in the same room.
Column
Type
Nullable
Default
Description
id
uuid
NO
gen_random_uuid()
Primary key
room_id
text
NO
-
Room ID
user_id
text
NO
-
User ID
session_id
text
NO
-
WebRTC session ID
track_name
text
NO
-
Unique track name within the room
created_at
timestamptz
YES
now()
Created
updated_at
timestamptz
YES
now()
Updated
session_history
Historical jam session records.
Column
Type
Nullable
Default
Description
id
uuid
NO
uuid_generate_v4()
Primary key
user_id
uuid
YES
-
FK to user_profiles
room_id
varchar
NO
-
Room ID
joined_at
timestamptz
NO
now()
Join time
left_at
timestamptz
YES
-
Leave time
duration_seconds
int4
YES
-
Session duration
instrument_id
varchar
YES
-
Instrument used
was_room_master
bool
YES
false
Was room master
participant_ids
uuid[]
YES
'{}'
Other participants
user_saved_rooms
User's saved/bookmarked rooms.
Column
Type
Nullable
Default
Description
id
uuid
NO
gen_random_uuid()
Primary key
user_id
text
NO
-
User ID
room_id
text
NO
-
FK to rooms
notes
text
YES
-
Personal notes
saved_at
timestamptz
YES
now()
Save time
Audio & Tracks
tracks
Uploaded audio tracks.
Column
Type
Nullable
Default
Description
id
text
NO
-
Primary key
room_id
text
YES
-
FK to rooms
name
text
NO
-
Track name
artist
text
YES
-
Artist name
duration
float4
NO
-
Duration in seconds
url
text
NO
-
Storage URL
uploaded_by
text
NO
-
Uploader user ID
uploaded_at
timestamptz
YES
now()
Upload time
ai_generated
bool
YES
false
AI generated flag
stems
jsonb
YES
-
Separated stems data
room_tracks
Tracks associated with rooms.
Column
Type
Nullable
Default
Description
id
uuid
NO
-
Primary key
room_id
text
NO
-
Room ID
name
text
NO
-
Track name
artist
text
YES
-
Artist
duration
int4
YES
0
Duration (ms)
url
text
NO
-
Storage URL
uploaded_by
text
YES
'user'
Uploader
youtube_id
text
YES
-
YouTube video ID
ai_generated
bool
YES
false
AI flag
created_at
timestamptz
YES
now()
Created
user_tracks
User audio tracks in rooms.
Column
Type
Nullable
Default
Description
id
text
NO
-
Primary key
room_id
text
NO
-
FK to rooms
user_id
text
NO
-
User ID
name
text
NO
-
Track name
color
text
NO
'#a78bfa'
Track color
audio_settings
jsonb
NO
'{}'
Audio settings
is_muted
bool
NO
false
Muted state
is_solo
bool
NO
false
Solo state
volume
float4
NO
1.0
Volume level
is_armed
bool
NO
true
Record armed
is_recording
bool
NO
false
Recording state
owner_user_id
text
YES
-
Owner user ID
owner_user_name
text
YES
-
Owner name
is_active
bool
NO
true
Active state
track_type
text
YES
'audio'
Track type
midi_settings
jsonb
YES
-
MIDI settings
created_at
timestamptz
NO
now()
Created
updated_at
timestamptz
NO
now()
Updated
room_loop_tracks
MIDI loop tracks in rooms.
Column
Type
Nullable
Default
Description
id
uuid
NO
gen_random_uuid()
Primary key
room_id
text
NO
-
FK to rooms
created_by
text
YES
-
Creator user ID
created_by_name
text
YES
-
Creator name
loop_id
text
NO
-
Loop identifier
custom_midi_data
jsonb
YES
-
Custom MIDI data
is_playing
bool
YES
false
Playing state
start_time
timestamptz
YES
-
Start time
loop_start_beat
float4
YES
0
Start beat
sound_preset
text
NO
'drums/acoustic-kit'
Sound preset
sound_settings
jsonb
YES
'{}'
Sound settings
tempo_locked
bool
YES
false
Tempo lock
target_bpm
float4
YES
-
Target BPM
key_locked
bool
YES
false
Key lock
target_key
text
YES
-
Target key
transpose_amount
int4
YES
0
Transpose semitones
volume
float4
YES
0.8
Volume
pan
float4
YES
0.0
Pan position
muted
bool
YES
false
Muted
solo
bool
YES
false
Solo
effects
jsonb
YES
(default chain)
Effects settings
humanize_enabled
bool
YES
false
Humanize
humanize_timing
float4
YES
0.05
Timing variance
humanize_velocity
float4
YES
0.1
Velocity variance
color
text
YES
'#6366f1'
Track color
name
text
YES
-
Track name
position
int4
YES
0
Position
created_at
timestamptz
YES
now()
Created
updated_at
timestamptz
YES
now()
Updated
songs
Song arrangements in rooms.
Column
Type
Nullable
Default
Description
id
uuid
NO
gen_random_uuid()
Primary key
room_id
text
NO
-
FK to rooms
name
text
NO
-
Song name
tracks
jsonb
NO
'[]'
Track data
bpm
int4
NO
120
Tempo
key
text
YES
-
Musical key
time_signature
int4[]
NO
'{4,4}'
Time signature
duration
float4
NO
0
Duration
color
text
NO
'#6366f1'
Color
position
int4
NO
0
Position
created_by
uuid
YES
-
Creator
created_by_name
text
YES
-
Creator name
created_at
timestamptz
NO
now()
Created
updated_at
timestamptz
NO
now()
Updated
saved_track_presets
User-saved track presets.
Column
Type
Nullable
Default
Description
id
text
NO
-
Primary key
user_id
text
NO
-
User ID
name
text
NO
-
Preset name
description
text
YES
-
Description
track_type
text
NO
'audio'
Track type
instrument_id
text
NO
'other'
Instrument
color
text
NO
'#a78bfa'
Color
volume
float4
NO
1.0
Volume
is_muted
bool
NO
false
Muted
is_solo
bool
NO
false
Solo
audio_settings
jsonb
YES
-
Audio settings
midi_settings
jsonb
YES
-
MIDI settings
effects
jsonb
NO
'{}'
Effects
active_effect_preset
text
YES
-
Active preset
is_default
bool
NO
false
Default flag
use_count
int4
NO
0
Usage count
created_at
timestamptz
NO
now()
Created
updated_at
timestamptz
NO
now()
Updated
lyria_usage
AI music generation usage tracking.
Column
Type
Nullable
Default
Description
id
uuid
NO
gen_random_uuid()
Primary key
user_id
uuid
NO
-
User ID
session_id
text
NO
-
Generation session
session_start
timestamptz
NO
now()
Start time
session_end
timestamptz
YES
-
End time
duration_seconds
int4
YES
0
Duration
prompt_text
text
YES
-
Generation prompt
style
text
YES
-
Music style
mood
text
YES
-
Mood setting
bpm
int4
YES
-
BPM setting
scale
text
YES
-
Musical scale
bytes_streamed
int8
YES
0
Data streamed
created_at
timestamptz
NO
now()
Created
lyria_rate_limits
AI generation rate limiting.
Column
Type
Nullable
Default
Description
user_id
uuid
NO
-
Primary key
request_count
int4
YES
0
Requests in window
window_start
timestamptz
YES
now()
Window start
daily_seconds_used
int4
YES
0
Seconds used today
daily_reset_at
timestamptz
YES
(tomorrow)
Daily reset time
updated_at
timestamptz
YES
now()
Updated
Avatar System
avatar_categories
Avatar component categories.
Column
Type
Nullable
Default
Description
id
text
NO
-
Primary key
display_name
text
NO
-
Display name
layer_order
int4
NO
-
Render order
is_required
bool
YES
false
Required category
max_selections
int4
YES
1
Max selections
supports_color_variants
bool
YES
false
Color support
default_color_palette
text
YES
-
FK to palettes
is_active
bool
YES
true
Active status
render_x
int4
NO
0
Render X position
render_y
int4
NO
0
Render Y position
render_width
int4
NO
512
Render width
render_height
int4
NO
512
Render height
prompt_addition
text
YES
-
AI prompt addition
created_at
timestamptz
YES
now()
Created
updated_at
timestamptz
YES
now()
Updated
avatar_components
Individual avatar components.
Column
Type
Nullable
Default
Description
id
text
NO
-
Primary key
category_id
text
NO
-
FK to categories
name
text
NO
-
Component name
image_url
text
NO
-
Image URL
thumbnail_url
text
YES
-
Thumbnail URL
r2_key
text
NO
-
R2 storage key
tags
text[]
YES
'{}'
Tags
rarity
text
YES
'common'
Rarity tier
color_variants
jsonb
YES
'{}'
Color variants
base_color
text
YES
-
Base color
generation_prompt
text
YES
-
AI prompt
generation_model
text
YES
-
AI model used
generation_params
jsonb
YES
-
AI params
is_active
bool
YES
true
Active
created_by
uuid
YES
-
Creator
created_at
timestamptz
YES
now()
Created
updated_at
timestamptz
YES
now()
Updated
avatar_color_palettes
Color palette definitions.
Column
Type
Nullable
Default
Description
id
text
NO
-
Primary key
display_name
text
NO
-
Display name
colors
jsonb
NO
'[]'
Color array
created_at
timestamptz
YES
now()
Created
avatar_unlock_rules
Rules for unlocking components.
Column
Type
Nullable
Default
Description
id
text
NO
-
Primary key
display_name
text
NO
-
Display name
description
text
YES
-
Description
unlock_type
text
NO
-
Unlock type
level_required
int4
YES
-
Level requirement
achievement_id
text
YES
-
Achievement required
statistic_key
text
YES
-
Stat key
statistic_operator
text
YES
-
Comparison operator
statistic_value
numeric
YES
-
Required value
is_active
bool
YES
true
Active
created_at
timestamptz
YES
now()
Created
updated_at
timestamptz
YES
now()
Updated
avatar_component_unlocks
Component-to-unlock-rule mappings.
Column
Type
Nullable
Default
Description
component_id
text
NO
-
PK, FK to components
unlock_rule_id
text
NO
-
PK, FK to rules
avatar_generation_presets
AI avatar generation presets.
Column
Type
Nullable
Default
Description
id
text
NO
-
Primary key
name
text
NO
-
Preset name
prompt_template
text
NO
-
Prompt template
negative_prompt
text
YES
-
Negative prompt
style_suffix
text
YES
-
Style suffix
model
text
YES
'flux-schnell'
AI model
params
jsonb
YES
'{}'
Parameters
is_active
bool
YES
true
Active
created_at
timestamptz
YES
now()
Created
user_avatar_canvas
User avatar compositions.
Column
Type
Nullable
Default
Description
id
uuid
NO
gen_random_uuid()
Primary key
user_id
uuid
NO
-
FK to user_profiles
canvas_data
jsonb
NO
(default)
Canvas layers
full_body_url
text
YES
-
Full body render
headshot_url
text
YES
-
Headshot render
thumbnail_urls
jsonb
YES
-
Thumbnails
created_at
timestamptz
YES
now()
Created
updated_at
timestamptz
YES
now()
Updated
user_unlocked_components
User's unlocked avatar components.
Column
Type
Nullable
Default
Description
user_id
uuid
NO
-
PK, FK to user_profiles
component_id
text
NO
-
PK, FK to components
unlocked_at
timestamptz
YES
now()
Unlock time
unlocked_reason
text
YES
-
Unlock reason
homepage_characters
Homepage display characters.
Column
Type
Nullable
Default
Description
id
uuid
NO
gen_random_uuid()
Primary key
name
varchar
NO
-
Character name
description
text
YES
-
Description
canvas_data
jsonb
NO
(default)
Avatar data
full_body_url
text
YES
-
Full render
thumbnail_url
text
YES
-
Thumbnail
personality
varchar
YES
-
Personality type
preferred_scenes
text[]
YES
-
Scene preferences
walk_speed
numeric
YES
1.0
Animation speed
idle_animation
varchar
YES
'bounce'
Idle animation
is_active
bool
YES
true
Active
sort_order
int4
YES
0
Display order
created_by
uuid
YES
-
Creator
created_at
timestamptz
YES
now()
Created
updated_at
timestamptz
YES
now()
Updated
Gamification
achievements
Achievement definitions.
Column
Type
Nullable
Default
Description
id
varchar
NO
-
Primary key
name
varchar
NO
-
Achievement name
description
text
NO
-
Description
category
varchar
NO
-
Category
icon
varchar
YES
'trophy'
Icon name
xp_reward
int4
YES
50
XP reward
criteria
jsonb
NO
-
Unlock criteria
is_hidden
bool
YES
false
Hidden achievement
sort_order
int4
YES
0
Display order
created_at
timestamptz
YES
now()
Created
user_achievements
User's earned achievements.
Column
Type
Nullable
Default
Description
id
uuid
NO
uuid_generate_v4()
Primary key
user_id
uuid
YES
-
FK to user_profiles
achievement_id
varchar
YES
-
FK to achievements
unlocked_at
timestamptz
YES
now()
Unlock time
challenges
Time-limited challenges.
Column
Type
Nullable
Default
Description
id
uuid
NO
uuid_generate_v4()
Primary key
type
varchar
NO
-
Challenge type
name
varchar
NO
-
Challenge name
description
text
NO
-
Description
criteria
jsonb
NO
-
Completion criteria
xp_reward
int4
YES
100
XP reward
active_from
date
NO
-
Start date
active_until
date
NO
-
End date
Social Features
follows
Follow relationships.
Column
Type
Nullable
Default
Description
follower_id
uuid
NO
-
PK, FK to user_profiles
following_id
uuid
NO
-
PK, FK to user_profiles
created_at
timestamptz
YES
now()
Follow time
friendships
Friend relationships.
Column
Type
Nullable
Default
Description
id
uuid
NO
uuid_generate_v4()
Primary key
user_id
uuid
YES
-
FK to user_profiles
friend_id
uuid
YES
-
FK to user_profiles
status
varchar
YES
'pending'
Request status
requested_at
timestamptz
YES
now()
Request time
accepted_at
timestamptz
YES
-
Acceptance time
jams_together
int4
YES
0
Shared sessions
total_time_together_seconds
int8
YES
0
Time together
notifications
User notifications.
Column
Type
Nullable
Default
Description
id
uuid
NO
uuid_generate_v4()
Primary key
user_id
uuid
YES
-
FK to user_profiles
type
varchar
NO
-
Notification type
title
varchar
NO
-
Title
message
text
YES
-
Message body
link_type
varchar
YES
-
Link type
link_id
uuid
YES
-
Related entity
is_read
bool
YES
false
Read status
read_at
timestamptz
YES
-
Read time
created_at
timestamptz
YES
now()
Created
activity_feed
Social activity feed.
Column
Type
Nullable
Default
Description
id
uuid
NO
gen_random_uuid()
Primary key
user_id
uuid
NO
-
FK to user_profiles
type
text
NO
-
Activity type
data
jsonb
YES
'{}'
Activity data
created_at
timestamptz
YES
now()
Created
System Configuration
system_loops
System MIDI loop library.
Column
Type
Nullable
Default
Description
id
text
NO
-
Primary key
name
text
NO
-
Loop name
category
text
NO
-
Category
subcategory
text
YES
-
Subcategory
bpm
int4
NO
120
BPM
bars
int4
NO
1
Bar count
time_signature_numerator
int4
NO
4
Time sig numerator
time_signature_denominator
int4
NO
4
Time sig denominator
key
text
YES
-
Musical key
midi_data
jsonb
NO
'[]'
MIDI note data
sound_preset
text
NO
-
Sound preset
tags
text[]
YES
'{}'
Tags
intensity
int4
NO
3
Intensity (1-5)
complexity
int4
NO
2
Complexity (1-5)
is_active
bool
YES
true
Active
created_by
uuid
YES
-
Creator
created_at
timestamptz
YES
now()
Created
updated_at
timestamptz
YES
now()
Updated
system_loop_categories
Loop category definitions.
Column
Type
Nullable
Default
Description
id
text
NO
-
Primary key
name
text
NO
-
Category name
icon
text
NO
-
Icon
sort_order
int4
YES
0
Display order
created_at
timestamptz
YES
now()
Created
updated_at
timestamptz
YES
now()
Updated
system_loop_subcategories
Loop subcategory definitions.
Column
Type
Nullable
Default
Description
id
text
NO
-
Primary key
category_id
text
NO
-
FK to categories
name
text
NO
-
Subcategory name
sort_order
int4
YES
0
Display order
created_at
timestamptz
YES
now()
Created
updated_at
timestamptz
YES
now()
Updated
user_custom_loops
User-created loops.
Column
Type
Nullable
Default
Description
id
text
NO
-
Primary key
user_id
text
NO
-
User ID
name
text
NO
-
Loop name
category
text
NO
-
Category
subcategory
text
YES
'custom'
Subcategory
bpm
int4
NO
120
BPM
bars
int4
NO
2
Bars
time_signature
jsonb
NO
'[4, 4]'
Time signature
key
text
YES
-
Key
midi_data
jsonb
NO
'[]'
MIDI data
sound_preset
text
NO
-
Sound preset
tags
jsonb
NO
'["custom"]'
Tags
intensity
int4
NO
3
Intensity
complexity
int4
NO
2
Complexity
description
text
YES
-
Description
is_favorite
bool
YES
false
Favorite flag
is_promoted
bool
YES
false
Promoted to system
promoted_at
timestamptz
YES
-
Promotion time
promoted_by
uuid
YES
-
Promoter
created_at
timestamptz
YES
now()
Created
updated_at
timestamptz
YES
now()
Updated
system_instruments
Instrument definitions.
Column
Type
Nullable
Default
Description
id
text
NO
-
Primary key
name
text
NO
-
Instrument name
category
text
NO
-
Category
type
text
NO
-
Type
icon
text
NO
'🎹'
Icon
description
text
YES
-
Description
tags
text[]
YES
'{}'
Tags
layout
text
YES
'piano'
Keyboard layout
note_range_min
int4
YES
36
Min MIDI note
note_range_max
int4
YES
84
Max MIDI note
synth_config
jsonb
YES
-
Synth config
drum_map
jsonb
YES
-
Drum mapping
is_active
bool
YES
true
Active
created_by
uuid
YES
-
Creator
created_at
timestamptz
YES
now()
Created
updated_at
timestamptz
YES
now()
Updated
system_instrument_categories
Instrument category definitions.
Column
Type
Nullable
Default
Description
id
text
NO
-
Primary key
name
text
NO
-
Category name
icon
text
NO
-
Icon
sort_order
int4
YES
0
Display order
created_at
timestamptz
YES
now()
Created
updated_at
timestamptz
YES
now()
Updated
system_instant_band_presets
Quick-start band presets.
Column
Type
Nullable
Default
Description
id
text
NO
-
Primary key
name
text
NO
-
Preset name
description
text
YES
-
Description
loop_ids
text[]
NO
'{}'
Loop IDs
bpm_range_min
int4
YES
80
Min BPM
bpm_range_max
int4
YES
140
Max BPM
genre
text
YES
-
Genre
is_active
bool
YES
true
Active
sort_order
int4
YES
0
Display order
created_at
timestamptz
YES
now()
Created
updated_at
timestamptz
YES
now()
Updated
Admin & Moderation
reports
User reports.
Column
Type
Nullable
Default
Description
id
uuid
NO
uuid_generate_v4()
Primary key
reporter_id
uuid
YES
-
FK to user_profiles
target_type
varchar
NO
-
Target type
target_id
uuid
NO
-
Target entity ID
reason
varchar
NO
-
Report reason
description
text
YES
-
Details
evidence_urls
text[]
YES
'{}'
Evidence URLs
status
varchar
YES
'pending'
Review status
reviewed_by
uuid
YES
-
Reviewer
reviewed_at
timestamptz
YES
-
Review time
resolution
text
YES
-
Resolution notes
action_taken
varchar
YES
-
Action taken
created_at
timestamptz
YES
now()
Created
admin_audit_log
Admin action audit trail.
Column
Type
Nullable
Default
Description
id
uuid
NO
uuid_generate_v4()
Primary key
admin_id
uuid
YES
-
FK to user_profiles
action
varchar
NO
-
Action type
target_type
varchar
YES
-
Target type
target_id
uuid
YES
-
Target ID
details
jsonb
YES
'{}'
Action details
ip_address
inet
YES
-
IP address
created_at
timestamptz
YES
now()
Action time
Row Level Security (RLS) Policies
All tables have RLS enabled. Policies control access based on authentication state and user roles.
Access Patterns
Pattern
Description
auth.uid()
Current authenticated user's ID
account_type = 'admin'
Admin role check via user_profiles
auth.jwt() ->> 'role' = 'service_role'
Service role (backend) access
is_active = true
Only active records visible
User System Policies
user_profiles
Policy
Command
Rule
Public profiles are viewable by everyone
SELECT
profile_visibility = 'public' OR auth.uid() = id
Users can insert own profile
INSERT
auth.uid() = id
Users can update own profile
UPDATE
auth.uid() = id
user_stats
Policy
Command
Rule
Stats viewable based on profile settings
SELECT
show_stats = true OR auth.uid() = user_id
Users can view all stats
SELECT
true
Users can insert own stats
INSERT
auth.uid() = user_id
Users can update own stats
UPDATE
auth.uid() = user_id
user_instruments
Policy
Command
Rule
Instruments are viewable by everyone
SELECT
true
Users can manage own instruments
ALL
auth.uid() = user_id
user_achievements
Policy
Command
Rule
User achievements viewable by everyone
SELECT
true
Users can insert own achievements
INSERT
auth.uid() = user_id
user_xp_transactions
Policy
Command
Rule
Users can view own xp
SELECT
auth.uid() = user_id
Users can insert own xp
INSERT
auth.uid() = user_id
Social Policies
follows
Policy
Command
Rule
Follows are viewable by everyone
SELECT
true
Users can manage own follows
ALL
auth.uid() = follower_id
friendships
Policy
Command
Rule
Users can view their friendships
SELECT
auth.uid() = user_id OR auth.uid() = friend_id
Users can create friend requests
INSERT
auth.uid() = user_id
Users can update friendships they're part of
UPDATE
auth.uid() = user_id OR auth.uid() = friend_id
Users can delete friendships they're part of
DELETE
auth.uid() = user_id OR auth.uid() = friend_id
activity_feed
Policy
Command
Rule
Users can view own activity
SELECT
auth.uid() = user_id OR user_id IN (accepted friends)
Users can create own activity
INSERT
auth.uid() = user_id
Users can manage own activity
ALL
auth.uid() = user_id
notifications
Policy
Command
Rule
Users can view own notifications
SELECT
auth.uid() = user_id
Users can update own notifications
UPDATE
auth.uid() = user_id
System can insert notifications
INSERT
true
Room Policies
rooms
Policy
Command
Rule
Public read access
SELECT
is_public = true
Allow insert
INSERT
true
saved_rooms
Policy
Command
Rule
Public rooms are viewable by everyone
SELECT
room_type = 'public' OR owner_id = auth.uid()
Users can manage own rooms
ALL
auth.uid() = owner_id
room_invitations
Policy
Command
Rule
Users can view their own invitations
SELECT
invited_user_id = auth.uid() OR invited_email matches