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

Shorten ActiveRecord::InternalMetadata.table_name to ar_internal_metadata #23025

Conversation

yahonda
Copy link
Member

@yahonda yahonda commented Jan 12, 2016

This pull request addresses the following error when tested with Oracle enhanced adapter.

It changes ActiveRecord::InternalMetadata.table_name to ar_internal_metadatas to support Oracle database which only supports 30 byte identifier length.

ActiveRecord::StatementInvalid:
OCIError: ORA-00972: identifier is too long: CREATE TABLE "ACTIVE_RECORD_INTERNAL_METADATAS" ("KEY" VARCHAR2(255), "VALUE" VARCHAR2(255), "CREATED_AT" TIMESTAMP NOT NULL, "UPDATED_AT" TIMESTAMP NOT NULL)

I think "ar_internal_metadatas" can explain what it intends.

@rails-bot
Copy link

r? @arthurnn

(@rails-bot has picked a reviewer for you, use r? to override)

@yahonda yahonda force-pushed the shorten_internal_metadata_table_name_less_than_30_byte branch 2 times, most recently from 3e54e56 to d3d9450 Compare January 12, 2016 14:06
@matthewd
Copy link
Member

I'm leaning towards renaming it schema_metadata, so it'll visually live with schema_migrations (and avoid the awkward "metadatas").

@yahonda
Copy link
Member Author

yahonda commented Jan 13, 2016

Thanks for the suggestion. As long as the table name length is shorter than 26 byte considering prefix and suffix support which requires 4 bytes. I'm fine with schema_metadata, ar_internal_metadatas or whatever.

@yahonda yahonda closed this Jan 20, 2016
@yahonda yahonda deleted the shorten_internal_metadata_table_name_less_than_30_byte branch January 20, 2016 15:54
@yahonda yahonda restored the shorten_internal_metadata_table_name_less_than_30_byte branch January 20, 2016 15:55
@yahonda yahonda reopened this Jan 20, 2016
@yahonda yahonda force-pushed the shorten_internal_metadata_table_name_less_than_30_byte branch from d3d9450 to d327414 Compare January 25, 2016 13:52
@yahonda
Copy link
Member Author

yahonda commented Jan 26, 2016

I've been thinking about which schema_metadata or ar_internal_metadatas table name is a better choice.

Looks like ActiveRecord::InternalMetadata is aiming to manage Rails environments to avoid tables dropped unintentionally, schema_metadata is little bit narrow. I think. Then I prefer ar_internal_metadatas.

This pull request is important for Oracle since it's identifier length is limited to 30 bytes (Yes, it is way short, but it is what it is so far..), and there are some use cases who develops their applications using non Oracle database and migrate it to Oracle at production environment.

It would be appreciated this pull request reviewed.

@sgrif
Copy link
Contributor

sgrif commented Jan 26, 2016

This will need to check for existing tables with the old name and rename them if they exist

@yahonda
Copy link
Member Author

yahonda commented Jan 26, 2016

@sgrif Thanks for the review. I have a question.

As far as I understand ActiveRecord::InternalMetadata is introduced in Rails 5.0, which is in beta status. I'm wondering if it still needs to implement a feature to handle if the old table name exist or not.

@sgrif
Copy link
Contributor

sgrif commented Jan 26, 2016

Given how easy it is to rename, I think it's worth it for people who are
currently on the beta.

On Tue, Jan 26, 2016, 3:07 PM Yasuo Honda notifications@github.com wrote:

@sgrif https://github.com/sgrif Thanks for the review. I have a
question.

As far as I understand ActiveRecord::InternalMetadata is introduced in
Rails 5.0, which is in beta status. I'm wondering if it still needs to
implement a feature to handle if the old table name exist or not.


Reply to this email directly or view it on GitHub
#23025 (comment).

@yahonda
Copy link
Member Author

yahonda commented Jan 26, 2016

Let me try to implement renaming and update this pull request.

@yahonda yahonda force-pushed the shorten_internal_metadata_table_name_less_than_30_byte branch from d327414 to adebed1 Compare January 27, 2016 14:25
@yahonda
Copy link
Member Author

yahonda commented Jan 27, 2016

Updated this pull request to include rename active_record_internal_metadatas to ar_internal_metadatas.

@@ -34,8 +42,16 @@ def table_exists?
ActiveSupport::Deprecation.silence { connection.table_exists?(table_name) }
end

def original_table_exists?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a note to remove this method in 5.1?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. Let me add one line comment in this method.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment added to mention that this method will be removed in Rails 5.1

@yahonda yahonda force-pushed the shorten_internal_metadata_table_name_less_than_30_byte branch from adebed1 to bff2ba2 Compare January 27, 2016 18:25
@maclover7
Copy link
Contributor

Can you change the table name to be ar_internal_metadata, (remove the "s" at the end)? I think the previous name had a grammar error. :)

@arthurnn arthurnn assigned sgrif and unassigned arthurnn Jan 27, 2016
@yahonda yahonda force-pushed the shorten_internal_metadata_table_name_less_than_30_byte branch from bff2ba2 to 543e07b Compare January 27, 2016 19:26
@yahonda
Copy link
Member Author

yahonda commented Jan 27, 2016

Thanks for the review and advice. Updated to use ar_internal_metadata, removing the trailing "s"

@yahonda yahonda changed the title Shorten ActiveRecord::InternalMetadata.table_name to ar_internal_metadatas Shorten ActiveRecord::InternalMetadata.table_name to ar_internal_metadata Jan 28, 2016
…data

to support Oracle database which only supports 30 byte identifier length
for those who already migrated to Rails 5.0.0 beta
@yahonda yahonda force-pushed the shorten_internal_metadata_table_name_less_than_30_byte branch from 543e07b to 407e0ab Compare February 1, 2016 15:52
sgrif added a commit that referenced this pull request Feb 1, 2016
…e_name_less_than_30_byte

Shorten ActiveRecord::InternalMetadata.table_name to ar_internal_metadata
@sgrif sgrif merged commit 4f2bce9 into rails:master Feb 1, 2016
@yahonda yahonda deleted the shorten_internal_metadata_table_name_less_than_30_byte branch February 1, 2016 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants