# @amplication/plugin-db-postgres

> Use a PostgreSQL database in a service generated by Amplication

Latest version **1.3.6** (published 2023-12-28) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @amplication/plugin-db-postgres
pnpm add @amplication/plugin-db-postgres
yarn add @amplication/plugin-db-postgres
bun add @amplication/plugin-db-postgres
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.6 |
| Published | 2023-12-28 |
| First published | 2022-09-17 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 74.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Amit Barletz |
| Maintainers | amplication-bot, mulygottlieb, levivannoort, overbit, barshimi, morhag, amitbarletz, yuvalhazaz |

## Links

- npm: https://www.npmjs.com/package/@amplication/plugin-db-postgres
- npm.io page: https://npm.io/package/@amplication/plugin-db-postgres

## Recent versions

- 1.3.6 (latest) — 2023-12-28
- 1.3.10-beta.pr-354.1e83d71 (beta) — 2024-03-12
- 1.3.10-beta.pr-354.31d30ce — 2024-03-12
- 1.3.9 — 2024-03-08
- 1.3.8 — 2024-03-08
- 1.3.7 — 2024-03-08
- 1.3.5 — 2023-12-28
- 1.3.4 — 2023-11-28
- 1.3.4-beta.pr-297.80f0b66 — 2023-11-28
- 1.3.3-beta.pr-295.e09faa7 — 2023-11-27
- 1.3.3-beta.pr-289.0d3954c — 2023-11-22
- 1.3.3 — 2023-08-15
- 1.3.2 — 2023-08-08
- 1.3.1 — 2023-06-18
- 1.3.1-beta.3 — 2023-06-18
- … 30 more at https://npm.io/package/@amplication/plugin-db-postgres/versions

## README

# @amplication/plugin-db-postgres

[![NPM Downloads](https://img.shields.io/npm/dt/@amplication/plugin-db-postgres)](https://www.npmjs.com/package/@amplication/plugin-db-postgres)

Use a PostgreSQL database in the service generated by Amplication.

> Note: this plugin is used by the code generation engine by default when no other DB plugin is installed.

## Purpose

This plugin adds the required code to use PostgreSQL database in the service generated by Amplication.
It updates the following parts:

- Updates the datasource on the `schema.prisma` file:
  - For versions older than `1.3.3` the datesource name is based on the database type
    - PostgreSQL - the datasource name is `postgresql`
  - From version `1.3.3` the datasource name is `db`, no matter what is the database type
- From version `1.3.3` as the datasouce name is `db`, all the custom attributes that use the `@{datasource.name}.{nameOfTheAttribute}` are replaced with `@db.{nameOfTheAttribute}`
- Adds the requires services and variables to `docker-compose.yml`
- Add the `db` service to the `docker-compose.dev.yml`
- Add the requires environment variables to `.env`

## Configuration

The plugin uses the parameters configured on the database tab on the service settings page

![image](https://user-images.githubusercontent.com/43705455/190962515-6ffc6751-71de-4acb-9a85-da9e7096f923.png)

## Usage

This plugin integrates with the all default tasks and scripts used by the generated service:

```json
    "seed": "ts-node scripts/seed.ts",
    "db:migrate-save": "prisma migrate dev",
    "db:migrate-up": "prisma migrate deploy",
    "db:clean": "ts-node scripts/clean.ts",
    "db:init": "run-s \"db:migrate-save -- --name 'initial version'\" db:migrate-up seed",
    "prisma:generate": "prisma generate",
    "docker:db": "docker-compose -f docker-compose.db.yml up -d",
    "docker:build": "docker build .",
    "compose:up": "docker-compose up -d",
    "compose:down": "docker-compose down --volumes"
```

---
_Source: https://npm.io/package/@amplication/plugin-db-postgres · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
