You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There should be an option to add additional postgres extensions when connecting to a database.
The Problem
We're using the tablefunc module in some of our view entities. Right now, we need to make sure the extension is installed when we create the database. It would be better if TypeORM could ensure the extension is created while it installs other extensions, such as uuid-ossp.
We could add a migration that runs this query, but this isn't compatible with development workflows using synchronize. It also feels slightly awkward. An ORM should manage the minutia of a database for us, which includes making sure the necessary features are enabled.
Additional Context
Relevant Database Driver(s)
aurora-data-api
aurora-data-api-pg
better-sqlite3
cockroachdb
cordova
expo
mongodb
mysql
nativescript
oracle
postgres
react-native
sap
sqlite
sqlite-abstract
sqljs
sqlserver
Are you willing to resolve this issue by submitting a Pull Request?
Yes, I have the time, and I know how to start.
Yes, I have the time, but I don't know how to start. I would need guidance.
No, I don't have the time, although I believe I could do it if I had the time...
No, I don't have the time and I wouldn't even know how to start.
(I'm a little stretched right now.)
Reacted by Alexandru Iaru, xEverth and Alessandro Raffa
I've worked around this by doing something like this when the DataSource gets created:
constextensions=['tablefunc'];// Whatever extensions you want to installconstdataSource=newDataSource(config);(dataSourceasany).__initialize=dataSource.initialize;dataSource.initialize=asyncfunction(){awaitthis.__initialize();for(constextensionofextensions){awaitthis.query(/*sql*/`CREATE EXTENSION IF NOT EXISTS ${extension}`);}returnthis;};dataSource.initialize.bind(dataSource);
A bit hacky, but it works until this feature is implemented.
Activity
strongpauly commentedon Jun 13, 2025
I've worked around this by doing something like this when the
DataSourcegets created:A bit hacky, but it works until this feature is implemented.