{"id":13412007,"url":"https://github.com/GuiaBolso/darwin","last_synced_at":"2025-03-14T17:31:26.927Z","repository":{"id":53557559,"uuid":"55521819","full_name":"GuiaBolso/darwin","owner":"GuiaBolso","description":"Database schema evolution library for Go","archived":false,"fork":false,"pushed_at":"2023-02-24T17:39:33.000Z","size":32,"stargazers_count":145,"open_issues_count":5,"forks_count":34,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-07-31T20:49:35.702Z","etag":null,"topics":["database","go","golang","migration"],"latest_commit_sha":null,"homepage":"","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/GuiaBolso.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}},"created_at":"2016-04-05T15:57:59.000Z","updated_at":"2024-06-20T01:43:38.000Z","dependencies_parsed_at":"2022-08-20T15:40:46.463Z","dependency_job_id":"856aaf4d-21d5-4317-8ec4-14eb7214f140","html_url":"https://github.com/GuiaBolso/darwin","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GuiaBolso%2Fdarwin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GuiaBolso%2Fdarwin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GuiaBolso%2Fdarwin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GuiaBolso%2Fdarwin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GuiaBolso","download_url":"https://codeload.github.com/GuiaBolso/darwin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243618714,"owners_count":20320281,"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":["database","go","golang","migration"],"created_at":"2024-07-30T20:01:20.064Z","updated_at":"2025-03-14T17:31:21.905Z","avatar_url":"https://github.com/GuiaBolso.png","language":"Go","funding_links":[],"categories":["Data Integration Frameworks","Database","數據庫","数据库","数据库  `go语言实现的数据库`","\u003cspan id=\"数据库-database\"\u003e数据库 Database\u003c/span\u003e","Uncategorized","Generators"],"sub_categories":["Database Schema Migration","Advanced Console UIs","高級控制台界面","数据库模式迁移","\u003cspan id=\"高级控制台用户界面-advanced-console-uis\"\u003e高级控制台用户界面 Advanced Console UIs\u003c/span\u003e","标准 CLI","高级控制台界面"],"readme":"[![Build Status](https://travis-ci.org/GuiaBolso/darwin.svg?branch=master)](https://travis-ci.org/GuiaBolso/darwin)\n[![Go Report Card](https://goreportcard.com/badge/github.com/GuiaBolso/darwin)](https://goreportcard.com/report/github.com/GuiaBolso/darwin)\n[![GoDoc](https://godoc.org/github.com/GuiaBolso/darwin?status.svg)](https://godoc.org/github.com/GuiaBolso/darwin)\n\nTry browsing [the code on Sourcegraph](https://sourcegraph.com/github.com/GuiaBolso/darwin)!\n\n# Darwin\n\nDatabase schema evolution library for Go\n\n# Example\n\n```go\npackage main\n\nimport (\n\t\"database/sql\"\n\t\"log\"\n\n\t\"github.com/GuiaBolso/darwin\"\n\t_ \"github.com/go-sql-driver/mysql\"\n)\n\nvar (\n\tmigrations = []darwin.Migration{\n\t\t{\n\t\t\tVersion:     1,\n\t\t\tDescription: \"Creating table posts\",\n\t\t\tScript: `CREATE TABLE posts (\n\t\t\t\t\t\tid INT \t\tauto_increment, \n\t\t\t\t\t\ttitle \t\tVARCHAR(255),\n\t\t\t\t\t\tPRIMARY KEY (id)\n\t\t\t\t\t ) ENGINE=InnoDB CHARACTER SET=utf8;`,\n\t\t},\n\t\t{\n\t\t\tVersion:     2,\n\t\t\tDescription: \"Adding column body\",\n\t\t\tScript:      \"ALTER TABLE posts ADD body TEXT AFTER title;\",\n\t\t},\n\t}\n)\n\nfunc main() {\n\tdatabase, err := sql.Open(\"mysql\", \"root:@/darwin\")\n\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tdriver := darwin.NewGenericDriver(database, darwin.MySQLDialect{})\n\n\td := darwin.New(driver, migrations, nil)\n\terr = d.Migrate()\n\n\tif err != nil {\n\t\tlog.Println(err)\n\t}\n}\n```\n\n# Questions\n\nQ. Why there is not a command line utility?\n\nA. The purpose of this library is just be a library.\n\nQ. How can I read migrations from file system?\n\nA. You can read with the standard library and build the migration list.\n\nQ. Can I put more than one statement in the same Script migration?\n\nA. I do not recommend. Put one database change per migration, if some migration fail, you exactly what statement caused the error. Also only postgres correctly handle rollback in DDL transactions. \n\nTo be less annoying you can organize your migrations like? 1.0, 1.1, 1.2 and so on.\n\nQ. Why does not exists downgrade migrations?\n\nA. Please read https://flywaydb.org/documentation/faq#downgrade\n\nQ. Does Darwin perform a roll back if a migration fails?\n\nA. Please read https://flywaydb.org/documentation/faq#rollback\n\nQ. What is the best strategy for dealing with hot fixes?\n\nA. Plese read https://flywaydb.org/documentation/faq#hot-fixes\n\n\n# LICENSE\n\nThe MIT License (MIT)\n\nCopyright (c) 2016 Claudemiro\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGuiaBolso%2Fdarwin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FGuiaBolso%2Fdarwin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGuiaBolso%2Fdarwin/lists"}