-
-
Notifications
You must be signed in to change notification settings - Fork 246
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
db:create not working on branch bump-7-2 #415
Comments
Yep, open a PR! |
Started looking at how we could possibly add a test for this, but I went down a rabbit hole and there isn't anything simple. There's definitely something complicated, which would involve us creating a mini-Rails app, or manually loading all the Rails DB tasks. What's your suggestion - do I just ignore tests for now, or try to get something working? |
@dorner we used to have a test for tasks in older versions. This PR removed the deprecated tasks, but this is the file we used to test them: https://github.com/rgeo/activerecord-postgis-adapter/pull/353/files#diff-7b02d5d1111ed5b54c5fe75fb4796e01b12d15ba0db38212fb628f8516e379a4. That should be a sufficient structure to test this on. |
Actually, @dorner it appears this is already in the branch: activerecord-postgis-adapter/lib/active_record/connection_adapters/postgis_adapter.rb Line 163 in 435027d
|
Ah good catch! I'll do some spelunking to see if there's a loading issue. I'll try to bring back that file just to test this for backwards compability with existing Rails tasks. |
Hey @dorner I just made a new rails app and was able to run |
It was a new one. I'm going to try to dig into this either today or next week. |
Tried this again and it seems to be working. No idea what happened before. Closing this, will reopen if I figure out anything else :) |
OK interesting. |
Yup. Looks like the I'm wondering if something else in your new app is "accidentally" creating a connection and hence the adapter registration happens. The code itself is super easy (just add the register call to the very base Ruby file). The test file you linked doesn't really help because it calls the database module directly - the whole issue here seems to be related to a loading problem. Would it be OK to put in a PR without a corresponding test? |
@dorner I think that's fine since it's just a loading issue |
PR is up! #418 |
Got the problem! The issue is happening only when there are multiple databases, and a secondary database is postgis. Using this database.yml: development:
primary:
host: <%= ENV['DB_HOST'] %>
database: <%= ENV['DB_DATABASE'] %>
username: <%= ENV['DB_USERNAME'] %>
password: '<%= ENV['DB_PASSWORD'] %>'
adapter: trilogy
port: 3306
other:
host: <%= ENV['DB_HOST'] %>
database: <%= ENV['DB_DATABASE'] %>
username: <%= ENV['DB_USERNAME'] %>
password: '<%= ENV['DB_PASSWORD'] %>'
adapter: postgis
port: 5432
encoding: utf8
test:
primary:
host: <%= ENV['DB_HOST'] %>
database: <%= ENV['DB_DATABASE'] %>
username: <%= ENV['DB_USERNAME'] %>
password: '<%= ENV['DB_PASSWORD'] %>'
adapter: trilogy
port: 3306
other:
host: <%= ENV['DB_HOST'] %>
database: <%= ENV['DB_DATABASE'] %>
username: <%= ENV['DB_USERNAME'] %>
password: '<%= ENV['DB_PASSWORD'] %>'
adapter: postgis
port: 5432
encoding: utf8
|
I'm not sure how common this case is, but in my case I'm writing a pipeline viewer that collates data across multiple microservices' data stores, which is where I ran into this. |
When I try running
rake db:create
, I get the following error:If I add this in an initializer, it works:
ActiveRecord::Tasks::DatabaseTasks.register_task(/postgis/, "ActiveRecord::Tasks::PostgreSQLDatabaseTasks")
Not sure if this is something that used to be handled automatically and no longer is with Rails 7.2. I can whip up a PR if y'all like, just wanted to double check if I was doing something wrong.
The text was updated successfully, but these errors were encountered: