ever-traduora icon indicating copy to clipboard operation
ever-traduora copied to clipboard

Support for PostgreSQL

Open MatteoJoliveau opened this issue 4 years ago • 10 comments

Is your feature request related to a problem? Please describe. Our stack is based on PostgreSQL as our primary datastore. We would love to use one of the existing server instances for our Traduora deployment instead of having to provision a MySQL instance just for it.

Describe the solution you'd like Ideally, since TypeORM supports different database systems, we could find a way to keep Traduora agnostic and let the users pick the database they want.

Describe alternatives you've considered I could fork the repo and replace MySQL's config with Postgre's one, but it would be hacky and less useful for other users.

I'm willing to try and implement this if there is enough interest from the community and the maintainers.

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar

MatteoJoliveau avatar Oct 08 '19 09:10 MatteoJoliveau

It's look like TypeORM support everything. So the only line you need to change is: https://github.com/ever-co/ever-traduora/blob/2f61214264170f76fe8649920c2e87278f4cf3cf/api/src/config.ts#L50 with a new environment variable.

azlux avatar Mar 01 '22 16:03 azlux

@rahul-rathore-576 please see if we can copy the logic of configurations for DB from our other projects (e.g. https://github.com/ever-co/ever-gauzy) to Traduora as seems it's interesting for multiple customers. Please also make sure all works well with PostgreSQL and SQLite.

evereq avatar Mar 01 '22 16:03 evereq

The merged PR does not fully fix this issue in my eyes as trying to run the application with postgres as DB_TYPE results in DriverPackageNotInstalledError: Postgres package has not been found installed. Try to install it: npm install pg --save

peh avatar Feb 17 '23 12:02 peh

Data type "binary" in "User.encryptedPassword" is not supported by "postgres" database.

this is far as I come...

peh avatar Feb 17 '23 13:02 peh

this is far as I come...

I also stopped here. I guess it would be possible to use postgres 'bytea' column type instead of 'binary' but that would require to change the column type based on which DB is used.

oldluke92 avatar Mar 15 '23 07:03 oldluke92

I went ahead and replaced "binary" with "bytea". Next stop is migrations

Migration "addLocales1537531930470" failed, error: syntax error at or near "`"
/opt/traduora/node_modules/typeorm/error/TypeORMError.js:9
        var _this = _super.call(this, message) || this;
                           ^

QueryFailedError: syntax error at or near "`"
    at QueryFailedError.TypeORMError [as constructor] (/opt/traduora/node_modules/typeorm/error/TypeORMError.js:9:28)
    at new QueryFailedError (/opt/traduora/node_modules/typeorm/error/QueryFailedError.js:13:28)
    at PostgresQueryRunner.<anonymous> (/opt/traduora/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:281:31)
    at step (/opt/traduora/node_modules/typeorm/node_modules/tslib/tslib.js:143:27)
    at Object.throw (/opt/traduora/node_modules/typeorm/node_modules/tslib/tslib.js:124:57)
    at rejected (/opt/traduora/node_modules/typeorm/node_modules/tslib/tslib.js:115:69)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  query: 'CREATE TABLE IF NOT EXISTS `locale` (`code` varchar(255) NOT NULL, `language` varchar(255) NOT NULL, `region` varchar(255) NOT NULL, `dateCreated` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), `dateModified` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), PRIMARY KEY (`code`)) ENGINE=InnoDB',

Giving up for now.

oldluke92 avatar Mar 16 '23 15:03 oldluke92

The merged PR does not fully fix this issue in my eyes as trying to run the application with postgres as DB_TYPE results in DriverPackageNotInstalledError: Postgres package has not been found installed. Try to install it: npm install pg --save

How did you fix this?

csampaio26 avatar Sep 01 '23 09:09 csampaio26

Hey there, as my pevious comments show - not at all really. I built a new docker that has the pg package installed aswell as some db type replacements in the code. Did not invest too much time and therefor did not get it running with postgres anyways. I spun up a seperate mysql instance instead.

oldluke92 avatar Sep 01 '23 10:09 oldluke92

@csampaio26 / @oldluke92 not sure you saw, we have PR https://github.com/ever-co/ever-traduora/pull/391 by @vvadymk, however it's not yet finalized.

evereq avatar Sep 01 '23 19:09 evereq

@csampaio26 / @oldluke92 not sure you saw, we have PR #391 by @vvadymk, however it's not yet finalized.

Yes, it is still in progress.

vvadymk avatar Sep 01 '23 19:09 vvadymk