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

Do not expect database user with app name to exist #13415

Merged
merged 1 commit into from Dec 20, 2013

Commits on Dec 20, 2013

  1. Do not expect database user with app name to exist

    By default when creating a project with `--database=postgresql` the `config/database.yml` file that is generated has a user specified that is the same as the app name
    
    ```
    development:
      adapter: postgresql
      encoding: unicode
      database: <%= app_name %>_development
      pool: 5
      username: <%= app_name %>
      password:
    ```
    
    This is counterintuitive and would rarely be valid. By default postgres creates a user with the current user name (http://www.postgresql.org/docs/9.3/static/database-roles.html) "it will have the same name as the operating system user that initialized the database cluster":
    
    ```
    $ whoami
    schneems
    ```
    
    If the `username` is left out postgresql will assume that you wish to log in as the default user
    
    ```
    $ psql -c '\du'
                                 List of roles
     Role name |                   Attributes                   | Member of
    -----------+------------------------------------------------+-----------
     schneems  | Superuser, Create role, Create DB, Replication | {}
    ```
    
    A good sensible default then for auto generated `database.yml` files is to remove the `username`, and have postgres attempt to connect to the database as the currently logged in user.
    
    Instead of submitting with a blank password, don't submit a password.
    schneems committed Dec 20, 2013
    Configuration menu
    Copy the full SHA
    dece621 View commit details
    Browse the repository at this point in the history