PG extensions and database credentials

Hello team, I have 2 questions: 1) I added generator client { provider = "prisma-client-js" previewFeatures = ["postgresqlExtensions"] } datasource db { provider = "postgresql" url = env("DATABASE_URL") extensions = [pgvector(map: "vector"), pgcrypto] } but there was an error: pgvector and pgcrypto do not exist in your server, make sure to run or add them before using them. 1) How can I add extensions like pgvector, pgcrypto, etc ? 2) Where can I get the database credentials ( Host, User, Password, Database name), since the URL does not have those?
2 Replies
Prisma AI Help
Prisma AI Helpā€¢3d ago
You selected the bot's instantaneous insights. Let me compile your answer right away! I'd be happy to help you with your questions about Prisma and PostgreSQL extensions. Let me address each of your questions: 1) To add PostgreSQL extensions like pgvector and pgcrypto in Prisma, you can use the postgresqlExtensions preview feature. Here's how you can do it: First, enable the preview feature in your schema.prisma file:
generator client {
provider = "prisma-client-js"
previewFeatures = ["postgresqlExtensions"]
}

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
extensions = [pgvector(map: "vector"), pgcrypto]
}
generator client {
provider = "prisma-client-js"
previewFeatures = ["postgresqlExtensions"]
}

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
extensions = [pgvector(map: "vector"), pgcrypto]
}
This example adds both pgvector and pgcrypto extensions. You can add or remove extensions as needed. After updating your schema, you can apply these changes to your database using Prisma Migrate:
npx prisma migrate dev --name add_extensions
npx prisma migrate dev --name add_extensions
For more detailed information, you can refer to the PostgreSQL extensions documentation. 2) Regarding database credentials, Prisma typically uses a connection URL stored in an environment variable. The connection URL contains all the necessary credentials. Here's an example of what it might look like:
DATABASE_URL="postgresql://USER:PASSWORD@HOST:PORT/DATABASE?schema=SCHEMA"
DATABASE_URL="postgresql://USER:PASSWORD@HOST:PORT/DATABASE?schema=SCHEMA"
You would replace USER, PASSWORD, HOST, PORT, DATABASE, and SCHEMA with your specific database details. If you're setting up a new project, you might define these credentials yourself. If you're working with an existing project, you should check the project's .env file or ask your team's database administrator for the correct credentials. For more information on connection URLs, you can refer to the Connection details documentation. Remember to keep your database credentials secure and never commit them to version control. šŸ¤” Alright, thanks for letting us know that there's still some help needed. A team member will reply to you shortly. In the meantime, please let us know any additional info, questions, or which parts of the answer may need clarification.
Nurul
Nurulā€¢20h ago
Hey šŸ‘‹ 1. Support for adding extensions like pgvector, pgcrypto is coming very soon. At the moment, it is not possible with Prisma Postgres. 2. Can you share your usecase for needing database credentials instead of API Key? Do you require it to connect to a database IDE?

Did you find this page helpful?