|
| 1 | +# First-Last-Agg |
| 2 | + |
| 3 | +[First-Last-Agg](https://github.com/wulczer/first_last_agg) is a simple |
| 4 | +extension providing two aggregate functions, last and first aggregate |
| 5 | +functions, operating on any element type and returning the last or the first |
| 6 | +value of the group. |
| 7 | + |
| 8 | +This image provides a convenient way to deploy and manage `first_last_agg` with |
| 9 | +[CloudNativePG](https://cloudnative-pg.io/). |
| 10 | + |
| 11 | +## Usage |
| 12 | + |
| 13 | +### 1. Add the first_last_agg extension image to your Cluster |
| 14 | + |
| 15 | +Define the `first_last_agg` extension under the `postgresql.extensions` section of |
| 16 | +your `Cluster` resource. For example: |
| 17 | + |
| 18 | +```yaml |
| 19 | +apiVersion: postgresql.cnpg.io/v1 |
| 20 | +kind: Cluster |
| 21 | +metadata: |
| 22 | + name: cluster-first-last-agg |
| 23 | +spec: |
| 24 | + imageName: ghcr.io/cloudnative-pg/postgresql:18-minimal-trixie |
| 25 | + instances: 1 |
| 26 | + |
| 27 | + storage: |
| 28 | + size: 1Gi |
| 29 | + |
| 30 | + postgresql: |
| 31 | + extensions: |
| 32 | + - name: first_last_agg |
| 33 | + image: |
| 34 | + # renovate: suite=trixie-pgdg depName=postgresql-18-first-last-agg |
| 35 | + reference: ghcr.io/cloudnative-pg/first-last-agg:0.8.2-18-trixie |
| 36 | +``` |
| 37 | +
|
| 38 | +### 2. Enable the extension in a database |
| 39 | +
|
| 40 | +You can install `first_last_agg` in a specific database by creating or updating a |
| 41 | +`Database` resource. For example, to enable it in the `app` database: |
| 42 | + |
| 43 | +```yaml |
| 44 | +apiVersion: postgresql.cnpg.io/v1 |
| 45 | +kind: Database |
| 46 | +metadata: |
| 47 | + name: cluster-first-last-agg-app |
| 48 | +spec: |
| 49 | + name: app |
| 50 | + owner: app |
| 51 | + cluster: |
| 52 | + name: cluster-first-last-agg |
| 53 | + extensions: |
| 54 | + - name: first_last_agg |
| 55 | + # renovate: suite=trixie-pgdg depName=postgresql-18-first-last-agg extractVersion=^(?<version>\d+\.\d+\.\d+) |
| 56 | + version: '0.8.2' |
| 57 | +``` |
| 58 | + |
| 59 | +### 3. Verify installation |
| 60 | + |
| 61 | +Once the database is ready, connect to it with `psql` and run: |
| 62 | + |
| 63 | +```sql |
| 64 | +\dx |
| 65 | +``` |
| 66 | + |
| 67 | +You should see `first_last_agg` listed among the installed extensions. |
0 commit comments