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

postgres-safe-migration

/postgres-safe-migration

Pisze bezpieczne migracje PostgreSQL dla tabel z danymi, zmian kolumn, indeksów i ograniczeń.

Repozytorium
claude-packs ↗
Licencja
MIT
Ostatnia zmiana repozytorium
11.11.2026

Ocena i bezpieczeństwo

96/ 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ść31 / 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 11.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

Pisze bezpieczne migracje PostgreSQL dla tabel z danymi, zmian kolumn, indeksów i ograniczeń.

Oryginalny opis (EN)

Use when writing a migration for a table that holds data, when changing a column, adding a required column, an index or a constraint, or when a pg- check refuses a migration.

Jak działa

SKILL.md bez nagłówków drugiego poziomu · 42 linii, 388 słów

Podgląd SKILL.md
---
name: postgres-safe-migration
description: Use when writing a migration for a table that holds data, when changing a column, adding a required column, an index or a constraint, or when a pg- check refuses a migration.
---

# Change a live Postgres table (one job: the change lands, and no query waits for it)

<constraints>
Always do:
1. Find out how big the table is and how busy, or ask. A new or empty table needs none of this.
2. Find out how the migration tool leaves a transaction, before writing `CONCURRENTLY`. Each has its own way:
   | Tool | How |
   |---|---|
   | Rails | `disable_ddl_transaction!` |
   | Django | `atomic = False` |
   | Diesel | `run_in_transaction = false` in `metadata.toml` |
   | goose | `-- +goose NO TRANSACTION` |
   | dbmate | `-- migrate:up transaction:false` |
   | sqlx | `-- no-transaction` on the first line |
   | Alembic | `autocommit_block()` |
   | Knex | `exports.config = { transaction: false }` |
   | node-pg-migrate | `pgm.noTransaction()` |

   Drizzle runs every pending migration in one transaction: take the index out of its migrations and run it apart.
3. Add a required column:
   ```sql
   ALTER TABLE t ADD COLUMN owner_id bigint;              -- 1. nullable, instant
   -- 2. the code writes it, and a backfill runs in batches
   ALTER TABLE t ADD CONSTRAINT t_owner CHECK (owner_id IS NOT NULL) NOT VALID;
   ALTER TABLE t VALIDATE CONSTRAINT t_owner;             -- 3. a later transaction, no write lock
   ALTER TABLE t ALTER COLUMN owner_id SET NOT NULL;      -- 4. the valid check skips the scan
   ALTER TABLE t DROP CONSTRAINT t_owner;
   ```
4. Add a foreign key: `ADD CONSTRAINT ... NOT VALID`, then `VALIDATE CONSTRAINT` in a later transaction. In one transaction it gains nothing.
5. Add a unique constraint: `CREATE UNIQUE INDEX CONCURRENTLY`, then `ADD CONSTRAINT ... UNIQUE USING INDEX`.
6. Change a type: check first whether it rewrites. `varchar` to `text` does not. Most others do: add a new column, write both, backfill, switch reads, drop the old one.
7. A failed `CONCURRENTLY` leaves an invalid index: drop it, then build it again.
8. Set a short `lock_timeout` on a statement that takes a strong lock, and retry it.
9. Deploy the code that can read both shapes first, and drop what is old only after nothing reads it.

Never do:
- Backfill a large table in one `UPDATE`.
- Rename a column in one step while old code still runs.
- Refuse `now()` or a constant default as unsafe: since PostgreSQL 11 both are instant.
</constraints>

Wersje

W bazie nie ma innych skilli o nazwie postgres-safe-migration.

Migawka bazy z 13.11.2026 · wersja paczki 52653d08894a (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

  • 95db-migration
    Pilnuje zasad zmian schematu bazy: tabel, kolumn, indeksów, ograniczeń, enumów, triggerów, uzupełnień danych i plików migracji.
  • 87postgres-migration
    Zmienia schemat Postgresa bez psucia poprzedniego wydania: wzorzec expand i contract dla kolumn, tabel, typów i indeksów.
  • 100postgres-safe-migrations
    Sprawdza migracje schematu dla żywej aplikacji: dodawanie kolumn i indeksów, zmiany ograniczeń bez blokowania tabel i zerwania działającego kodu.
  • 100alembic-safe-migrations
    Pisze i sprawdza migracje Alembic, które nie zablokują produkcyjnej bazy PostgreSQL, przy dodawaniu indeksów, kolumn NOT NULL, zmianie typów i backfillu.
  • 100migration-helper
    Pisze bezpieczne migracje schematu i danych z planem wycofania i sprawdzeniem blokad dla Postgres i MySQL.
  • 100add-migration
    Dodaje lub zmienia migrację schematu Postgres: nową tabelę, kolumnę albo indeks, i uruchamia polecenie migracji w projekcie.

Uwagi i zgłoszenia

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