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

Rails 7.1 db:create not installing extension #389

Closed
frehoy opened this issue Dec 1, 2023 · 5 comments
Closed

Rails 7.1 db:create not installing extension #389

frehoy opened this issue Dec 1, 2023 · 5 comments

Comments

@frehoy
Copy link
Contributor

frehoy commented Dec 1, 2023

On a fresh new rails app on Rails 7.1.2 with the gem installed and adapter: postgis in config/database.yml I run rake db:create but the postgis extension is not created in the db, but the readme implies it will be:

The adapter will add the PostGIS extension to your database.
https://github.com/rgeo/activerecord-postgis-adapter#creating-a-spatial-rails-app

Running a migration with enable_extension 'postgis' works fine though.

I'd be happy to fix the readme or take a stab at fixing it in code if someone can point me in the right direction, I can't find the code that's supposed to create the extension 😬

@BuonOmo
Copy link
Member

BuonOmo commented Dec 12, 2023

I don’t have access to my computer now, I would find the correct place by following the db create task, found on GitHub: https://github.com/rails/rails/blob/531643244474446efc061b559504ed67acc8cae1/activerecord/lib/active_record/railties/databases.rake#L46C14-L46C14

@BuonOmo
Copy link
Member

BuonOmo commented Jan 27, 2024

@frehoy are you still in for fixing this ?

I think I found the culprit commit: 418c027

The author removed loads of things, including the postgis_database_tasks.rb that contained an extension_names method. Which is the interesting bit for us. Based on this I think there is enough to implement a PR (of course, we'd need to find which are the good bits we want). I don't really have time or energy for this now unfortunately so your help would be very appreciated !


@keithdoggett another solution would be to remove the documentation saying that the extension will be added, and refer to the other bit of doc saying the user needs to create a migration. Not really the rails magic way, but definitely a faster PR!

@frehoy
Copy link
Contributor Author

frehoy commented Jan 29, 2024

Yes! I'll give it a go this week.

@frehoy
Copy link
Contributor Author

frehoy commented Feb 3, 2024

Thanks for the pointers @BuonOmo, I had a look at 418c027 now and found quite a few tasks.

Since I don't know the background of why the tasks were removed I think just making the README consistent is the best course of action right now? I made a PR for that. Adding automagically creating the extensions back seems like a fair bit of work and I'm not sure of how it "should" look. Here's the PR: #392

@frehoy
Copy link
Contributor Author

frehoy commented Mar 7, 2024

Fixed by #392 Thanks for the help!

@frehoy frehoy closed this as completed Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants