---
title: Forecast
slug: forecast
docTags: 
createdAt: 2024-09-20T18:57:02.074Z
---

The Forecast table stores internal/customer forecasts for a well, which can be compared against ProdX's PI-based forecasts in the application's variance reports.

Customer forecasts are not versioned in ProdX — at any point in time there is one customer forecast per well. The unique constraint on forecast entries is **uwi + date**.

:::hint{type="warning"}
**Replacing a forecast**

If a new version of a forecast uses the **same dates** as the old one, just push it — the upsert overwrites the existing records. If the dates **differ**, delete the well's old forecast first: otherwise the new points insert alongside the old ones and the well ends up with a mix of both forecasts.
:::

| **Variable** | **Data Type**   | **Unit of Measure** | **Is Nullable?** | **Default Value** | **Description**                                                                                           |
| ------------ | --------------- | ------------------- | ---------------- | ----------------- | --------------------------------------------------------------------------------------------------------- |
| uwi          | String          | -                   | No               | -                 | Unique Well Identifier. Must match the uwi of a record in the [Well](docId\:P-xHbe4jqKJQemay7aOL5) table. |
| date         | Datetime Offset | -                   | No               | -                 | Forecast date. Datetime offset (with timezone) in ISO 8601 format. Example: 2022-09-27T16:28:37+0000      |
| oilRate      | Double          | STB/d               | No               | -                 | Forecasted oil rate                                                                                       |
| gasRate      | Double          | Mscf/d              | No               | -                 | Forecasted gas rate                                                                                       |
| waterRate    | Double          | STB/d               | No               | -                 | Forecasted water rate                                                                                     |

***

# Data Integrity Checks

| **Condition**                        | **Response**    |
| ------------------------------------ | --------------- |
| uwi is NULL or empty                 | Record Rejected |
| uwi does not exist in the Well table | Record Rejected |
| Any non-nullable field is NULL       | Record Rejected |

***

# Common Error Messages

| **API**                 | **Scenario** | **Error Response**     |
| ----------------------- | ------------ | ---------------------- |
| Add / Upsert forecast   | Unknown UWI  | UWI xxx does not exist |
| Fetch / Delete forecast | Unknown UWI  | UWI xxx does not exist |
