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

add-table

/add-table

Dodaje tabelę bazy danych do projektu TurbineKit w Drizzle: schemat, prefiks ID, migrację i testy na PGlite.

Repozytorium
turbinekit ↗
Licencja
MIT
Ostatnia zmiana repozytorium
04.11.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 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
1
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
0
Przestarzałość

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

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Dodaje tabelę bazy danych do projektu TurbineKit w Drizzle: schemat, prefiks ID, migrację i testy na PGlite.

Oryginalny opis (EN)

Add a database table to a TurbineKit project with Drizzle — the schema, its ID prefix, the migration and tests on PGlite. Use whenever the product needs to store a new kind of data.

Jak działa

  1. Steps
  2. Check
Sekcje z nagłówków SKILL.md, w oryginale · 82 linii, 306 słów
Podgląd SKILL.md
---
name: add-table
description: Add a database table to a TurbineKit project with Drizzle — the schema, its ID prefix, the migration and tests on PGlite. Use whenever the product needs to store a new kind of data.
---

# Add a table

App tables live in `packages/db/src/schema/`. `schema/app.ts` holds the
example `project` table: copy its shape.

## Steps

1. **Prefix.** Pick a 3-letter ID prefix and check no table uses it:

   ```sh
   grep -rn 'createId("' packages/db/src
   ```

   (better-auth's tables take theirs from `ID_PREFIXES` in
   `packages/db/src/id.ts`.)

2. **Schema.** Add the table to `packages/db/src/schema/app.ts`, or to a new
   file in that folder that `schema/index.ts` exports:

   ```ts
   export const note = pgTable(
   	"note",
   	{
   		id: text("id")
   			.primaryKey()
   			.$defaultFn(() => createId("not")),
   		body: text("body").notNull(),
   		ownerId: text("owner_id")
   			.notNull()
   			.references(() => user.id, { onDelete: "cascade" }),
   		createdAt: timestamp("created_at", { withTimezone: true, precision: 3 })
   			.notNull()
   			.defaultNow(),
   		updatedAt: timestamp("updated_at", { withTimezone: true, precision: 3 })
   			.notNull()
   			.defaultNow()
   			.$onUpdate(() => new Date()),
   	},
   	(table) => [index("note_owner_idx").on(table.ownerId)],
   );
   ```

   - Times: always `{ withTimezone: true, precision: 3 }`. Milliseconds
     match JavaScript dates, so list cursors stay exact.
   - Snake_case column names, camelCase properties.
   - Index every column you filter on.
   - If the project has teams (an `organization` table in `schema/auth.ts`),
     copy `organizationId` and its index from `project`, so rows can belong
     to a team.

3. **Migration.** It needs no database:

   ```sh
   pnpm db:generate --name=note    # writes packages/db/drizzle/NNNN_note.sql
   ```

   Read the SQL before you commit it. Never edit a migration that already
   ran somewhere: make a new one. Then, with the database running
   (`pnpm db:local` or `docker compose up -d`):

   ```sh
   pnpm db:migrate
   ```

4. **Services and operations.** Queries on the table go in a service in
   `packages/api/src/services/` (skill `add-operation`), never in pages or
   route handlers.

5. **Tests** go with the service, in `packages/api/src/api.test.ts`
   (`add-operation`, step 8). Test the table alone, in
   `packages/db/src/*.test.ts`, only for database behavior (a constraint, a
   cascade). `createTestDb()` from `@repo/db/testing` gives a fresh PGlite
   database with every migration applied, and `insertUser(db)` a user.

## Check

```sh
pnpm typecheck && pnpm test
pnpm db:generate    # must print "No schema changes"
```

Wersje

W bazie nie ma innych skilli o nazwie add-table.

Migawka bazy z 13.11.2026 · wersja paczki 1c4ac0bd3e87 (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

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

Podobne skille

  • 100add-locale
    Dodaje nowy język do projektu TurbineKit: stronę, e-maile, strony prawne, dokumentację API i baner zgody.
  • 100drizzle-orm
    Pomaga definiować schemat bazy w TypeScripcie, pisać typowane zapytania Postgres, MySQL i SQLite oraz używać drizzle-kit z Neon, Turso, Cloudflare D1, PGlite i node-postgres.
  • 100add-email
    Dodaje e-mail transakcyjny do projektu TurbineKit: szablon React Email z tekstami we wszystkich językach i wysyłkę.
  • 95database-migration
    Tworzy migrację bazy danych ze zmianami schematu i wycofaniem, gdy trzeba dodać tabelę albo zmodyfikować schemat.
  • 100add-migration
    Dodaje lub zmienia migrację schematu Postgres: nową tabelę, kolumnę albo indeks, i uruchamia polecenie migracji w projekcie.
  • 100pglite
    Obsługuje PGlite, czyli Postgres 18 skompilowany do WebAssembly, uruchamiany w przeglądarce, Node.js, Bun lub Deno bez serwera: instalacja, persystencja, pgvector, zapytania na żywo i workery.

Uwagi i zgłoszenia

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