{"id":16645584,"url":"https://github.com/boolangery/gorm-app-migrate","last_synced_at":"2026-04-19T16:03:17.857Z","repository":{"id":87084197,"uuid":"304724391","full_name":"boolangery/gorm-app-migrate","owner":"boolangery","description":null,"archived":false,"fork":false,"pushed_at":"2020-10-18T11:28:03.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-12T08:27:02.519Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/boolangery.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2020-10-16T19:47:14.000Z","updated_at":"2020-10-18T11:28:05.000Z","dependencies_parsed_at":"2023-03-04T17:45:11.105Z","dependency_job_id":null,"html_url":"https://github.com/boolangery/gorm-app-migrate","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/boolangery/gorm-app-migrate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boolangery%2Fgorm-app-migrate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boolangery%2Fgorm-app-migrate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boolangery%2Fgorm-app-migrate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boolangery%2Fgorm-app-migrate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/boolangery","download_url":"https://codeload.github.com/boolangery/gorm-app-migrate/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boolangery%2Fgorm-app-migrate/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32012788,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T20:23:30.271Z","status":"online","status_checked_at":"2026-04-19T02:00:07.110Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","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":"2024-10-12T08:24:22.219Z","updated_at":"2026-04-19T16:03:17.837Z","avatar_url":"https://github.com/boolangery.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gorm-app-migrate\n\nA dead simple library to migrate / organize migration of web project in apps.\n\n## usage\n\n```go\ntype User struct {\n\tID        uint   `gorm:\"primarykey\"`\n\tEmail     string `gorm:\"uniqueIndex\"`\n\tFirstName string\n}\n\n// An app to manage users\ntype UserApp struct {}\n\nfunc (a *UserApp) Name() string {\n\treturn \"users\"\n}\n\nfunc (a *UserApp) Migrations() []GormMigration {\n\treturn []GormMigration{\n\t\tInlineGormMigration{\n\t\t\tID: \"0001_add_user\",\n\t\t\tOnUp: func(db *gorm.DB) error {\n\t\t\t\t// Here we are not using db.Migrator().CreateTable(\u0026User{}) because when resetting\n\t\t\t\t// migrations to zero, it will create field which would not have existed before\n\t\t\t\tif err := db.Exec(\"CREATE TABLE `users` (`id` integer,`email` text,PRIMARY KEY (`id`))\").Error; err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tif err := db.Exec(\"CREATE UNIQUE INDEX `idx_users_email` ON `users`(`email`)\").Error; err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\treturn nil\n\t\t\t},\n\t\t\tOnDown: func(db *gorm.DB) error {\n\t\t\t\treturn db.Migrator().DropTable(\u0026User{})\n\t\t\t},\n\t\t},\n\t\tInlineGormMigration{\n\t\t\tID: \"0002_add_user_first_name\",\n\t\t\tOnUp: func(db *gorm.DB) error {\n\t\t\t\treturn db.Migrator().AddColumn(\u0026User{}, \"FirstName\")\n\t\t\t},\n\t\t\tOnDown: func(db *gorm.DB) error {\n\t\t\t\treturn db.Migrator().DropColumn(\u0026User{}, \"FirstName\")\n\t\t\t},\n\t\t},\n\t}\n}\n\n\nfunc main() {\n    app := \u0026UserApp{}\n\n\tif s, err := Migrate(db.Debug(), app); err != nil {\n\t\tt.Error(err)\n\t} else {\n\t\ts.Print()\n\t}\n\n\tif s, err := MigrateTo(db.Debug(), app, \"zero\"); err != nil {\n\t\tt.Error(err)\n\t} else {\n\t\ts.Print()\n\t}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboolangery%2Fgorm-app-migrate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fboolangery%2Fgorm-app-migrate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboolangery%2Fgorm-app-migrate/lists"}