Przejdź do treści
Biblioteka skilli
Dane i analityka · Budowanie i kod

engineering-postgres-game-schema

/engineering-postgres-game-schema

Projektuje schematy baz danych dla gier w PostgreSQL i Drizzle: modele graczy, ekwipunek, tabele wyników i dane gry.

Repozytorium
agent-skills ↗
Licencja
GPL-3.0
Ostatnia zmiana repozytorium
18.10.2026

Ocena i bezpieczeństwo

95/ 100Klasa: dobry
Format20 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
5
Skrypty
4
Komentarze HTML
0
Adresy URL w SKILL.md
3
Przestarzałość

Brak sygnałów. Repozytorium zmienione 18.10.2026, bez odwołań do wycofanych modeli i API.

Licencja

GPL-3.0, otwarta.

Co sprawdzić przed instalacją
  • 4 skrypty w paczce. Przejrzyj je przed instalacją, bo Claude może je uruchomić.

Skrypty: boilerplate/migrations.ts, boilerplate/schema.ts, templates/entity-template.ts, templates/query-patterns.ts

Co robi i kiedy

Projektuje schematy baz danych dla gier w PostgreSQL i Drizzle: modele graczy, ekwipunek, tabele wyników i dane gry.

Oryginalny opis (EN)

Use when designing game database schemas, player data models, inventory systems, or working with Drizzle ORM and PostgreSQL for games. Triggers: database, schema, Drizzle, players, inventory, leaderboards, game data.

Jak działa

  1. Purpose
  2. When to Use
  3. Prerequisites
  4. Core Principles
  5. Step-by-Step Instructions
  6. Code Examples
  7. Cross-References
  8. Pitfalls & Anti-Patterns
  9. Designer Philosophy
  10. Sources
Sekcje z nagłówków SKILL.md, w oryginale · 124 linii, 556 słów
Podgląd SKILL.md
---
name: engineering-postgres-game-schema
description: >-
  Use when designing game database schemas, player data models, inventory systems, or working with Drizzle ORM and PostgreSQL for games. Triggers: database, schema, Drizzle, players, inventory, leaderboards, game data.
---

# PostgreSQL Game Schema

## Purpose

Genre-agnostic database schema design for games using Drizzle ORM + PostgreSQL.

## When to Use

Trigger: database schema, game database, Drizzle schema, players table, inventory, leaderboards, sessions, events, entity system, game data model

## Prerequisites

None — this is a foundational skill.

## Core Principles

> Sid Meier: "A game is a series of interesting decisions."
> Richard Garfield: "The best game systems are elegant rule systems — minimal components that compose into complex behaviors."

1. **Schema must be game-type agnostic** — never assume RPG, MMO, or idle
2. **Use JSONB for extensible data** (stats, properties, metadata)
3. **Timestamps everywhere** (createdAt, updatedAt) for audit trails
4. **Soft deletes over hard deletes** for game data
5. **Enum types for fixed categories** (rarity, status, role)
6. **Composite indexes** for common query patterns
7. **Foreign keys with cascading deletes** where appropriate
8. **Versioned schema migrations** with drizzle-kit

## Step-by-Step Instructions

### 1. Install Dependencies

```bash
bun add drizzle-orm @neondatabase/serverless
bun add -d drizzle-kit
```

### 2. Configure Drizzle

Create `drizzle.config.ts` at the project root. See `boilerplate/migrations.ts` for the full config pattern.

### 3. Define Schemas

Start with the core tables in `boilerplate/schema.ts`. These cover players, sessions, inventory, items, events, leaderboards, achievements, currencies, social relations, guilds, and guild members.

Extend with custom entities using `templates/entity-template.ts`.

### 4. Generate Migrations

```bash
bunx drizzle-kit generate
```

### 5. Run Migrations

```bash
bunx drizzle-kit migrate
```

### 6. Query Data

See `templates/query-patterns.ts` for common query patterns including inventory lookups, leaderboard queries, event aggregation, and JSONB filtering.

## Code Examples

### Player with JSONB stats

```typescript
import { players } from './schema';

await db.insert(players).values({
  username: 'player1',
  email: 'player1@example.com',
  displayName: 'Player One',
  stats: { health: 100, speed: 10 },
  metadata: { tutorial_completed: true },
});
```

### Flexible item definitions

```typescript
await db.insert(itemDefinitions).values({
  name: 'Rare Artifact',
  type: 'equipment',
  rarity: 'rare',
  baseStats: { power: 25, durability: 100 },
  metadata: { description: 'A mysterious artifact', tradeable: true },
  stackable: false,
});
```

See `boilerplate/schema.ts` for full table definitions and `templates/query-patterns.ts` for advanced queries.

## Cross-References

- `bullmq-game-queues` for async event processing
- `redis-game-patterns` for cached queries
- `betterauth-integration` for auth tables
- `game-economy-design` for economy schemas

## Pitfalls & Anti-Patterns

- **Don't store game state as a single JSON blob** — use normalized tables with JSONB for extensible fields only
- **Don't use auto-increment IDs for player-facing identifiers** — use UUIDs or nanoid to prevent enumeration
- **Don't skip indexes on frequently queried columns** — especially playerId, category, type, and createdAt
- **Don't hardcode genre-specific columns in core tables** — use JSONB metadata instead of adding `swordDamage` or `spellPower` columns
- **Don't use hard deletes** — always soft delete with `deletedAt` timestamps so game history is preserved
- **Don't forget composite indexes** — queries like "player's inventory filtered by type" need `(playerId, type)` indexes

## Designer Philosophy

**Sid Meier:** Schema should enable "interesting decisions" — flexible enough that any game mechanic can be modeled without schema changes. A well-designed JSONB column lets designers iterate on game mechanics without migrations.

**Richard Garfield:** Elegant schemas have minimal tables that compose into complex behaviors. Eleven core tables can model inventory, progression, social, economy, and analytics for any genre.

## Sources

- [Drizzle ORM Documentation](https://orm.drizzle.team)
- [PostgreSQL JSONB Best Practices](https://www.postgresql.org/docs/current/datatype-json.html)
- Game Database Design Patterns (GDC talks on scalable game backends)
- [Neon Serverless PostgreSQL](https://neon.tech/docs)
Pliki w paczce (5)
  • SKILL.md 4 KB
  • boilerplate/migrations.ts 2 KB
  • boilerplate/schema.ts 11 KB
  • templates/entity-template.ts 5 KB
  • templates/query-patterns.ts 7 KB

Wersje

W bazie nie ma innych skilli o nazwie engineering-postgres-game-schema.

Identyczna treść występuje jeszcze w 1 innych folderach na GitHubie. Tu pokazujemy jedną, najlepiej ocenioną kopię.

Migawka bazy z 28.10.2026 · wersja paczki 482d8418054d (skrót SHA-256 całej paczki)

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 90postgres-drizzle
    Pisze i przegląda schematy PostgreSQL, zapytania, migracje i kod Drizzle ORM, dbając o relacje, indeksy i wydajność połączeń.
  • 85Drizzle ORM
    Prowadzi przez Drizzle ORM: schematy, zapytania, relacje, migracje, integrację z TypeScript dla SQLite i PostgreSQL oraz Drizzle Studio.
  • 100drizzle-orm
    Stosuje wzorce Drizzle ORM dla schematów, migracji, zapytań, typów brandowanych i granic między Postgres a D1.
  • 100drizzle
    Pomaga w pracy z Drizzle ORM: typowane schematy, migracje, relacje i klienty baz serverless w aplikacjach TypeScript z PostgreSQL, MySQL lub SQLite.
  • 90database-design
    Pomaga projektować schematy, przeglądać modele danych i planować migracje w PostgreSQL, MySQL, MongoDB, Prisma i Drizzle.
  • 100drizzle
    Pomaga pisać i zmieniać schematy, zapytania i migracje Drizzle ORM w pakiecie @internal/dashboard-agent-db: schemat pg-core, sterownik postgres-js, drizzle-kit oraz konwencje repozytorium.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.