{"id":18550497,"url":"https://github.com/ayaanqui/go-migration-tool","last_synced_at":"2025-05-15T10:09:41.035Z","repository":{"id":103576170,"uuid":"607981574","full_name":"ayaanqui/go-migration-tool","owner":"ayaanqui","description":"Simple database migration tool for Go","archived":false,"fork":false,"pushed_at":"2023-11-06T17:20:35.000Z","size":23,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-01T09:14:03.189Z","etag":null,"topics":["cli","db-migration","golang","gorm"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/ayaanqui/go-migration-tool","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/ayaanqui.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-03-01T04:07:21.000Z","updated_at":"2023-03-04T22:50:20.000Z","dependencies_parsed_at":"2023-11-07T01:01:20.241Z","dependency_job_id":"5a55bb02-d8eb-4133-9578-f207093511b3","html_url":"https://github.com/ayaanqui/go-migration-tool","commit_stats":{"total_commits":22,"total_committers":1,"mean_commits":22.0,"dds":0.0,"last_synced_commit":"10e602a6ce6e94ab1256ec45aa8a5a97556bf5f2"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayaanqui%2Fgo-migration-tool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayaanqui%2Fgo-migration-tool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayaanqui%2Fgo-migration-tool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayaanqui%2Fgo-migration-tool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ayaanqui","download_url":"https://codeload.github.com/ayaanqui/go-migration-tool/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254319720,"owners_count":22051075,"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":["cli","db-migration","golang","gorm"],"created_at":"2024-11-06T21:04:57.163Z","updated_at":"2025-05-15T10:09:41.013Z","avatar_url":"https://github.com/ayaanqui.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Go Migration Tool\nA simple database migration tool that allows making sequential migrations easy.\n\n## Installation\n```\n$ go get github.com/ayaanqui/go-migration-tool\n```\n\n## Usage\nThis repository comes with 2 different sets of tooling. The first and probably the most important is the migration-tool. This is module allows the user to create a migration table with a list of all successful migrations. And when new migrations are detected, it will go ahead and create these migrations.\n\nThe second module is a simple CLI, which allows the user to create these database migration files. These files are just regular `.sql` files with a specific migration name and a UNIX timestamp.\n\n### migration-tool\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"log\"\n    \"net/http\"\n\n    \"github.com/ayaanqui/go-migration-tool/migration_tool\"\n)\n\nfunc main() {\n    db, err := get_db_connection() // Arbitrary function that returns an pointer to sql.DB\n    migration := migration_tool.New(db, \u0026migration_tool.Config{\n        Directory: \"./migrations\", // Directory which will contain all migraiton files\n        TableName: \"migrations\", // Name of the table that will hold all successful migrations\n    })\n    migration.RunMigration()\n\n    // Basic net/http server\n    http.HandleFunc(\"/\", func (w http.ResponseWriter, r *http.Request) {\n        fmt.Fprintf(w, \"Homepage\")\n    })\n    log.Fatal(http.ListenAndServe(\":8080\", nil))\n}\n```\n\n### CLI\n```\ngo run github.com/ayaanqui/go-migration-tool --directory \"./migrations\" create-migration MyNewMigration\n```\nRunning this command will create a new file inside the `./migrations` directory with the file name `[timestamp]_MyNewMigration.sql`.\n\nAssuming that the server was setup in a way, such that the `RunMigration()` method is called before starting the server, the method should take the contents of the generated SQL file and execute it, while also creating a new row inside the migration tabel with the UNIX timpstamp and the name of the migration.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fayaanqui%2Fgo-migration-tool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fayaanqui%2Fgo-migration-tool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fayaanqui%2Fgo-migration-tool/lists"}