Skip to content
Skills Library
Programming · Building & coding

grb-postgres-migrations

/grb-postgres-migrations

Use when changing the database schema, the seed, a gorm store or a migration in the Go React boilerplate. Covers embedded golang-migrate files, gorm boundaries, UUID keys, seed idempotency and the relevant commands.

Licence
MIT
Last repository change
13.11.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 13.11.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Use when changing the database schema, the seed, a gorm store or a migration in the Go React boilerplate. Covers embedded golang-migrate files, gorm boundaries, UUID keys, seed idempotency and the relevant commands.

Original author description

Use when changing the database schema, the seed, a gorm store or a migration in the Go React boilerplate. Covers embedded golang-migrate files, gorm boundaries, UUID keys, seed idempotency and the relevant commands.

How it works

  1. Schema changes
  2. Rules
  3. Seed
  4. Commands
  5. Testing a schema change
  6. Useful checks
Original SKILL.md headings · 67 lines, 277 words
SKILL.md preview
---
name: grb-postgres-migrations
description: Use when changing the database schema, the seed, a gorm store or a migration in the Go React boilerplate. Covers embedded golang-migrate files, gorm boundaries, UUID keys, seed idempotency and the relevant commands.
---

# PostgreSQL, gorm and migrations

PostgreSQL is the only database. The adapter is
`internal/adapter/postgres`. gorm rows never leave that package.

## Schema changes

1. Add a new pair of files in
   `internal/adapter/postgres/migrations/`:
   - `000002_short_name.up.sql`
   - `000002_short_name.down.sql`
2. Never edit an applied migration.
3. Use snake_case table and column names.
4. Use `uuid` primary keys generated in Go with `entity.NewUUID()`.
5. Add indexes for foreign keys and common filters.
6. Use `timestamptz` and defaults.
7. Update the gorm row struct in `models.go`.
8. Update the store methods.
9. Run `make db-migrate` or `make db-reset`.

## Rules

- gorm stays inside `internal/adapter/postgres`, `internal/xmodule` and `cmd`.
- Store rows convert to entities at the boundary.
- Use `port.ErrUniqueViolation` for duplicate-key failures.
- Use transactions for multi-row writes.
- Use `context.Context` on every query.
- Never scan directly into an HTTP DTO.

## Seed

- `internal/adapter/postgres/seed.go` is idempotent.
- Permissions and roles are upserted.
- Demo users are inserted only when absent.
- Demo password is `password`.
- The seeded state is 14 users and 3 roles.
- Run `make db-seed` after a role or permission change.

## Commands

```bash
make db-up        # Postgres and Mailpit
make db-migrate   # apply migrations
make db-seed      # permissions, roles, demo users
make db-reset     # destructive rebuild
```

The server also applies migrations at boot. `cmd/migrate` exists for release
pipelines.

## Testing a schema change

1. Run `make db-reset`.
2. Sign in as `superadmin@example.com`.
3. Exercise the affected screen.
4. Run `make test` and the relevant Playwright spec.
5. Confirm the seed still produces the documented counts.

## Useful checks

```sql
SELECT count(*) FROM users;
SELECT count(*) FROM roles;
SELECT key, value FROM settings;
```

Versions

The database has no other skills named grb-postgres-migrations.

Database snapshot: 13.11.2026 · package version 7430ad080b7e (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100go-data-persistence
    Data persistence patterns in Go covering raw SQL with sqlx/pgx, ORMs like Ent and GORM, connection pooling, migrations with golang-migrate, and transaction management. Use when implementing database access, designing repositories, or managing schema migrations.
  • 100grb-architecture
    Use when adding or changing a feature in the Go React boilerplate, deciding where code belongs, or reviewing the hexagonal layer boundaries. Covers entity, port, use case, adapter, HTTP handler, React route and test placement.
  • 100grb-testing
    Use when adding or running tests for the Go React boilerplate. Covers Go unit tests, Vitest, Playwright, the demo accounts, rate limits, cleanup rules and the Docker test stack.
  • 90dev-writing-migrations
    Use when a change touches a live Postgres/MySQL schema: migration-plan.md at G3, migration files at G7, expand → migrate → contract, real rollback.
  • 100migration-helper
    Write safe database schema and data migrations with rollback steps, lock and timeout checks, and an expand-and-contract plan for zero-downtime deploys. Use when the user asks to add, rename or drop a column or table, add an index or constraint, backfill data, or review a…
  • 95postgres-best-practices
    Best practices and guidelines for working with Postgres. Covers schema design, indexing strategies, query optimization, migrations, and common pitfalls. Use when writing SQL, designing database schemas, optimizing queries, or setting up a Postgres database.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.