{"id":24362197,"url":"https://github.com/piisalie/nomadize","last_synced_at":"2025-04-10T10:43:59.478Z","repository":{"id":56885697,"uuid":"45852498","full_name":"piisalie/nomadize","owner":"piisalie","description":"Some utilities for managing migrations with PostgreSQL","archived":false,"fork":false,"pushed_at":"2016-09-06T18:59:11.000Z","size":38,"stargazers_count":11,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-29T23:24:51.401Z","etag":null,"topics":["database","migration-tool","postgresql","ruby"],"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/piisalie.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-11-09T16:54:22.000Z","updated_at":"2018-02-15T12:20:29.000Z","dependencies_parsed_at":"2022-08-21T00:20:46.789Z","dependency_job_id":null,"html_url":"https://github.com/piisalie/nomadize","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piisalie%2Fnomadize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piisalie%2Fnomadize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piisalie%2Fnomadize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piisalie%2Fnomadize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/piisalie","download_url":"https://codeload.github.com/piisalie/nomadize/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248200497,"owners_count":21063908,"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","migration-tool","postgresql","ruby"],"created_at":"2025-01-18T22:50:22.618Z","updated_at":"2025-04-10T10:43:59.459Z","avatar_url":"https://github.com/piisalie.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Nomadize\n\nNomadize is a collection of rake tasks for managing migrations using a PostgreSQL database. It does not import an entire ORM and aims to be a small / simple utility.\n\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'nomadize'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install nomadize\n\n\n## Usage\n\nNomadize supports two different methods for configuring the connection to Postgres. Nomadize will also provide access to the underlying PG connection wrapper (using your defined config) by using the `Nomadize::Config.db` method. This wrapper responds to `exec` in the same way that the underlying PG connection object does.\n\n### Config File\n\nYou may use a config file `config/database.yml`. This file can be generated with either the rake task: `db:generate_template_config` or the CLI: `$ nomadize generate_template_config`. You can also choose to create the file for yourself. `config/database.yml` should look something like:\n\n```\ndevelopment:\n  :dbname: lol_dev\ntest:\n  :dbname: lol_test\nproduction:\n  :dbname: lol_production\n```\n\nThe test/development/production keys define environment dependent options for the `PG.connection` based on the environment set via `RACK_ENV`. These key/value pairs are handed directly to the `PG.connect` method, documentation for what options can be passed can be found [here](http://deveiate.org/code/pg/PG/Connection.html#method-c-new).\n\n### ENV['DATABASE_URL']\n\nAs of 0.4.0 Nomadize will also respect the `DATABASE_URL` environment variable. If `DATABASE_URL` is set it will override the connection information in the config file `config/database.yml`.\neg `postgres://user1:supersecure@somehost:1337/database-name` will result in the following configuration hash being passed to the underlying `PG.connection` object.\n\n```ruby\n{\n  dbname:   'database-name',\n  port:     1337,\n  user:     'user1',\n  password: 'supersecure',\n  host:     'somehost'\n}\n```\n\n### Migrations\nAfter a config file is in place  add `require 'nomadize/tasks'` to your rake file, and enjoy helpful new rake tasks such as:\n\n* `rake db:create` - creates a database and a schema_migrations table\n* `rake db:drop`   - dumps your poor poor database\n* `rake db:new_migration[migration_name]` - creates a timestamped migration file in db/migrations/ just fill in the details.\n* `rake db:migrate` - runs migrations found in db/migrations that have not been run yet\n* `rake db:status` - see which migrations have or have not been run\n* `rake db:rollback[count]` - rollback migrations (default count: 1)\n* `rake db:generate_template_config` - generate a config file in `config/database.yml`\n\nAlternatively you can use the commandline tool `nomadize`:\n\n* `nomadize create` - creates a database and a schema_migrations table\n* `nomadize drop`   - dumps your poor poor database\n* `nomadize new_migration $migration_name` - creates a timestamped migration file in db/migrations/ just fill in the details.\n* `nomadize migrate` - runs migrations found in db/migrations that have not been run yet\n* `nomadize status` - see which migrations have or have not been run\n* `nomadize rollback $count` - rollback migrations (default count: 1)\n* `nomadize generate_template_config` - generate a config file in `config/database.yml`\n\nMigrations are written in SQL in the generated YAML files:\n\n```\n---\n:up:   'CREATE TABLE testing (field TEXT);'\n:down: 'DROP TABLE testing;'\n```\n\n## Development\n\ntodo:\n\n- [x] an actual config setup / object\n- [x] sql cleaning (getting rid of the interpolation)\n- [x] to display migration status\n- [x] migration rollbacks\n- [ ] transactions / error handling\n- [x] maybe some kind of logging idk\n- [x] possibly wrap pg\n- [x] template config file generator\n- [x] maybe set a default migrations path (so the key isn't required in the config file)\n\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/piisalie/nomadize. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.\n\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n\n## Changelog\n0.4.2\n  * Make migrations path hard coded (this fixes an issue with heroku overwriting the database.yml file)\n\n0.4.1\n  * Fix a bug with command line utility using and incorrect method name.\n\n0.4.0\n  * support DATABASE_URL env variable\n  * Add template_config generator to command line tool\n  * Update the README\n  * Added some basic logging\n  * Fix an issue with rollback count not actually working :'(\n\n0.3.0\n  * Include a command line interface for Nomadize commands (THANKS [@moonglum](https://github.com/moonglum))\n\n0.2.0\n  * migration_path setting now has a default instead of being a required option in config/database.yml\n  * Reworded some of the README.md\n  * Added a rake task to generate a template config file in config/database.yml\n\n0.1.0 - Initial Release\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpiisalie%2Fnomadize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpiisalie%2Fnomadize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpiisalie%2Fnomadize/lists"}