{"id":20852931,"url":"https://github.com/nonetheless/gorm-migrate","last_synced_at":"2025-05-12T05:31:02.523Z","repository":{"id":57487954,"uuid":"202981820","full_name":"nonetheless/gorm-migrate","owner":"nonetheless","description":"A codegen tool to generage gorm versiond migration,and manage it","archived":false,"fork":false,"pushed_at":"2019-11-25T03:02:37.000Z","size":9266,"stargazers_count":6,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-01T00:51:12.219Z","etag":null,"topics":["gorm","gorm-migrate","gorm-migration","migrate","migration","migration-tool"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nonetheless.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":"2019-08-18T09:04:58.000Z","updated_at":"2023-03-29T01:54:18.000Z","dependencies_parsed_at":"2022-08-29T13:30:21.085Z","dependency_job_id":null,"html_url":"https://github.com/nonetheless/gorm-migrate","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nonetheless%2Fgorm-migrate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nonetheless%2Fgorm-migrate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nonetheless%2Fgorm-migrate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nonetheless%2Fgorm-migrate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nonetheless","download_url":"https://codeload.github.com/nonetheless/gorm-migrate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253681928,"owners_count":21946836,"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":["gorm","gorm-migrate","gorm-migration","migrate","migration","migration-tool"],"created_at":"2024-11-18T03:19:18.430Z","updated_at":"2025-05-12T05:30:57.512Z","avatar_url":"https://github.com/nonetheless.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gorm-migrate\nA codegen tool to generate gorm versiond migration code, you can create a gorm migration with gorm-migrate client, and you can use the migration code by import it.\n\n## Migrate codegen tool\n### Download binary and build \n```bash\ngo build gorm-migrate.go\n```\n### Install \nTo install the library and command line program, use the following:\n```bash\nGO111MODULE=off; go get -u github.com/nonetheless/gorm-migrate/...\n```\n\n### Usage\nYou can easily use this tool to create your gorm migration\n```bash\ngorm-migrate \nThe migrate generator for Gorm.\n\nUsage:\n  gmigrate [command]\n\nAvailable Commands:\n  help        Help about any command\n  migrate     create a new version\n  stamp       check test_migration version relation\n\nFlags:\n  -c, --configFile string    gorm migrate config (default \"configFile\")\n  -d, --dirName string       gorm migrate new version root dir path (default \"dirName\")\n  -h, --help                 help for gmigrate\n  -p, --packageName string   your project test_migration package name packageName (default \"packageName\")\n\n# you can create migration with this cmd\ngorm-migrate migrate -d $DIR -p $PACKAGENAME\n......\n\n# you can check the migration with this cmd\ngorm-migrate stamp -d $DIR\n[INFO] Stamp test_migration version:\n[INFO]                ---------\u003e     xlq9lndwjv9j\n[INFO] xlq9lndwjv9j   ---------\u003e     phma9g1znhpm\n[INFO] phma9g1znhpm   ---------\u003e     p1buif9wgmig\n[INFO] p1buif9wgmig   ---------\u003e     v3c06skwrur9\n\n```\n## Use Migration \n### Code migrate Demo\nWith the tool you can get the code template:\n```go\nfunc run(db *gorm.DB) error {\n\t//TODO add version update sql\n\treturn nil\n}\n\nfunc rollBack(db *gorm.DB) error {\n\t//TODO add version rollback function\n\treturn nil\n}\n```\nYou must write your own migration function with gorm.DB\n\n### Usage Example\nYou can use your migration code with import code, it's a upgrade database example:\n```go\npacakge main\n// main.go\nimport (\n\t\"github.com/google/martian/log\"\n\t\"github.com/jinzhu/gorm\"\n\t_ \"github.com/jinzhu/gorm/dialects/mysql\"\n    //this is your own migration pacakge\n\tmigration \"github.com/nonetheless/gorm-migrate/pkg/migrate\"\n)\n\nfunc main(){\n    \tdb, err := gorm.Open(\"mysql\", \"root:root@tcp(127.0.0.1:3306)/demo?charset=utf8\u0026parseTime=True\")\n    \tif err != nil {\n    \t\tt.Fatal(err)\n    \t}\n    \tdefer db.Close()\n    \tupdate, err:= migration.CreateMigration(db)\n    \terr = update.Upgrade(migrate.WithCmdOut(log))\n    \tif err != nil {\n    \t\tt.Fatal(err)\n    \t}\n}\n```\n## Development \n### Build\nBuild binary client:\n```bash\ngo build gorm-migrate.go\n```\n### Test\nTest asset, upgrade and downgrade function\n```bash\ngo test ./...\n```\n### Template\nThis project use go-bindata to store template, when you change template you must run :\n```bash\ngo-bindata -o asset/asset.go -pkg=asset template/...\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnonetheless%2Fgorm-migrate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnonetheless%2Fgorm-migrate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnonetheless%2Fgorm-migrate/lists"}