customink / secondbase

Seamless second database integration for Rails.
MIT License
220 stars 31 forks source link

remote tables #38

Closed steveburkett closed 3 weeks ago

steveburkett commented 7 years ago

hi there,

does secondbase support remote tables? in my case, I have a rails app that needs to connect to a few tables in a remote postgres db. i dont want to own the tables, i want to use the tables virtually. e.g., use a rails model to connect to it, and have a virtual schema representation locally so i can use FactoryGirl/test/add data to it. I dont want to "own" the foreign schema, i just want it "rebuilt" on a new test run, before the tests run, so i can add data to it and it might fail if my local assumptions are off. Does secondbase support this? thanks!

hmadison commented 7 years ago

You can have SecondBase dump the schema from your remote database and use that during test/development, then in production use a read only account for access. I don't think supporting CREATE FOREIGN TABLE or some other foreign data wrapper is within SecondBase's scope.

steveburkett commented 7 years ago

i think what you're suggesting is what we want. i dont think we want a FDW, but to dump the schema and use that during test. how do you suggest that we can automate this for running rspec spec?

hmadison commented 7 years ago

If you run rake db:schema:dump or rake db:structure:dump (depending on the setting of config.active_record.schema_format) from a rails application connected to the remote database and copy the resulting file into db/secondbase the gem should take care of the rest.