{"id":24667289,"url":"https://github.com/yanun0323/gem","last_synced_at":"2026-02-17T19:01:19.288Z","repository":{"id":273507819,"uuid":"919951261","full_name":"yanun0323/gem","owner":"yanun0323","description":"Gem is a powerful database migration file generator for Go applications using GORM tags. It simplifies the process of creating database migration files by automatically generating SQL statements based on your Go struct definitions.","archived":false,"fork":false,"pushed_at":"2025-03-19T08:41:43.000Z","size":73,"stargazers_count":0,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-07T05:24:11.823Z","etag":null,"topics":["code-generator","go","gorm","migrations","sql"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yanun0323.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-21T09:56:58.000Z","updated_at":"2025-03-19T08:41:45.000Z","dependencies_parsed_at":"2025-02-26T09:27:41.101Z","dependency_job_id":"39c2f38d-d1ea-42e8-a771-493e09251805","html_url":"https://github.com/yanun0323/gem","commit_stats":null,"previous_names":["yanun0323/gem"],"tags_count":29,"template":false,"template_full_name":null,"purl":"pkg:github/yanun0323/gem","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yanun0323%2Fgem","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yanun0323%2Fgem/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yanun0323%2Fgem/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yanun0323%2Fgem/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yanun0323","download_url":"https://codeload.github.com/yanun0323/gem/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yanun0323%2Fgem/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29554374,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-17T18:16:07.221Z","status":"ssl_error","status_checked_at":"2026-02-17T18:16:04.782Z","response_time":100,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["code-generator","go","gorm","migrations","sql"],"created_at":"2025-01-26T08:16:32.889Z","updated_at":"2026-02-17T19:01:19.272Z","avatar_url":"https://github.com/yanun0323.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Gem\n\nGem is a powerful database migration file generator for Go applications using [GORM](https://gorm.io) tags. It simplifies the process of creating database migration files by automatically generating SQL statements based on your Go struct definitions.\n\n## Features\n\n- Supports multiple migration formats:\n  - Raw SQL\n  - [Goose](https://github.com/pressly/goose)\n  - [Golang-Migrate](https://github.com/golang-migrate/migrate)\n- Automatically generates:\n  - Table creation statements\n  - Column definitions with constraints\n  - Indexes (normal and unique)\n  - Foreign keys\n- Tracks schema changes and generates migration files only when needed\n- Preserves migration history\n- Supports complex data types and relationships\n- Handles embedded structs and custom table names\n- Supports table aliases through type aliasing\n\n## Installation\n\n```bash\ngo get github.com/yanun0323/gem@latest\n```\n\n## Usage\n\n### Basic Example\n\n```go\npackage main\n\nimport (\n    \"log\"\n    \"github.com/yanun0323/gem\"\n)\n\ntype User struct {\n    ID        uint      `gorm:\"primaryKey;autoIncrement\"`\n    Name      string    `gorm:\"size:255;not null\"`\n    Email     string    `gorm:\"unique;size:100\"`\n    CreatedAt time.Time `gorm:\"autoCreateTime\"`\n}\n\nfunc main() {\n    g := gem.New(\u0026gem.Config{\n        Tool:    gem.Goose,        // or gem.GolangMigrate, gem.RawSQL\n        OutputPath: \"./migrations\",\n        KeepDroppedColumn: false,\n    })\n\n    g.AddModels(User{})\n\n    if err := g.Generate(); err != nil {\n        log.Fatal(err)\n    }\n}\n```\n\n### Alias Example\n\n```go\npackage main\n\ntype User struct {\n    ID   uint   `gorm:\"primaryKey;autoIncrement\"`\n    Name string `gorm:\"size:255;not null\"`\n}\n\n// UserAlias is an alias of User but uses a different table name\ntype UserAlias User\n\nfunc (UserAlias) TableName() string {\n    return \"users_alias\"\n}\n\nfunc main() {\n    g := gem.New(\u0026gem.Config{\n        Tool:    gem.Goose,\n        OutputPath: \"./migrations\",\n    })\n\n    // Generate migration files for both User and UserAlias\n    g.AddModels(User{}, UserAlias{})\n\n    if err := g.Generate(); err != nil {\n        log.Fatal(err)\n    }\n}\n```\n\n### Configuration Options\n\n```go\ntype Config struct {\n    Tool              MigrationTool // Goose, GolangMigrate, or RawSQL\n    OutputPath         string       // Directory to store migration files\n    KeepDroppedColumn bool          // Keep dropped columns in down migrations\n}\n```\n\n### Supported GORM Tags\n\n[!IMPORTANT] GORM tags are case sensitive, please refer to [tag.md](tag.md) for the correct usage.\n\n|   Tag Name    | Description                     |\n| :-----------: | :------------------------------ |\n|    column     | Column database name            |\n|     type      | Column data type                |\n|     size      | Column size/length              |\n|  primaryKey   | Specifies column as primary key |\n|    unique     | Specifies column as unique      |\n|     index     | Creates index                   |\n|  uniqueIndex  | Creates unique index            |\n|    default    | Specifies default value         |\n|   not null    | Specifies NOT NULL constraint   |\n| autoIncrement | Enables auto-increment          |\n|   embedded    | Embeds the field                |\n|    comment    | Adds column comment             |\n\nFor a complete list of supported tags, please refer to [tag.md](tag.md).\n\n## Example Project Structure\n\n```\n.\n├── migrations/\n│   ├── 20240101000000_create_users.sql\n│   └── .gem/\n│       └── snapshots.json\n├── models/\n│   └── user.go\n└── main.go\n```\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\nThis project is licensed under the MIT License - see the LICENSE file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyanun0323%2Fgem","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyanun0323%2Fgem","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyanun0323%2Fgem/lists"}