{"id":20566246,"url":"https://github.com/telkomdev/go-dbcodegen","last_synced_at":"2025-04-14T15:41:00.214Z","repository":{"id":41526605,"uuid":"501991653","full_name":"telkomdev/go-dbcodegen","owner":"telkomdev","description":"Go DB Code Generator","archived":false,"fork":false,"pushed_at":"2022-07-03T14:47:10.000Z","size":56,"stargazers_count":24,"open_issues_count":0,"forks_count":0,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-03-28T04:34:56.073Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/telkomdev.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}},"created_at":"2022-06-10T10:00:15.000Z","updated_at":"2022-10-06T07:40:12.000Z","dependencies_parsed_at":"2022-09-04T15:20:27.974Z","dependency_job_id":null,"html_url":"https://github.com/telkomdev/go-dbcodegen","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telkomdev%2Fgo-dbcodegen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telkomdev%2Fgo-dbcodegen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telkomdev%2Fgo-dbcodegen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telkomdev%2Fgo-dbcodegen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/telkomdev","download_url":"https://codeload.github.com/telkomdev/go-dbcodegen/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248907888,"owners_count":21181425,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-11-16T04:40:46.022Z","updated_at":"2025-04-14T15:41:00.186Z","avatar_url":"https://github.com/telkomdev.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Go Database Code Generator\nThis tool is to help you generate schema migrations and CRUD code in Golang from an entity definition in form of JSON.\n\n## Why\nThis tool is inspired by an amazing video titled [Design Microservice Architectures the Right Way](https://www.youtube.com/watch?v=j6ow-UemzBc).\nPlenty of reasons why this tool is built can be found there. One of the example, according to that video, is when things \nare slow because some queries don't have index, the hero is not the person who fix it by adding index. However, the unsung \nhero is the one who prevents it from ever happened in the first place. One way to do that is to provide a tool to generate high\nquality database access code. This dbcodegen is aimed to be such tool.\n\n## Supported Command\n## gen:migration\nGenerate database migration file\n\nCommand:\n```\ndbgen gen:migration -c {connection_string} -d {output directory} -o {output filename} input file(s)/folder(s)\n```\nExample:\n```\ndbgen gen:migration -c postgresql://postgres:postgres@localhost:5432/playground -d db/migration -o  users_registrations db/schemas\n```\n\n## gen:code\nGenerate schemas and queries into code\n\nCommand:\n```\ndbgen gen:code -i {input folder}\n```\n\nExample:\n```\ndbgen gen:code -i examples/schemas\n```\n\nNotes:\ngen:code also has some optional fields:\n1. packageName: package name for database in Go\n2. packagePath: output path for database in Go\n3. sqlPackage: SQL Package to specify which library to use\n\n## dump:db\nDump current schemas into JSON files\n\nCommand:\n```\ndbgen dump:db -c {connection} -o {output path}\n```\n\nExample:\n```\ndump:db -c postgresql://postgres:postgres@localhost:5432/playground -o examples/schemas\n```\n\n## Input file Example\nThe input is JSON file containing structures of an entity. Complete schema spec can be found [here](https://github.com/telkomdev/go-dbcodegen/blob/main/examples/schemas/json-schema-spec.md)\n```\n{\n  \"name\": \"example\",\n  \"fields\": [\n    {\n      \"name\": \"id\",\n      \"type\": \"bigserial\",\n      \"options\": [\n        \"primary key\"\n      ]\n    },\n    {\n      \"name\": \"name\",\n      \"type\": \"varchar\",\n      \"limit\": 50,\n      \"options\": [\n        \"not null\"\n      ]\n    }\n  ],\n  \"indexes\": [\n    {\n      \"name\": \"index_example_on_name\",\n      \"fields\": [\n        {\n          \"column\": \"name\"\n        }\n      ],\n      \"unique\": true\n    }\n  ]\n}\n```\nOther examples can be found [here](https://github.com/telkomdev/go-dbcodegen/tree/main/examples/schemas)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftelkomdev%2Fgo-dbcodegen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftelkomdev%2Fgo-dbcodegen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftelkomdev%2Fgo-dbcodegen/lists"}