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
Fix postgresql database naming convention #332
Fix postgresql database naming convention #332
Conversation
I did not make any changes to the default user for postgresql. It is still I can incorporate that change also if wanted. |
@marksiemers yes, go ahead and change the default user. |
@drujensen - I can get that change in tomorrow. Overall, is my approach of adding a lot of LOC to the test suite acceptable? Not just for this change, but in general? |
The changes that were merged in from master may mean I have to rework some code. A few questions:
|
@marksiemers the test coverage and approach your taking looks good to me. |
ce05434
to
3df8325
Compare
Conflicts have been resolved, anything else needed for this PR? |
One question - should the database name be treated the same for all databases? Should we |
@marksiemers yes, I think you can rename it for all 3 for consistency. |
3df8325
to
3353eb8
Compare
@drujensen - The naming is now consistent. This one should be good to merge. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@marksiemers In regard to your last question. I think we should always default database names to be underscore instead of hyphen. Same for files and folder names as well.
@@ -4,7 +4,7 @@ ENV["AMBER_ENV"] = "test" | |||
TEST_PATH = "spec/support/sample" | |||
PUBLIC_PATH = TEST_PATH + "/public" | |||
VIEWS_PATH = TEST_PATH + "/views" | |||
TEST_APP_NAME = "test_app" | |||
TEST_APP_NAME = "sample-app" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this change? I personally prefer "test_app" since that's what it is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two reasons, though this might not be the best place for it:
- In order to test this fix, the app name needs a dash (-) in it
- This test would be a false green for an app containing "test"
@@ -42,6 +51,26 @@ module Amber::CLI::Spec | |||
YAML.parse(File.read("#{TESTING_APP}/shard.yml")) | |||
end | |||
|
|||
def environment_yml(environment : String) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't these already exist? Why does it show you adding them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK, not for the environment yaml files. It did exist for others:
def db_yml
YAML.parse(File.read("#{TESTING_APP}/config/database.yml"))
end
def amber_yml
YAML.parse(File.read("#{TESTING_APP}/.amber.yml"))
end
def shard_yml
YAML.parse(File.read("#{TESTING_APP}/shard.yml"))
end
That should be the case after this is merged in, all 3 dbs will use database_name_base which gsubs "-" with "_"
In #330 we are consistent with underscore, but I did not gsub hyphens. It should be easy enough to do - likely one line (not including tests). |
The build finally passed, are we good to merge? |
* Add test for generating and app with postgres * Add test for database url in environment yaml files * Add tests for database urls and names generated for docker-compose.yml * Replace '-' with '_' for postgresql database names * Switch default postgresql username to postgres in database.yml * Name databases consistently for pg, mysql, sqlite * Test Amber::CLI::App directly for database naming * Use 'database_name_base' property in all parts of docker-compose.yml
* Add test for generating and app with postgres * Add test for database url in environment yaml files * Add tests for database urls and names generated for docker-compose.yml * Replace '-' with '_' for postgresql database names * Switch default postgresql username to postgres in database.yml * Name databases consistently for pg, mysql, sqlite * Test Amber::CLI::App directly for database naming * Use 'database_name_base' property in all parts of docker-compose.yml Former-commit-id: 69716c4
Description of the Change
This fixes the issue that if an app name has a dash "-" in it, then an invalid database name will be generated for postgresql.
Alternate Designs
Some alternative choices:
Adopting the first would make the second easier to accomplish.
Benefits
Users will not face errors generating a new postgresql database when their app name has a dash in it. Fixes #329
Possible Drawbacks
As written, this will create inconsistent database names between postgresql and other databases.
Also, I changed the name of the
TESTING_APP
fromtest_app
tosample-app
. It didn't cause any pre-existing tests to fail, so I don't think it is an issue.