{"id":28402025,"url":"https://github.com/leancodebox/dbhelper","last_synced_at":"2025-07-23T10:34:50.574Z","repository":{"id":79218337,"uuid":"604955285","full_name":"leancodebox/dbhelper","owner":"leancodebox","description":"db helper","archived":false,"fork":false,"pushed_at":"2024-06-14T07:46:35.000Z","size":101,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-01T22:42:22.527Z","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/leancodebox.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":"2023-02-22T06:04:36.000Z","updated_at":"2024-06-14T07:46:38.000Z","dependencies_parsed_at":"2024-06-20T11:14:42.371Z","dependency_job_id":null,"html_url":"https://github.com/leancodebox/dbhelper","commit_stats":null,"previous_names":["purerun/dbhelper"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/leancodebox/dbhelper","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leancodebox%2Fdbhelper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leancodebox%2Fdbhelper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leancodebox%2Fdbhelper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leancodebox%2Fdbhelper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leancodebox","download_url":"https://codeload.github.com/leancodebox/dbhelper/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leancodebox%2Fdbhelper/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266663199,"owners_count":23964708,"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","status":"online","status_checked_at":"2025-07-23T02:00:09.312Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2025-06-01T14:36:17.076Z","updated_at":"2025-07-23T10:34:50.566Z","avatar_url":"https://github.com/leancodebox.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 数据库助手/dbhelper （MYSQL）\n\n\u003e 一个极简的数据库辅助助手，可以帮助你创建gorm/model，迁移数据表表结构或者迁移一个数据库（MYSQL）表数据到另一个数据库中\n\n# 安装/install\n\n如果你的本地有`go 1.18`以上的环境。你可以使用以下命令直接安装。\n\n```\ngo install github.com/leancodebox/dbhelper@latest\n```\n\n执行后你可以运行`dbhelper`查看是否安装成功\n\n```\n$ dbhelper \n数据库助手/database helper\n\nUsage:\n  dbhelper [command]\n\nAvailable Commands:\n  completion        Generate the autocompletion script for the specified shell\n  help              Help about any command\n  init              初始化配置文件\n  make:model        从db创建gorm\n  migrate:table     导表助手\n  migrate:tabledata 导表助手2\n\nFlags:\n  -h, --help   help for dbhelper\n\nUse \"dbhelper [command] --help\" for more information about a command.\n\n```\n\n# 使用\n\n当你初次使用 `dbhelper` 的时候你可以按照以下步骤\n\n```shell\nmkdir tmp\ncd tmp\ndbhelper init\n```\n\n`dbhelper init` 执行完毕后会在当前目录生成一个`config.toml` 文件，如果存在则不会再次生成。\n\n## 使用 dbhelper 进行数据库表迁移 命令：`dbhelper migrate:table`\n\n`config.toml` 中有两个变量和表结构迁移相关，分别是 `origin_url` 原数据库 `target_url` 目标数据库。\n变量配置格式如下\n\n```\nroot:password@tcp(127.0.0.1:3306)/thh_database?charset=utf8mb4\u0026parseTime=True\u0026loc=Local\n[账号]:[密码]@tcp([ip]:[端口])/[数据库名]?charset=utf8mb4\u0026parseTime=True\u0026loc=Local\n```\n\n配置好后即可执行迁移指令 `dbhelper migrate:table`\n\n## 使用 dbhelper 进行数据库表内容迁移 命令：`dbhelper migrate:tabledata`\n\n配置与表结构迁移相同，需注意保持两个数据库的表相同，如果出现表结构不同，或 mysql 版本不同都可能出现一些不符合预期的结果。\n\n配置好后即可执行迁移指令 `dbhelper migrate:tabledata`\n\n# 使用 dbhelper 生成 gorm\n\n[使用 dbhelper 生成 gorm](./examples/make_model.md)\n\n# 编译相关 / about build\n\n\nwindows\n```\nSET CGO_ENABLED=0\nSET GOOS=darwin\nSET GOARCH=amd64\ngo build\n\nSET CGO_ENABLED=0\nSET GOOS=darwin\nSET GOARCH=arm64\ngo build\n\nSET CGO_ENABLED=0\nSET GOOS=linux\nSET GOARCH=amd64\ngo build\n```\n\nmac\n```\ngo build\nCGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build\nCGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build\n```\n\nlinux\n```\ngo build\nCGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build\nCGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build\nCGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleancodebox%2Fdbhelper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleancodebox%2Fdbhelper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleancodebox%2Fdbhelper/lists"}