AgentSkillsCN

stackey-database

当用户提及“Stackey数据库”“区块表”“用户表”“收藏表”“区块媒体表”“Stackey架构”“RLS策略”,或在为StackeyBackend进行数据库迁移或编写查询时,可使用此技能。

SKILL.md
--- frontmatter
name: stackey-database
description: Use this skill when users mention "Stackey database", "blocks table", "users table", "favorites table", "block_media table", "Stackey schema", "RLS policies", or when working on database migrations or queries for StackeyBackend.
version: 1.0.0
context: fork

Stackey Database Schema

PostgreSQL database schema for the StackeyBackend Supabase project.

Tables Overview

TablePurposeKey Relationships
usersUser profilesExtends auth.users
blocksVideo generation presetsHas many block_media
block_mediaImages/videos for blocksBelongs to blocks
favoritesUser-block favoritesMany-to-many junction

Entity Relationship

code
auth.users (Supabase)
    │
    ▼
  users ──────────────────┐
    │                     │
    │                     │
    ▼                     ▼
 blocks ◀──────────── favorites
    │
    ▼
block_media

Quick Reference

Users Table

sql
-- Columns: id, email, display_name, avatar_url, role, created_at, updated_at
-- role: 'user' | 'admin'

SELECT * FROM users WHERE id = 'user-uuid';

Blocks Table

sql
-- Columns: id, title, description, tags, is_public, created_by, created_at, updated_at
-- tags: text[] with GIN index

SELECT * FROM blocks WHERE 'camera' = ANY(tags);
SELECT * FROM blocks WHERE is_public = true;

Block Media Table

sql
-- Columns: id, block_id, type, url, filename, mime_type, size_bytes, sort_order, created_at
-- type: 'image' | 'video'

SELECT * FROM block_media WHERE block_id = 'block-uuid' ORDER BY sort_order;

Favorites Table

sql
-- Columns: user_id, block_id, created_at
-- Primary key: (user_id, block_id)

SELECT b.* FROM favorites f
JOIN blocks b ON b.id = f.block_id
WHERE f.user_id = 'user-uuid';

Storage

Bucket block-media stores uploaded files:

  • Path pattern: {block_id}/{uuid}.{ext}
  • Public read access enabled

Additional Resources

For complete table definitions, constraints, and RLS policies, see references/schema.md.