{"id":49666938,"url":"https://github.com/sawirricardo/dbrs","last_synced_at":"2026-05-06T17:05:00.132Z","repository":{"id":346491985,"uuid":"1190225987","full_name":"sawirricardo/dbrs","owner":"sawirricardo","description":"small minimal database migration tool","archived":false,"fork":false,"pushed_at":"2026-03-24T12:45:39.000Z","size":58,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-25T05:44:48.685Z","etag":null,"topics":["database","db","mariadb","migration","mysql","postgres","postgresql","sqlite","tool"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/sawirricardo.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-24T04:40:07.000Z","updated_at":"2026-03-24T12:47:44.000Z","dependencies_parsed_at":null,"dependency_job_id":"16bd3ac8-a9f4-4673-8e32-8ee66d34b26b","html_url":"https://github.com/sawirricardo/dbrs","commit_stats":null,"previous_names":["sawirricardo/dbrs"],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/sawirricardo/dbrs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sawirricardo%2Fdbrs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sawirricardo%2Fdbrs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sawirricardo%2Fdbrs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sawirricardo%2Fdbrs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sawirricardo","download_url":"https://codeload.github.com/sawirricardo/dbrs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sawirricardo%2Fdbrs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32703536,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-06T08:33:17.875Z","status":"ssl_error","status_checked_at":"2026-05-06T08:33:17.221Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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","db","mariadb","migration","mysql","postgres","postgresql","sqlite","tool"],"created_at":"2026-05-06T17:04:47.759Z","updated_at":"2026-05-06T17:05:00.126Z","avatar_url":"https://github.com/sawirricardo.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dbrs\n\n`dbrs` is a small SQL migration tool.\n\nIt creates timestamped migration files, applies pending migrations, tracks applied versions in a database table, supports rolling migrations back in reverse order, and includes destructive reset commands for development workflows.\n\n## Features\n\n- Timestamped SQL migration files\n- Default migration path at `./db/migrations`\n- `migrate` to apply pending migrations\n- `status` to show applied and pending migrations\n- `show` to inspect database metadata and table sizes\n- `table` to inspect one table's columns and indexes\n- `rollback` to revert one or more applied migrations\n- `reset` to revert all tracked migrations\n- `wipe` to reset the current database without dropping the database itself\n- `fresh` to wipe and then re-run all migrations\n- Streamed progress output for `migrate`, `rollback`, `reset`, `wipe`, and `fresh`\n- Global `--quiet` / `-q` flag for summary-only output\n- Global `--json` flag for NDJSON event output in CI/agents\n- `.env` support, including custom env file paths\n- Configurable migration directory and migration table name\n- Opt-in table scaffolding for `create_*` migrations\n\n## Installation\n\nStable release:\n\n```bash\ncurl -fsSL https://raw.githubusercontent.com/sawirricardo/dbrs/main/install.sh | bash\n```\n\nEdge release from `main`:\n\n```bash\nDBRS_RELEASE_TAG=edge curl -fsSL https://raw.githubusercontent.com/sawirricardo/dbrs/main/install.sh | bash\n```\n\nCustom install directory:\n\n```bash\nDBRS_INSTALL_DIR=/usr/local/bin curl -fsSL https://raw.githubusercontent.com/sawirricardo/dbrs/main/install.sh | bash\n```\n\nUninstall:\n\n```bash\ncurl -fsSL https://raw.githubusercontent.com/sawirricardo/dbrs/main/uninstall.sh | bash\n```\n\n## Quick Start\n\nCreate a `.env`:\n\n```env\nDATABASE_URL=postgres://localhost/my_app\nDBRS_MIGRATIONS_DIR=./db/migrations\nDBRS_MIGRATION_TABLE=dbrs_migrations\n```\n\nCreate a migration:\n\n```bash\ndbrs new create_users\n```\n\nApply migrations:\n\n```bash\ndbrs migrate\n```\n\nCheck migration status:\n\n```bash\ndbrs status\n```\n\nInspect the database:\n\n```bash\ndbrs show\n```\n\nInspect a table:\n\n```bash\ndbrs table users\n```\n\nRoll back the latest migration:\n\n```bash\ndbrs rollback --yes\n```\n\nReset all tracked migrations:\n\n```bash\ndbrs reset --yes\n```\n\nReset the database and re-run all migrations:\n\n```bash\ndbrs fresh --yes\n```\n\n## Migration Files\n\nBy default, `dbrs new my_migration` creates:\n\n```text\n./db/migrations/YYYY_MM_DD_HHMMSS-my-migration.sql\n```\n\nDefault file template:\n\n```sql\n-- dbrs:up\n\n-- write your forward migration here\n\n-- dbrs:down\n\n-- write the rollback for this migration here\n```\n\nRules:\n\n- `-- dbrs:up` is required\n- `-- dbrs:down` is optional\n- `rollback` and `reset` fail if they hit a migration with no `down` section\n- migrations are applied in filename order\n\nExample:\n\n```sql\n-- dbrs:up\n\nCREATE TABLE users (\n    id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,\n    email TEXT NOT NULL UNIQUE\n);\n\n-- dbrs:down\n\nDROP TABLE users;\n```\n\n## Commands\n\nGlobal options:\n\n- `--env-file \u003cENV_FILE\u003e` or `DBRS_ENV_FILE`\n- `--quiet` or `-q` to suppress streamed progress output and show only summaries/errors\n- `--json` for newline-delimited JSON event output on stdout for CI/agents\n- `--wait` to poll until the database accepts connections before running a DB-backed command\n- `--wait-timeout \u003csecs\u003e` and `--wait-interval \u003csecs\u003e` to control readiness polling\n- `--quiet` and `--json` are mutually exclusive\n\nProgress output:\n\n- `migrate`, `rollback`, `reset`, `wipe`, and `fresh` print live progress by default\n- use `--quiet` for summary-only output\n- use `--json` for machine-readable NDJSON events\n- use `--wait` when your database may still be starting up\n\nCreate a migration:\n\n```bash\ndbrs new \u003cname\u003e\n```\n\nOptions:\n\n- `--dir \u003cDIR\u003e` or `DBRS_MIGRATIONS_DIR`\n- `--env-file \u003cENV_FILE\u003e` or `DBRS_ENV_FILE`\n- `--table`\n- `--backend postgres|mysql|sqlite`\n\nApply pending migrations:\n\n```bash\ndbrs migrate --database-url \u003cDATABASE_URL\u003e\n```\n\nWait for the database first if needed:\n\n```bash\ndbrs --wait --wait-timeout 60 migrate --database-url \u003cDATABASE_URL\u003e\n```\n\nOptions:\n\n- `--dir \u003cDIR\u003e` or `DBRS_MIGRATIONS_DIR`\n- `--env-file \u003cENV_FILE\u003e` or `DBRS_ENV_FILE`\n- `--database-url \u003cDATABASE_URL\u003e` or `DATABASE_URL`\n- `--quiet` or `-q`\n- `--json`\n\nExample output:\n\n```text\nRunning 2 pending migration(s)...\n[1/2] Running 2026_03_24_120000 (create-users)...\n[1/2] Done 2026_03_24_120000 (create-users) in 0.03s\n[2/2] Running 2026_03_24_120100 (add-email-index)...\n[2/2] Done 2026_03_24_120100 (add-email-index) in 0.01s\nApplied 2 migration(s).\nTotal migrate time: 0.05s\n```\n\nExample JSON output:\n\n```text\n{\"event\":\"start\",\"command\":\"migrate\",\"pending\":2}\n{\"event\":\"migration_started\",\"command\":\"migrate\",\"index\":1,\"total\":2,\"version\":\"2026_03_24_120000\",\"name\":\"create-users\"}\n{\"event\":\"migration_finished\",\"command\":\"migrate\",\"index\":1,\"total\":2,\"version\":\"2026_03_24_120000\",\"name\":\"create-users\",\"duration_seconds\":0.030000}\n{\"event\":\"summary\",\"command\":\"migrate\",\"applied\":2,\"duration_seconds\":0.050000}\n```\n\nShow status:\n\n```bash\ndbrs status --database-url \u003cDATABASE_URL\u003e\n```\n\nOptions:\n\n- `--json`\n\nOutput states:\n\n- `APPLIED`\n- `PENDING`\n- `APPLIED_MODIFIED`\n- `MISSING_FILE`\n\nExample JSON output:\n\n```text\n{\"event\":\"migration\",\"command\":\"status\",\"state\":\"APPLIED\",\"version\":\"2026_03_24_120000\",\"name\":\"create-users\"}\n{\"event\":\"summary\",\"command\":\"status\",\"count\":1}\n```\n\nShow database info:\n\n```bash\ndbrs show --database-url \u003cDATABASE_URL\u003e\n```\n\nOptions:\n\n- `--database-url \u003cDATABASE_URL\u003e` or `DATABASE_URL`\n- `--limit \u003cN\u003e` for the number of tables to print, default `20`\n- `--json`\n\nExample JSON output:\n\n```text\n{\"event\":\"database_info\",\"command\":\"show\",\"backend\":\"postgres\",\"database\":\"my_app\",\"current_schema\":\"public\",\"database_size_bytes\":123456,\"open_connections\":2,\"schemas\":[\"public\"]}\n{\"event\":\"table_size\",\"command\":\"show\",\"name\":\"public.users\",\"size_bytes\":8192}\n{\"event\":\"summary\",\"command\":\"show\",\"count\":1}\n```\n\nInspect one table:\n\n```bash\ndbrs table users --database-url \u003cDATABASE_URL\u003e\n```\n\nOptions:\n\n- `--json`\n\nExample JSON output:\n\n```text\n{\"event\":\"table_info\",\"command\":\"table\",\"backend\":\"postgres\",\"database\":\"my_app\",\"table\":\"public.users\",\"estimated_rows\":42,\"size_bytes\":8192}\n{\"event\":\"column\",\"command\":\"table\",\"table\":\"public.users\",\"name\":\"id\",\"data_type\":\"bigint\",\"nullable\":false,\"default\":null}\n{\"event\":\"index\",\"command\":\"table\",\"table\":\"public.users\",\"name\":\"users_pkey\",\"unique\":true,\"columns\":[\"id\"]}\n{\"event\":\"summary\",\"command\":\"table\",\"columns\":1,\"indexes\":1}\n```\n\nThe table name can be either:\n\n- `table`\n- `schema.table`\n\nRoll back one or more migrations:\n\n```bash\ndbrs rollback --database-url \u003cDATABASE_URL\u003e --steps 3 --yes\n```\n\nOptions:\n\n- `--quiet` or `-q`\n- `--json`\n\nRoll back until a specific migration version remains applied:\n\n```bash\ndbrs rollback --database-url \u003cDATABASE_URL\u003e --to 2026_03_24_12_30_00.123456 --yes\n```\n\nReset all tracked migrations:\n\n```bash\ndbrs reset --database-url \u003cDATABASE_URL\u003e --yes\n```\n\nOptions:\n\n- `--quiet` or `-q`\n- `--json`\n\nWipe the current database contents:\n\n```bash\ndbrs wipe --database-url \u003cDATABASE_URL\u003e --yes\n```\n\nOptions:\n\n- `--quiet` or `-q`\n- `--json`\n\nFresh database from migrations:\n\n```bash\ndbrs fresh --database-url \u003cDATABASE_URL\u003e --yes\n```\n\nOptions:\n\n- `--quiet` or `-q`\n- `--json`\n\n## Environment\n\nSupported environment variables:\n\n- `DATABASE_URL`\n- `DBRS_ENV_FILE`\n- `DBRS_MIGRATIONS_DIR`\n- `DBRS_MIGRATION_TABLE`\n\nEnv loading order:\n\n1. `--env-file`\n2. `DBRS_ENV_FILE`\n3. default `.env`\n\nMigration directory behavior:\n\n- default: `./db/migrations`\n- override with `--dir`\n- or set `DBRS_MIGRATIONS_DIR`\n\nMigration table behavior:\n\n- default: `dbrs_migrations`\n- override with `DBRS_MIGRATION_TABLE=migrations`\n- allowed names are simple identifiers only: letters, numbers, and underscores\n\n## Table Scaffolding\n\n`dbrs new` supports opt-in table scaffolding:\n\n```bash\ndbrs new create_users --table\n```\n\nIf the migration name looks like a table creation, `dbrs new create_users` prints a hint suggesting `--table`.\n\nExamples:\n\n```bash\ndbrs new create_users --table\ndbrs new create_users_table --table --backend postgres\ndbrs new create_orders --table --backend mysql\n```\n\nScaffolded tables include:\n\n- `id`\n- `created_at`\n- `updated_at`\n\nBackend behavior:\n\n- Postgres uses `GENERATED BY DEFAULT AS IDENTITY`\n- MySQL uses `AUTO_INCREMENT`\n- SQLite uses `INTEGER PRIMARY KEY AUTOINCREMENT`\n\n## Supported Databases\n\n- PostgreSQL\n- MySQL / MariaDB\n- SQLite\n\n## Safety\n\nThese commands require explicit confirmation with `--yes`:\n\n- `rollback`\n- `reset`\n- `wipe`\n- `fresh`\n\n`migrate` does not require confirmation.\n\n## Local Development\n\nBuild:\n\n```bash\ncargo build\n```\n\nRun tests:\n\n```bash\ncargo test\n```\n\nRun repeatable Postgres/MySQL smoke tests:\n\n```bash\nscripts/smoke-test.sh \\\n  --postgres-url postgres://postgres@localhost:5432/testing \\\n  --mysql-url mysql://root:root@localhost:3306/testing\n```\n\nIf your databases may still be starting up, wait for readiness first:\n\n```bash\nscripts/smoke-test.sh \\\n  --postgres-url postgres://postgres@localhost:5432/testing \\\n  --mysql-url mysql://root:root@localhost:3306/testing \\\n  --wait\n```\n\nDestructive coverage for disposable databases only:\n\n```bash\nscripts/smoke-test.sh \\\n  --postgres-url postgres://postgres@localhost:5432/dbrs_smoke \\\n  --mysql-url mysql://root:root@localhost:3306/dbrs_smoke \\\n  --allow-destructive\n```\n\nThe smoke script verifies `migrate`, `status`, `show`, `table`, JSON output, `rollback`, and `reset`.\nWith `--allow-destructive`, it also verifies `fresh` and `wipe`.\nThe script-level `--wait` is useful when orchestrating fresh databases; `dbrs` itself also supports `--wait`, `--wait-timeout \u003csecs\u003e`, and `--wait-interval \u003csecs\u003e`.\n\nRun locally:\n\n```bash\ncargo run -- --help\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsawirricardo%2Fdbrs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsawirricardo%2Fdbrs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsawirricardo%2Fdbrs/lists"}