Conversation
Because it makes more sense. Let's not over-abstract things with weird terms :)
e2897e7 to
4f88731
Compare
|
@jwoertink this now allows configuring multiple databases and allows configuring what database each model uses. Does this look like it would work for your needs? |
paulcsmith
left a comment
There was a problem hiding this comment.
This still needs work, but hoping this shows what can be done
| database_name = "avram_dev" | ||
|
|
||
| Avram::Repo.configure do |settings| | ||
| class TestDatabase < Avram::Database |
There was a problem hiding this comment.
Here is how to create a new Database
| class TestDatabase < Avram::Database | ||
| end | ||
|
|
||
| TestDatabase.configure do |settings| |
| class BaseModel < Avram::Model | ||
| def self.database | ||
| TestDatabase | ||
| end |
There was a problem hiding this comment.
Here is how you set what database a model uses. Can be done on the abstract class or could be overridden per model
4f88731 to
b2bf1ac
Compare
jwoertink
left a comment
There was a problem hiding this comment.
This is pretty amazing! The only thing I'm wondering is maybe there should be a spec that actually connects to another DB? It would mean setting up a secondary one, but it could have just a single table so we can verify that we can query each DB at the same time.
Aside from that, it all looks great. I can't wait to try this out.
|
Yeah I need to add some more specs and a few other things but wanted to make sure this would actually address the problem. Looks like it will so I'll finish it up so we can get you guys on Avram :D |
88e97e7 to
9d5cf3e
Compare
|
Spec added. Ready for another review! |
jwoertink
left a comment
There was a problem hiding this comment.
Sweet! Super close. Just a few comments.
| # | ||
| # If does not raise an error then that means it is using the good connection, | ||
| # which is not what we configured | ||
| expect_raises Avram::ConnectionError do |
There was a problem hiding this comment.
Should this raise an exception error message letting us know which one it wasn't able to connect to? Our app could have up to 4 PG connections technically (a bit absurd, I know), so if for some reason one of them didn't connection, it would be nice to see Unable to connect with DatabaseWithIncorrectSettings or something.
88bc48d to
f26c304
Compare
|
This will require changes to the guides and also will need changes in Lucky CLI to generate a default database. I think we'll call it |
f26c304 to
88e05c3
Compare
Introduced in luckyframework/avram#136
Introduced in luckyframework/avram#136
Introduced in luckyframework/avram#136
Introduced in luckyframework/avram#136
Introduced in luckyframework/avram#136
Introduced in luckyframework/avram#136
Introduced in luckyframework/avram#136
Closes #9