{"id":18319764,"url":"https://github.com/redding/ardb","last_synced_at":"2025-04-05T22:31:35.438Z","repository":{"id":7731495,"uuid":"9097854","full_name":"redding/ardb","owner":"redding","description":"Tools for using ActiveRecord with or without Rails.","archived":false,"fork":false,"pushed_at":"2022-01-24T00:18:34.000Z","size":324,"stargazers_count":1,"open_issues_count":5,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-21T12:59:21.809Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/redding.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":"2013-03-29T12:18:17.000Z","updated_at":"2022-01-29T12:52:33.000Z","dependencies_parsed_at":"2022-09-10T04:14:08.374Z","dependency_job_id":null,"html_url":"https://github.com/redding/ardb","commit_stats":null,"previous_names":[],"tags_count":41,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redding%2Fardb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redding%2Fardb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redding%2Fardb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redding%2Fardb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/redding","download_url":"https://codeload.github.com/redding/ardb/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247411236,"owners_count":20934650,"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-05T18:14:11.456Z","updated_at":"2025-04-05T22:31:34.989Z","avatar_url":"https://github.com/redding.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ardb\n\nTools for using ActiveRecord with or without Rails.\n\n## Usage\n\nGiven configured database connection parameters, Ardb provides a CLI and assorted tools for working with an ActiveRecord database. Ardb is designed to be used with or without Rails.\n\n### Configuration\n\nBy default, Ardb looks for database configuration in the `config/db.rb` file. You can override this using the `ENV[\"ARDB_DB_FILE\"]` env var.\n\nThe configuration includes typical database configuration parameters:\n\n```ruby\n# in config/db.rb\nrequire \"ardb\"\n\nArdb.configure do |c|\n  c.logger Logger.new($stdout)\n  c.root_path File.expand_path(\"../..\", __FILE__)\n\n  c.db.adapter      \"postgresql\"\n  c.db.encoding     \"unicode\"\n  c.db.min_messages \"WARNING\"\n  c.db.url          \"localhost:5432\"\n  c.db.username     \"testuser\"\n  c.db.password     \"secret\"\n  c.db.database     \"testdb\"\nend\n```\n\n#### Rails configuration\n\nIf using Ardb with Rails, add a `config/db.rb` file to have Ardb use Rails's configuration settings:\n\n```ruby\n# in config/db.rb\nrequire_relative \"./environment\"\nrequire \"ardb\"\n\n# This Ardb configuration matches Rails's settings.\nArdb.configure do |c|\n  rails_db_config    = Rails.application.config_for(\"database\")\n  c.root_path        = Rails.root\n  c.logger           = Rails.logger\n  c.schema_format    = Rails.application.config.active_record.schema_format || :ruby\n  c.default_timezone = :utc\n  c.adapter          = rails_db_config[\"adapter\"]\n  c.host             = rails_db_config[\"host\"]\n  c.port             = rails_db_config[\"port\"]\n  c.username         = rails_db_config[\"username\"]\n  c.password         = rails_db_config[\"password\"]\n  c.database         = rails_db_config[\"database\"]\n  c.encoding         = rails_db_config[\"encoding\"]\n  c.min_messages     = rails_db_config[\"min_messages\"]\n\n  c.migrations_path = \"db/migrate\"\n  c.schema_path = \"db/schema\"\nend\n```\n\n### CLI\n\n```\n$ ardb --help\nUsage: ardb [COMMAND] [options]\n\nOptions:\n        --version\n        --help\n\nCommands:\n  connect            Connect to the configured DB\n  create             Create the configured DB\n  drop               Drop the configured DB\n  generate-migration Generate a MIGRATION-NAME migration file\n  migrate            Migrate the configured DB\n  migrate-up         Migrate the configured DB up\n  migrate-down       Migrate the configured DB down\n  migrate-forward    Migrate the configured DB forward\n  migrate-backward   Migrate the configured DB backward\n```\n\n#### `connect` command\n\n```\n$ ardb connect --help\nUsage: ardb connect [options]\n\nOptions:\n        --version\n        --help\n\nDescription:\n  Connect to the configured DB\n$ ardb connect\nerror: database \"some_database\" does not exist\n$ ardb create\ncreated postgresql db \"some_database\"\n$ ardb connect\nconnected to postgresql db \"some_database\"\n```\n\nUse this command to verify the connection parameter configuration is correct.\n\n#### `create` command\n\n```\n$ ardb create --help\nUsage: ardb create [options]\n\nOptions:\n        --version\n        --help\n\nDescription:\n  Create the configured DB\n$ ardb create\ncreated postgresql db \"some_database\"\n$ ardb create\nerror: database \"some_database\" already exists\n```\n\n#### `drop` command\n\n```\n$ ardb drop --help\nUsage: ardb drop [options]\n\nOptions:\n        --version\n        --help\n\nDescription:\n  Drop the configured DB\n$ ardb drop\ndropped postgresql db \"some_database\"\n$ ardb drop\nerror: database \"some_database\" does not exist\n```\n\n#### `generate-migration` command\n\n```\n$ ardb generate-migration add_projects --help\nUsage: ardb generate-migration MIGRATION-NAME [options]\n\nOptions:\n        --version\n        --help\n\nDescription:\n  Generate a MIGRATION-NAME migration file\n$ ardb generate-migration add_projects\ngenerated /path/to/app/db/migrate/20191222074043_add_projects.rb\n```\n\n#### `migrate` command\n\n```\n$ ardb migrate --help\nUsage: ardb migrate [options]\n\nOptions:\n        --version\n        --help\n\nDescription:\n  Migrate the configured DB\n$ ardb migrate\n== 20191222074043 AddProjects: migrating ======================================\n-- create_table(:projects)\n   -\u003e 0.0276s\n== 20191222074043 AddProjects: migrated (0.0277s) =============================\n```\n\n#### `migrate-up` command\n\n```\n$ ardb migrate-up --help\nUsage: ardb migrate-up [options]\n\nOptions:\n    -t, --target-version VALUE       version to migrate to\n        --version\n        --help\n\nDescription:\n  Migrate the configured DB up\n$ ardb migrate-up\n== 20191222074043 AddProjects: migrating ======================================\n-- create_table(:projects)\n   -\u003e 0.0510s\n== 20191222074043 AddProjects: migrated (0.0511s) =============================\n```\n\n#### `migrate-down` command\n\n```\n$ ardb migrate-down --help\nUsage: ardb migrate-down [options]\n\nOptions:\n    -t, --target-version VALUE       version to migrate to\n        --version\n        --help\n\nDescription:\n  Migrate the configured DB down\n$ ardb migrate-down\n== 20191222074043 AddProjects: reverting ======================================\n-- drop_table(:projects)\n   -\u003e 0.0092s\n== 20191222074043 AddProjects: reverted (0.0132s) =============================\n```\n\n#### `migrate-forward` command\n\n```\n$ ardb migrate-forward --help\nUsage: ardb migrate-forward [options]\n\nOptions:\n    -s, --steps VALUE                number of migrations to migrate\n        --version\n        --help\n\nDescription:\n  Migrate the configured DB forward\n$ ardb migrate-forward\n== 20191222074043 AddProjects: migrating ======================================\n-- create_table(:projects)\n   -\u003e 0.0510s\n== 20191222074043 AddProjects: migrated (0.0511s) =============================\n```\n\n#### `migrate-backward` command\n\n```\n$ ardb migrate-backward --help\nUsage: ardb migrate-backward [options]\n\nOptions:\n    -s, --steps VALUE                number of migrations to migrate\n        --version\n        --help\n\nDescription:\n  Migrate the configured DB backward\n$ ardb migrate-backward\n== 20191222074043 AddProjects: reverting ======================================\n-- drop_table(:projects)\n   -\u003e 0.0092s\n== 20191222074043 AddProjects: reverted (0.0132s) =============================\n```\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n    gem \"ardb\"\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install ardb\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Added some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredding%2Fardb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fredding%2Fardb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredding%2Fardb/lists"}