go-gorm-model

Generate GORM model structs from SQL migration tables.

Updated Apr 17, 2026
One-click install
npx skills add https://github.com/Manu343726/audible-exporter --skill go-gorm-model-manu343726
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go-gorm-model
Source: https://github.com/Manu343726/audible-exporter/tree/main/.agents/skills/go-gorm-model
Command: npx skills add https://github.com/Manu343726/audible-exporter --skill go-gorm-model-manu343726

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill removes the guesswork and repetitive typing involved in creating GORM persistence models by ensuring your Go structs match your SQL migrations precisely and follow established conventions.

Core Features & Use Cases

  • Model generation for persistence: Create GORM model structs that map database tables using the required <entity>_model.go naming and model package layout.
  • Correct typing and nullability: Use uint64 primary keys, pointer types for nullable columns, and the exact Go types that correspond to SQL definitions (including time.Time for TIMESTAMPTZ and []byte for JSONB).
  • Migration-aligned constraints: Apply only the necessary GORM tags for primary keys, indexes, unique constraints, defaults, JSONB, and other special cases implied by migrations.

Quick Start

Tell the AI to generate the GORM model for the specified SQL table by mapping every column and nullability rule into internal/modules/<module>/model/<entity>_model.go following the repository’s conventions.

Frequently Asked Questions about go-gorm-model

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I generate GORM models from SQL migrations in Go?

To generate GORM models from SQL migrations, you map database tables into Go structs using specific conventions like the `model` package, `<Entity>Model` struct naming, and `TableName()` implementation to ensure consistent database access.

How do I handle nullable fields and PostgreSQL JSONB in GORM models?

For nullable fields in GORM models, use pointer types in your Go structs. For PostgreSQL JSONB columns, use the `[]byte` Go type, and for `TIMESTAMPTZ` columns, use `time.Time` to match the SQL definitions exactly.

What GORM tags do I need for primary keys, indexes, and unique constraints?

You only need the necessary GORM tags for primary keys, indexes, unique constraints, defaults, and JSONB implied by your migrations, avoiding unnecessary column or json tags for a cleaner persistence model.

How do I map join tables and database defaults using GORM?

GORM model generation maps join tables and applies database defaults by adding only the specific GORM tags required by your SQL migrations, ensuring your Go structs accurately reflect complex database relationships and constraints.

Where should GORM model files be placed in a Go project?

GORM model files should be placed in `internal/modules/<module>/model/<entity>_model.go`, using the `model` package and following strict `<Entity>Model` struct naming conventions to maintain repository consistency.

What is the correct primary key type for GORM persistence models?

The correct primary key type for GORM persistence models is `uint64`, ensuring consistent database access and alignment with your SQL migration table definitions across all generated Go structs.