{"id":15405270,"url":"https://github.com/fnando/ar-sequence","last_synced_at":"2025-09-12T17:34:10.784Z","repository":{"id":41959406,"uuid":"151290483","full_name":"fnando/ar-sequence","owner":"fnando","description":"Add support for PostgreSQL's SEQUENCE on ActiveRecord migrations.","archived":false,"fork":false,"pushed_at":"2024-03-24T01:08:04.000Z","size":47,"stargazers_count":16,"open_issues_count":6,"forks_count":12,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-17T12:14:45.844Z","etag":null,"topics":["activerecord","postgresql","rails","sequence"],"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/fnando.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","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},"funding":{"github":["fnando"],"custom":["https://paypal.me/nandovieira/🍕"]}},"created_at":"2018-10-02T16:54:23.000Z","updated_at":"2024-09-09T15:48:44.000Z","dependencies_parsed_at":"2024-10-19T11:29:30.968Z","dependency_job_id":null,"html_url":"https://github.com/fnando/ar-sequence","commit_stats":{"total_commits":20,"total_committers":5,"mean_commits":4.0,"dds":"0.30000000000000004","last_synced_commit":"053e6586fb9a6335ab547a31368ea214d27512bf"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/fnando/ar-sequence","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnando%2Far-sequence","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnando%2Far-sequence/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnando%2Far-sequence/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnando%2Far-sequence/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fnando","download_url":"https://codeload.github.com/fnando/ar-sequence/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnando%2Far-sequence/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274847543,"owners_count":25360978,"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","status":"online","status_checked_at":"2025-09-12T02:00:09.324Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["activerecord","postgresql","rails","sequence"],"created_at":"2024-10-01T16:15:49.627Z","updated_at":"2025-09-12T17:34:10.715Z","avatar_url":"https://github.com/fnando.png","language":"Ruby","funding_links":["https://github.com/sponsors/fnando","https://paypal.me/nandovieira/🍕"],"categories":[],"sub_categories":[],"readme":"# ar-sequence\n\n[![Tests](https://github.com/fnando/ar-sequence/workflows/Tests/badge.svg)](https://github.com/fnando/ar-sequence)\n[![Gem](https://img.shields.io/gem/v/ar-sequence.svg)](https://rubygems.org/gems/ar-sequence)\n[![Gem](https://img.shields.io/gem/dt/ar-sequence.svg)](https://rubygems.org/gems/ar-sequence)\n\nAdd support for PostgreSQL's `SEQUENCE` on ActiveRecord migrations.\n\n## Installation\n\n```bash\ngem install ar-sequence\n```\n\nOr add the following line to your project's Gemfile:\n\n```ruby\ngem \"ar-sequence\"\n```\n\n## Usage\n\nTo create a `SEQUENCE`, just use the method `create_sequence`.\n\n```ruby\nclass CreateUsers \u003c ActiveRecord::Migration[5.2]\n def up\n   create_sequence :position\n end\n\n def down\n   drop_sequence :position\n end\nend\n```\n\nYou can also specify the initial value and increment:\n\n```ruby\ncreate_sequence :position, increment: 2\ncreate_sequence :position, start: 100\n```\n\nTo define a column that has a sequence as its default value, use something like\nthe following:\n\n```ruby\nclass CreateThings \u003c ActiveRecord::Migration[5.2]\n  def change\n    create_sequence :position\n\n    create_table :things do |t|\n      t.text :name\n\n      # PostgreSQL uses bigint as the sequence's default type.\n      # Use a block to specify the default value on migrations.\n      t.bigint :position,\n                null: false,\n                default: -\u003e { \"nextval('position')\" }\n\n      t.timestamps\n    end\n  end\nend\n```\n\nThis gem also adds a few helpers to interact with `SEQUENCE`s.\n\n```ruby\n# Advance sequence and return new value\nActiveRecord::Base.nextval(\"position\")\n\n# Return value most recently obtained with nextval for specified sequence.\nActiveRecord::Base.currval(\"position\")\n\n# Set sequence's current value\nActiveRecord::Base.setval(\"position\", 1234)\n```\n\n## Maintainer\n\n- [Nando Vieira](https://github.com/fnando)\n\n## Contributors\n\n- https://github.com/fnando/ar-sequence/contributors\n\n## Contributing\n\nFor more details about how to contribute, please read\nhttps://github.com/fnando/ar-sequence/blob/main/CONTRIBUTING.md.\n\n## License\n\nThe gem is available as open source under the terms of the\n[MIT License](https://opensource.org/licenses/MIT). A copy of the license can be\nfound at https://github.com/fnando/ar-sequence/blob/main/LICENSE.md.\n\n## Code of Conduct\n\nEveryone interacting in the ar-sequence project's codebases, issue trackers,\nchat rooms and mailing lists is expected to follow the\n[code of conduct](https://github.com/fnando/ar-sequence/blob/main/CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffnando%2Far-sequence","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffnando%2Far-sequence","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffnando%2Far-sequence/lists"}