bitcoin-sv / merchantapi-reference

Merchant API reference implementation
Other
23 stars 17 forks source link

Allow non 'Postgres' database schema to be used. #9

Open ghost opened 3 years ago

ghost commented 3 years ago

Can you please provide an example connecting to a pg database that is external link (ie: not dependant on the docker-compose.yml database dependency).

What I found is that the code assumes the database name is 'Postgres' and cannot connect

For instance, assume we wish to change:

- ConnectionStrings:DBConnectionString=Server=merchant-gateway-database;Port=5432;User Id=merchant;Password=merchant;Database=merchant_gateway;
- ConnectionStrings:DBConnectionStringMaster=Server=merchant-gateway-database;Port=5432;User Id=postgres;Password=postgres;Database=merchant_gateway;

To a remote host, custom user id and password with database 'merchant_gateway' by changing the above string and also removing the depends_on in the docker-compose file.

Expected Outcome

Developer is able to point the mapi server to a remote database with different User Id than postgres and still connect to schema merchant_gateway

Actual Outcome

Unable to connect to remote schema because the code expects postgres as database name.

bvizin commented 3 years ago

As you observed there are two connection strings in configuration:

DBConnectionString - This connection string is using merchant username and points to merchant_gateway schema. It is used for all database interactions during application runtime.

DBConnectionStringMaster - This connection string is using postgres username and points to postgres schema. It is used at startup for database upgrades (and database creation if it does not exist).

In current implementation it is required that both connections strings are provided - even in case when external database is used. Another constraint is that schema is named merchant_gateway and username is merchant (even in case of external database).

We are currently looking into removing this constraints in upcoming versions.

ghost commented 3 years ago

Thanks for clarifying! I'm going to test today

mickmight commented 3 years ago

Was your test successful please, @attilaaf ? Interested to know if this is still an issue. Thanks.