Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/westonganger/rails_uuid_to_integer_primary_keys
A Rails Migration to convert your UUID primary keys back to integer / bigint primary keys
https://github.com/westonganger/rails_uuid_to_integer_primary_keys
database-migration rails ruby uuid
Last synced: 14 days ago
JSON representation
A Rails Migration to convert your UUID primary keys back to integer / bigint primary keys
- Host: GitHub
- URL: https://github.com/westonganger/rails_uuid_to_integer_primary_keys
- Owner: westonganger
- Created: 2021-02-12T18:40:15.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2024-12-18T21:54:22.000Z (29 days ago)
- Last Synced: 2024-12-18T22:34:34.939Z (29 days ago)
- Topics: database-migration, rails, ruby, uuid
- Language: Ruby
- Homepage:
- Size: 54.7 KB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Rails UUID to Integer Primary Keys
So you inherited a Rails app that is currently using UUID’s but now its causing size or speed problems with your app.
Now its time to convert your UUID primary keys back to integer / bigint primary keys, however it is not trivial to do this because all references / belongs_to associations must be kept intact.
I have gone through the hard work of creating a migration that is able to handle this for you mostly automatically.
# Requirements
- All models to convert must inherit from ApplicationRecord
- All `belongs_to` or `has_and_belongs_to_many` must be correctly defined so that reference keys can be located and updated.# Migration
- [migration.rb](./migration.rb)
# Credits
Created by [Weston Ganger](https://westonganger.com) - [@westonganger](https://github.com/westonganger)