{"id":18548445,"url":"https://github.com/danielfbm/migrate","last_synced_at":"2025-05-15T08:13:05.916Z","repository":{"id":57554489,"uuid":"123063522","full_name":"danielfbm/migrate","owner":"danielfbm","description":null,"archived":false,"fork":false,"pushed_at":"2018-02-27T03:19:07.000Z","size":4009,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"v1.3.1-vendor","last_synced_at":"2024-12-26T07:09:29.085Z","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/danielfbm.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":"2018-02-27T02:53:21.000Z","updated_at":"2018-02-27T02:53:42.000Z","dependencies_parsed_at":"2022-09-26T18:51:21.231Z","dependency_job_id":null,"html_url":"https://github.com/danielfbm/migrate","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielfbm%2Fmigrate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielfbm%2Fmigrate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielfbm%2Fmigrate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielfbm%2Fmigrate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danielfbm","download_url":"https://codeload.github.com/danielfbm/migrate/tar.gz/refs/heads/v1.3.1-vendor","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239269808,"owners_count":19610865,"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-06T20:34:37.648Z","updated_at":"2025-02-17T09:43:26.476Z","avatar_url":"https://github.com/danielfbm.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"__[v3.0 in the making](https://github.com/danielfbm/migrate/tree/v3.0-prev)__\n\n---\n\n# migrate\n\n[![Build Status](https://travis-ci.org/mattes/migrate.svg?branch=master)](https://travis-ci.org/mattes/migrate)\n[![GoDoc](https://godoc.org/github.com/danielfbm/migrate?status.svg)](https://godoc.org/github.com/danielfbm/migrate)\n\nA migration helper written in Go. Use it in your existing Golang code \nor run commands via the CLI. \n\n```\nGoCode   import github.com/danielfbm/migrate/migrate\nCLI      go get -u github.com/danielfbm/migrate\n```\n\n__Features__\n\n* Super easy to implement [Driver interface](http://godoc.org/github.com/danielfbm/migrate/driver#Driver).\n* Gracefully quit running migrations on ``^C``.\n* No magic search paths routines, no hard-coded config files.\n* CLI is build on top of the ``migrate package``.\n\n\n## Available Drivers\n\n * [PostgreSQL](driver/postgres)\n * [Cassandra](driver/cassandra)\n * [SQLite](driver/sqlite3)\n * [MySQL](driver/mysql) ([experimental](https://github.com/danielfbm/migrate/issues/1#issuecomment-58728186))\n * [Neo4j](driver/neo4j)\n * [Ql](driver/ql)\n * [MongoDB](driver/mongodb)\n * [CrateDB](driver/crate)\n\nNeed another driver? Just implement the [Driver interface](http://godoc.org/github.com/danielfbm/migrate/driver#Driver) and open a PR.\n\n\n## Usage from Terminal\n\n```bash\n# install\ngo get github.com/danielfbm/migrate\n\n# create new migration file in path\nmigrate -url driver://url -path ./migrations create migration_file_xyz\n\n# apply all available migrations\nmigrate -url driver://url -path ./migrations up\n\n# roll back all migrations\nmigrate -url driver://url -path ./migrations down\n\n# roll back the most recently applied migration, then run it again.\nmigrate -url driver://url -path ./migrations redo\n\n# run down and then up command\nmigrate -url driver://url -path ./migrations reset\n\n# show the current migration version\nmigrate -url driver://url -path ./migrations version\n\n# apply the next n migrations\nmigrate -url driver://url -path ./migrations migrate +1\nmigrate -url driver://url -path ./migrations migrate +2\nmigrate -url driver://url -path ./migrations migrate +n\n\n# roll back the previous n migrations\nmigrate -url driver://url -path ./migrations migrate -1\nmigrate -url driver://url -path ./migrations migrate -2\nmigrate -url driver://url -path ./migrations migrate -n\n\n# go to specific migration\nmigrate -url driver://url -path ./migrations goto 1\nmigrate -url driver://url -path ./migrations goto 10\nmigrate -url driver://url -path ./migrations goto v\n```\n\n\n## Usage in Go\n\nSee GoDoc here: http://godoc.org/github.com/danielfbm/migrate/migrate\n\n```go\nimport \"github.com/danielfbm/migrate/migrate\"\n\n// Import any required drivers so that they are registered and available\nimport _ \"github.com/danielfbm/migrate/driver/mysql\"\n\n// use synchronous versions of migration functions ...\nallErrors, ok := migrate.UpSync(\"driver://url\", \"./path\")\nif !ok {\n  fmt.Println(\"Oh no ...\")\n  // do sth with allErrors slice\n}\n\n// use the asynchronous version of migration functions ...\npipe := migrate.NewPipe()\ngo migrate.Up(pipe, \"driver://url\", \"./path\")\n// pipe is basically just a channel\n// write your own channel listener. see writePipe() in main.go as an example.\n```\n\n## Migration files\n\nThe format of migration files looks like this:\n\n```\n1481574547_initial_plan_to_do_sth.up.sql     # up migration instructions\n1481574547_initial_plan_to_do_sth.down.sql   # down migration instructions\n1482438365_xxx.up.sql\n1482438365_xxx.down.sql\n...\n```\n\nWhy two files? This way you could still do sth like \n``psql -f ./db/migrations/1481574547_initial_plan_to_do_sth.up.sql`` and there is no\nneed for any custom markup language to divide up and down migrations. Please note\nthat the filename extension depends on the driver.\n\n\n## Alternatives\n\n * https://bitbucket.org/liamstask/goose\n * https://github.com/tanel/dbmigrate\n * https://github.com/BurntSushi/migration\n * https://github.com/DavidHuie/gomigrate\n * https://github.com/rubenv/sql-migrate\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielfbm%2Fmigrate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanielfbm%2Fmigrate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielfbm%2Fmigrate/lists"}