Skip to content

Consider not failing in storage_up if the user does not have a permission to create databases when the database is already created #296

@rinpatch

Description

@rinpatch

If a database user does not have a create database permission, PostgreSQL will return ERROR 42501 (insufficient_privilege) when trying to create a database, even if it is already created anyway. MySQL seems to have similar behavior. This makes Ecto.Adapter.Storage.storage_up error, which in turn makes mix ecto.create fail.

Our application runs mix ecto.create before starting tests because we expected it to create the table with the default postgres superuser credentials, or just do nothing if the database already exists with custom credentials. However the latter is not the case if the user does not have a permission to create databases. While this is an easy application-side fix, I would expect mix ecto.create to not fail with the same config mix ecto.migrate works.

I've implemented a proof-of-concept patch for Postgres adapter in rinpatch@691d673 . If this behavior makes sense for the project, I can add tests and implement the same behavior for MySQL adapter.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions