rails icon indicating copy to clipboard operation
rails copied to clipboard

Adds schema parameter into enable_extension

Open lomefin opened this issue 1 year ago • 7 comments

Summary

This patch tries to solve Heroku's new PostgreSQL extension policy while keeping the migration and schema code idiomatic.

PostgreSQL adapter method enable_extension now allows to add an schema in its name. The extension must be installed on another schema.

Usage:

enable_extension('other_schema.hstore')

The enable_extension can work with schema only if the given schema already exists in the database.

lomefin avatar Aug 09 '22 16:08 lomefin

@lomefin thank you for the PR.

Rather than an extra argument, could we use the same pattern as in https://github.com/rails/rails/pull/45707?

So it would be enable_extension('other_schema.hstore')

ghiculescu avatar Aug 09 '22 18:08 ghiculescu

Good idea.

lomefin avatar Aug 09 '22 21:08 lomefin

Please squash your commits when you're happy with this.

ghiculescu avatar Aug 09 '22 22:08 ghiculescu

I'm having issues on 2.7 on ActiveSupport's OptimizedMemCacheStoreTest#test_big5_hkscs_encoded_values

Any ideas how this commit is affecting that method or its an already existing error?

lomefin avatar Aug 10 '22 20:08 lomefin

I'm having issues on 2.7 on ActiveSupport's OptimizedMemCacheStoreTest#test_big5_hkscs_encoded_values

I believe that's just a flaky MemCache failure, I wouldn't worry about it

skipkayhil avatar Aug 10 '22 20:08 skipkayhil

Yeah, I guess so. There is also another error

PostgresqlTimestampFixtureTest#test_bc_timestamp

Which is the procedure for disregarding those issues? Just mention them here or should I do something else?

lomefin avatar Aug 10 '22 21:08 lomefin

Just mention them here or should I do something else?

Just mentioning here is fine - core/committers are usually pretty aware of which tests are flakey or related to this PR. The one you just observed is already logged here https://github.com/rails/rails/issues/45797

ghiculescu avatar Aug 10 '22 21:08 ghiculescu

Would you address the conflict with the latest main branch?

yahonda avatar Oct 18 '22 13:10 yahonda

done!

lomefin avatar Oct 25 '22 19:10 lomefin

I overlooked the CI failure. Please address this error as suggested and squash your commits.

% ARCONN=postgresql bin/test test/cases/adapters/postgresql/extension_migration_test.rb -n test_enable_extension_migration_with_schema
Using postgresql
Run options: -n test_enable_extension_migration_with_schema --seed 3125

# Running:

E

Error:
PostgresqlExtensionMigrationTest#test_enable_extension_migration_with_schema:
ArgumentError: wrong number of arguments (given 3, expected 4..5)
    /Users/yahonda/src/github.com/rails/rails/activerecord/lib/active_record/migration.rb:1304:in `initialize'
    /Users/yahonda/src/github.com/rails/rails/activerecord/test/cases/adapters/postgresql/extension_migration_test.rb:64:in `new'
    /Users/yahonda/src/github.com/rails/rails/activerecord/test/cases/adapters/postgresql/extension_migration_test.rb:64:in `test_enable_extension_migration_with_schema'


bin/test test/cases/adapters/postgresql/extension_migration_test.rb:59



Finished in 0.008196s, 122.0107 runs/s, 0.0000 assertions/s.
1 runs, 0 assertions, 0 failures, 1 errors, 0 skips
%

yahonda avatar Oct 31 '22 12:10 yahonda

Could you address the RuboCop offense below and squash commits?

activerecord/test/cases/adapters/postgresql/extension_migration_test.rb:65:1: C: [Correctable] Layout/TrailingWhitespace: Trailing whitespace detected.

yahonda avatar Nov 22 '22 14:11 yahonda

I've got hyper confused trying to re-squash the PR and got stuck. I'm sorry for the delay.

I decided to start anew, I made a new PR so I'll close this one. Thanks for all the comments, it has been very helpful.

lomefin avatar Jan 05 '23 07:01 lomefin

The subsequent PR: https://github.com/rails/rails/pull/46894

ghiculescu avatar Jan 06 '23 04:01 ghiculescu