{"id":15187398,"url":"https://github.com/notcoffee418/dbmigrator","last_synced_at":"2026-03-07T11:01:29.541Z","repository":{"id":200318944,"uuid":"705230491","full_name":"NotCoffee418/dbmigrator","owner":"NotCoffee418","description":"Database Migration system for Go.","archived":false,"fork":false,"pushed_at":"2025-04-25T18:07:01.000Z","size":48,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-24T04:27:53.373Z","etag":null,"topics":["database","database-management","db","go","golang","migration-tool","mssql","mysql","pgsql","sql","sqlite"],"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/NotCoffee418.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-10-15T12:36:43.000Z","updated_at":"2025-04-25T18:06:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"4172bf1b-e483-4e18-81db-df5643f14da4","html_url":"https://github.com/NotCoffee418/dbmigrator","commit_stats":{"total_commits":10,"total_committers":2,"mean_commits":5.0,"dds":0.09999999999999998,"last_synced_commit":"047c638bb1cceca235b5e95d21f4a69d65a55a69"},"previous_names":["notcoffee418/dbmigrator"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/NotCoffee418/dbmigrator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NotCoffee418%2Fdbmigrator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NotCoffee418%2Fdbmigrator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NotCoffee418%2Fdbmigrator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NotCoffee418%2Fdbmigrator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NotCoffee418","download_url":"https://codeload.github.com/NotCoffee418/dbmigrator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NotCoffee418%2Fdbmigrator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30212103,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-07T09:02:10.694Z","status":"ssl_error","status_checked_at":"2026-03-07T09:02:08.429Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["database","database-management","db","go","golang","migration-tool","mssql","mysql","pgsql","sql","sqlite"],"created_at":"2024-09-27T18:21:07.802Z","updated_at":"2026-03-07T11:01:29.511Z","avatar_url":"https://github.com/NotCoffee418.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Go Database Migrator\n\nSimple database migration system for Go.\n\n## Usage\n\n### Expected migration file structure\n\n- Must contain a `-- +up` comment to indicate the SQL below should run when applying a migration.\n- May contain a `-- +down` comment to indicate the SQL below should run when reverting a migration.\n- Comments behind `-- +up` and `-- +down` are allowed.\n\n```sql\n-- +up  \u003c- SQL below runs when applying a migration\nCREATE TABLE demo_guestbook (\n    id serial PRIMARY KEY,\n    name varchar(255) NOT NULL,\n    message text NOT NULL,\n    created_at timestamp NOT NULL DEFAULT NOW()\n);\n\n-- +down \u003c- SQL below runs when reverting a migration\nDROP TABLE demo_guestbook;\n```\n\n### Expected project structure\n\nYour migration files must be named in the format `0001_initial_migration.sql` where `0001` is the migration number and `initial_migration` is the name of the migration.\n\n```md\n|-- main.go\n|-- migrations\n|   |-- 0001_initial_migration.sql\n|   |-- 0002_second_migration.sql\n```\n\n### Apply and Revert Migrations\n\n```go\nimport (\n    \"github.com/NotCoffee418/dbmigrator\"\n)\n\n//go:embed all:migrations\nvar migrationFS embed.FS // `embed.FS` recommended but any `fs.FS` will work\n\nfunc main() {\n    // Define the query set for your database. Defaults to MySQL.\n    // Must be called before any other dbmigrator functions.\n    dbmigrator.SetDatabaseType(dbmigrator.PostgreSQL)\n    // Or\n    //dbmigrator.SetDatabaseType(dbmigrator.MySQL)\n    //dbmigrator.SetDatabaseType(dbmigrator.SQLite)\n    //dbmigrator.SetDatabaseType(dbmigrator.SQLServer)\n    // Or define your own based on dbmigrator.MigrationQueryDefinition\n\n    // Directory to migrations inside the FS\n    migrationsDir := \"migrations\"\n\n    // Migrations CLI (optional)\n    if len(os.Args \u003e 1) {\n        // help           - Display this help message.\n        // migrate up     - Apply all new database migrations.\n        // migrate down   - Rollback a single database migration.`\n        dbmigrator.HandleMigratorCommand(\n            db *sql.DB, \n            migrationFS embed.FS,\n            migrationsDir string, // Path to migrations dir in your fs \n            os.Args[1:] ...string)\n\n\n    // Manage migrations programatically\n    } else {\n        // Apply all new migrations\n        doneUp := \u003c-dbmigrator.MigrateUpCh(\n            db *sql.DB,\n            migrations embed.FS,\n            migrationsDir string)\n\n        // Revert Single Migration\n        doneDown := \u003c-dbmigrator.MigrateDownCh(\n            db *sql.DB,\n            migrations embed.FS,\n            migrationsDir string)\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnotcoffee418%2Fdbmigrator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnotcoffee418%2Fdbmigrator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnotcoffee418%2Fdbmigrator/lists"}