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

[CLI] Moves DB settings to config/environments #402

Closed
wants to merge 1 commit into from

Conversation

eliasjpr
Copy link
Contributor

@eliasjpr eliasjpr commented Nov 18, 2017

[CLI] Moves DB settings to config/environments …
Currently database settings reside in the config/database.yml this is
redundant since Amber has settings per environment.

This PR removes the config/database.yml and uses the environment yamls
files to load the database settings.

There is a couple of benefits for doing this:

  1. Database settings are loaded per environment.
  2. It is more intuitive to know where to put DB settings.

[ENV LOADER] Add database settings to environment_loader

  • Adds database property to Amber::Settings
  • Adds database property to spec test.yml
  • Load database settings from environment yml
  • Updates settings specs to check for database settings
  • Updates environment loader specs to check for database settings

[CLI] Updates init spec file

  • Updates amber spec file to check for database key
  • Tidy init_spec connection string validation
  • Add expected_db_url(db_key, env) method to cleanup specs

Issue #293

@eliasjpr eliasjpr added this to the 0.4.0 - Features & Bugfixes milestone Nov 18, 2017
Copy link
Contributor

@faustinoaq faustinoaq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@@ -56,9 +56,9 @@ describe Amber do
expected_session = {:key => "amber.session", :store => :signed_cookie, :expires => 0}
settings.session.should eq expected_session
settings.port.should_not eq 3000
settings.database.should eq "mysql://root@localhost:3306/amber_test_app_test"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I liked this being in secrets more because as a framework we're not opinionated on which ORM to use or even if you have to use one at all.

Someone might choose to use mongo instead of a relational database or choose to have 2 or 3 databases per environment. As such I feel like it makes more sense to leave this in secrets.

WDYGT? @drujensen @marksiemers @faustinoaq @eliasjpr

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One way or another, the database url for non-development environments needs to be protected, as it has a username and password in it.

Either encrypting it, or reading from an environment variable.

Is there a certain one that amber has been preferring to date?

@drujensen
Copy link
Member

@elorest I think the database is embedded in Amber and feel like the database_url and redis_url should be on par with each other. All of our scaffolding generators are focused on a full MVC experience. Just like redis_url for websockets, it feels more proper to put the database_url as a first class citizen. People can ignore the setting if they decide to use a different backend.

Does that make sense?

@@ -10,15 +10,16 @@ describe Amber::Server do
@log = ::Logger.new(STDOUT).tap{|l| l.level = ::Logger::INFO}
@color = true
@redis_url = "\#{ENV[%(REDIS_URL)]? || %(redis://localhost:6379)}"
@database = "mysql://root@localhost:3306/amber_test_app_test"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be called database_url

it "does create the database when `db migrate`" do
MainCommand.run ["generate", "model", "Post"]
MainCommand.run ["db", "migrate"]
p db_filename
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leftover debugging puts?

@eliasjpr
Copy link
Contributor Author

eliasjpr commented Nov 20, 2017

I have not made any changes to this PR since @drujensen and I will pair to merge the 2 branches of work #403

@eliasjpr
Copy link
Contributor Author

@drujensen and @amberframework/core-team please review and approve

Currently database settings reside in the config/database.yml this is
redundant since Amber has settings per environment.

This PR removes the `config/database.yml` and uses the environment yamls
files to load the database settings.

There is a couple of benefits for doing this:
1. Database settings are loaded per environment.
2. It is more intuitive to know where to put DB settings.

[ENV LOADER] Add database settings to environment_loader

- Adds database property to Amber::Settings
- Adds database property to spec test.yml
- Load database settings from environment yml
- Updates settings specs to check for database settings
- Updates environment loader specs to check for database settings

[CLI] Updates init spec file

- Updates amber spec file to check for database key
- Tidy init_spec connection string validation
- Add `expected_db_url(db_key, env)` method to cleanup specs
@eliasjpr eliasjpr force-pushed the ep/move-db-settings-to-environments branch from f3f15bd to 2eb329d Compare November 23, 2017 15:16
@faustinoaq
Copy link
Contributor

We will use database_url, right?
Still looks good to me, just check the p db_filename line, is this needed? #402 (comment)

@drujensen
Copy link
Member

closing this in favor of #406 which changes the name from database to database_url

@drujensen drujensen closed this Nov 23, 2017
@eliasjpr eliasjpr deleted the ep/move-db-settings-to-environments branch November 29, 2017 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants