Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional identity columns #2201

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

brianthoman
Copy link

The goal here is to add optional support for Oracle 12's IDENTITY columns.

This code is probably still in need of some cleanup/adjustments, but I wanted to submit it as a sort of proof-of-concept and get some feedback before I continue working on it.

By default, IDENTITY columns are disabled. They can be enabled in the following ways:

For the whole app via initializer/config:

ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.use_identity_for_pk = true

In migrations:

create_table :things, primary_key_as_identity: true

# OR

create_table :things, id: false do |t|
  t.primary_key :test_id, :primary_key, identity: true
end

# OR

add_column :things, :test_id, :primary_key, identity: true

Please let me know what you think. Thank you!

@mattalat
Copy link

mattalat commented Nov 4, 2021

We would love this change. It also would solve #2049.

@akostadinov
Copy link
Contributor

If Rails can create proper relationships with the new column type, then I would say, use it by default unless user requested older style primary key. Or course some test cases to show that would be needed.

Another thing to consider is migrations and schema dumps with :ruby format. For migrations I don't know, but probably it makes sense to dump selecting old style PK for tables using old style.

In either case, thorough upgrade docs would be needed.

@mattalat
Copy link

@yahonda Sorry to ping directly, but I wonder if you have any reservations about this PR or any guidance on things to improve so it can be accepted. I would love to see this support make it into the gem.

@yahonda
Copy link
Collaborator

yahonda commented Mar 15, 2022

Let me have some review.

@yahonda yahonda self-requested a review March 15, 2022 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants