{"id":18143225,"url":"https://github.com/jethrodaniel/sqlite_extensions-uuid","last_synced_at":"2025-04-06T19:28:20.974Z","repository":{"id":258913459,"uuid":"875536034","full_name":"jethrodaniel/sqlite_extensions-uuid","owner":"jethrodaniel","description":"Easily use the SQLite UUID extension in Rails","archived":false,"fork":false,"pushed_at":"2025-03-15T17:51:49.000Z","size":209,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-15T18:32:04.482Z","etag":null,"topics":["rails","ruby","sqlite"],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/sqlite_extensions-uuid","language":"C","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/jethrodaniel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.txt","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},"funding":{"github":["jethrodaniel"]}},"created_at":"2024-10-20T08:42:57.000Z","updated_at":"2025-03-15T17:51:52.000Z","dependencies_parsed_at":"2024-12-20T07:08:12.129Z","dependency_job_id":"4bb7897e-8d71-431c-b372-98fd2e01209e","html_url":"https://github.com/jethrodaniel/sqlite_extensions-uuid","commit_stats":null,"previous_names":["jethrodaniel/sqlite_extensions-uuid"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jethrodaniel%2Fsqlite_extensions-uuid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jethrodaniel%2Fsqlite_extensions-uuid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jethrodaniel%2Fsqlite_extensions-uuid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jethrodaniel%2Fsqlite_extensions-uuid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jethrodaniel","download_url":"https://codeload.github.com/jethrodaniel/sqlite_extensions-uuid/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247538145,"owners_count":20955070,"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":["rails","ruby","sqlite"],"created_at":"2024-11-01T19:06:10.210Z","updated_at":"2025-04-06T19:28:20.968Z","avatar_url":"https://github.com/jethrodaniel.png","language":"C","funding_links":["https://github.com/sponsors/jethrodaniel"],"categories":[],"sub_categories":[],"readme":"# sqlite_extensions-uuid\n\nSQLite's [UUID v4 extension](https://sqlite.org/src/file/ext/misc/uuid.c?t=version-3.46.1), packaged as a gem.\n\nThe main use-case is to allow using UUIDs as primary keys with SQLite in [Rails](https://rubyonrails.org/) apps.\n\n## Installation\n\nAdd this gem to your application's `Gemfile` by running this:\n\n```\nbundle add sqlite_extensions-uuid\n```\n\nor by adding this line and running `bundle`:\n\n```ruby\ngem \"sqlite_extensions-uuid\"\n```\n\nIn your Rails app, you'll need to load the extension in your `config/database.yml` like so:\n\n```yaml\ndevelopment:\n  adapter: sqlite3\n  extensions:\n    - \u003c%= SqliteExtensions::UUID.to_path %\u003e\n  # ...\n```\n\n## Usage\n\nSQLite's uuid extension provides the following:\n\n- `uuid()` - generate a version 4 UUID as a string\n- `uuid_str(X)` - convert a UUID X into a well-formed UUID string\n- `uuid_blob(X)` - convert a UUID X into a 16-byte blob\n\nFor more information about the extension itself, see the extension's [source code](https://sqlite.org/src/file/ext/misc/uuid.c?t=version-3.46.1).\n\n### Examples\n\nUse as a primary key in migrations:\n\n```\nbin/rails g model User email_address:uniq:index\n```\n```ruby\nclass CreateUsers \u003c ActiveRecord::Migration[8.0]\n  def change\n    create_table :users, id: :string, default: -\u003e { \"uuid()\" }, limit: 36 do |t|\n      t.string :email_address, null: false\n      t.timestamps\n    end\n    add_index :users, :email_address, unique: true\n  end\nend\n```\n\nCall SQL directly:\n\n```ruby\nActiveRecord::Base.connection.execute(\"select uuid_str(uuid())\")\n#=\u003e [{\"uuid_str(uuid())\"=\u003e\"56392d30-a2cf-47b9-895a-f8c1a1677bfc\"}]\n```\n\n## How it works\n\nThis gem compiles SQLite's uuid extension into a shared library using Ruby's native-gem functionality.\n\nIt doesn't _actually_ compile a Ruby native extension, it just uses the ruby extension process to compile the SQLite UUID library.\n\nIt then exposes a method, `SqliteExtensions::UUID.to_path`, which returns the location of that shared library.\n\nThis can be passed to [sqlite3](https://github.com/sparklemotion/sqlite3-ruby) in `Database.new(extensions: [])` or `Database#load_extension`.\n\n## Development\n\n```shell\n# one-time setup\nbundle\n\n# build and run tests\nbundle exec rake test\n\n# install locally\nbundle exec rake install\n\n# uninstall\ngem uninstall sqlite_extensions-uuid\n```\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/jethrodaniel/sqlite_extensions-uuid.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\nThe following files are copied verbatim from SQLite, and are used under their own license, which is visible at the beginning of each file:\n\n- `ext/sqlite_extensions/uuid/sqlite3ext.h`\n- `ext/sqlite_extensions/uuid/sqlite3.h`\n- `ext/sqlite_extensions/uuid/uuid.c`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjethrodaniel%2Fsqlite_extensions-uuid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjethrodaniel%2Fsqlite_extensions-uuid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjethrodaniel%2Fsqlite_extensions-uuid/lists"}