Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

fix: migration for gauge claibration status

Brad Barbin7468d3e55daa
diff --git a/packages/database/src/swagger-docs-schema.ts b/packages/database/src/swagger-docs-schema.ts
index 210d25f4da..6fa1cd42e0 100644
--- a/packages/database/src/swagger-docs-schema.ts
+++ b/packages/database/src/swagger-docs-schema.ts
@@ -8691,6 +8691,9 @@ export default {
{
$ref: "#/parameters/rowFilter.gauges.updatedBy",
},
+ {
+ $ref: "#/parameters/rowFilter.gauges.lastCalibrationStatus",
+ },
{
$ref: "#/parameters/rowFilter.gauges.gaugeCalibrationStatusWithDueDate",
},
@@ -8819,6 +8822,9 @@ export default {
{
$ref: "#/parameters/rowFilter.gauges.updatedBy",
},
+ {
+ $ref: "#/parameters/rowFilter.gauges.lastCalibrationStatus",
+ },
{
$ref: "#/parameters/rowFilter.gauges.gaugeCalibrationStatusWithDueDate",
},
@@ -8901,6 +8907,9 @@ export default {
{
$ref: "#/parameters/rowFilter.gauges.updatedBy",
},
+ {
+ $ref: "#/parameters/rowFilter.gauges.lastCalibrationStatus",
+ },
{
$ref: "#/parameters/rowFilter.gauges.gaugeCalibrationStatusWithDueDate",
},
@@ -9072,6 +9081,18 @@ export default {
{
$ref: "#/parameters/rowFilter.gaugeCalibrationRecords.updatedBy",
},
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecords.supplierId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecords.temperature",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecords.humidity",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecords.approvedBy",
+ },
{
$ref: "#/parameters/rowFilter.gaugeCalibrationRecords.gaugeReadableId",
},
@@ -47076,6 +47097,18 @@ export default {
{
$ref: "#/parameters/rowFilter.gaugeCalibrationRecord.updatedBy",
},
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecord.supplierId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecord.temperature",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecord.humidity",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecord.approvedBy",
+ },
{
$ref: "#/parameters/select",
},
@@ -47177,6 +47210,18 @@ export default {
{
$ref: "#/parameters/rowFilter.gaugeCalibrationRecord.updatedBy",
},
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecord.supplierId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecord.temperature",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecord.humidity",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecord.approvedBy",
+ },
{
$ref: "#/parameters/preferReturn",
},
@@ -47232,6 +47277,18 @@ export default {
{
$ref: "#/parameters/rowFilter.gaugeCalibrationRecord.updatedBy",
},
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecord.supplierId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecord.temperature",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecord.humidity",
+ },
+ {
+ $ref: "#/parameters/rowFilter.gaugeCalibrationRecord.approvedBy",
+ },
{
$ref: "#/parameters/body.gaugeCalibrationRecord",
},
@@ -53067,6 +53124,9 @@ export default {
{
$ref: "#/parameters/rowFilter.gauge.updatedBy",
},
+ {
+ $ref: "#/parameters/rowFilter.gauge.lastCalibrationStatus",
+ },
{
$ref: "#/parameters/select",
},
@@ -53192,6 +53252,9 @@ export default {
{
$ref: "#/parameters/rowFilter.gauge.updatedBy",
},
+ {
+ $ref: "#/parameters/rowFilter.gauge.lastCalibrationStatus",
+ },
{
$ref: "#/parameters/preferReturn",
},
@@ -53271,6 +53334,9 @@ export default {
{
$ref: "#/parameters/rowFilter.gauge.updatedBy",
},
+ {
+ $ref: "#/parameters/rowFilter.gauge.lastCalibrationStatus",
+ },
{
$ref: "#/parameters/body.gauge",
},
@@ -53286,6 +53352,204 @@ export default {
tags: ["gauge"],
},
},
+ "/demandProjection": {
+ get: {
+ parameters: [
+ {
+ $ref: "#/parameters/rowFilter.demandProjection.itemId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.demandProjection.locationId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.demandProjection.periodId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.demandProjection.forecastQuantity",
+ },
+ {
+ $ref: "#/parameters/rowFilter.demandProjection.forecastMethod",
+ },
+ {
+ $ref: "#/parameters/rowFilter.demandProjection.confidence",
+ },
+ {
+ $ref: "#/parameters/rowFilter.demandProjection.notes",
+ },
+ {
+ $ref: "#/parameters/rowFilter.demandProjection.companyId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.demandProjection.createdBy",
+ },
+ {
+ $ref: "#/parameters/rowFilter.demandProjection.createdAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.demandProjection.updatedAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.demandProjection.updatedBy",
+ },
+ {
+ $ref: "#/parameters/select",
+ },
+ {
+ $ref: "#/parameters/order",
+ },
+ {
+ $ref: "#/parameters/range",
+ },
+ {
+ $ref: "#/parameters/rangeUnit",
+ },
+ {
+ $ref: "#/parameters/offset",
+ },
+ {
+ $ref: "#/parameters/limit",
+ },
+ {
+ $ref: "#/parameters/preferCount",
+ },
+ ],
+ responses: {
+ "200": {
+ description: "OK",
+ schema: {
+ items: {
+ $ref: "#/definitions/demandProjection",
+ },
+ type: "array",
+ },
+ },
+ "206": {
+ description: "Partial Content",
+ },
+ },
+ tags: ["demandProjection"],
+ },
+ post: {
+ parameters: [
+ {
+ $ref: "#/parameters/body.demandProjection",
+ },
+ {
+ $ref: "#/parameters/select",
+ },
+ {
+ $ref: "#/parameters/preferPost",
+ },
+ ],
+ responses: {
+ "201": {
+ description: "Created",
+ },
+ },
+ tags: ["demandProjection"],
+ },
+ delete: {
+ parameters: [
+ {
+ $ref: "#/parameters/rowFilter.demandProjection.itemId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.demandProjection.locationId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.demandProjection.periodId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.demandProjection.forecastQuantity",
+ },
+ {
+ $ref: "#/parameters/rowFilter.demandProjection.forecastMethod",
+ },
+ {
+ $ref: "#/parameters/rowFilter.demandProjection.confidence",
+ },
+ {
+ $ref: "#/parameters/rowFilter.demandProjection.notes",
+ },
+ {
+ $ref: "#/parameters/rowFilter.demandProjection.companyId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.demandProjection.createdBy",
+ },
+ {
+ $ref: "#/parameters/rowFilter.demandProjection.createdAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.demandProjection.updatedAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.demandProjection.updatedBy",
+ },
+ {
+ $ref: "#/parameters/preferReturn",
+ },
+ ],
+ responses: {
+ "204": {
+ description: "No Content",
+ },
+ },
+ tags: ["demandProjection"],
+ },
+ patch: {
+ parameters: [
+ {
+ $ref: "#/parameters/rowFilter.demandProjection.itemId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.demandProjection.locationId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.demandProjection.periodId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.demandProjection.forecastQuantity",
+ },
+ {
+ $ref: "#/parameters/rowFilter.demandProjection.forecastMethod",
+ },
+ {
+ $ref: "#/parameters/rowFilter.demandProjection.confidence",
+ },
+ {
+ $ref: "#/parameters/rowFilter.demandProjection.notes",
+ },
+ {
+ $ref: "#/parameters/rowFilter.demandProjection.companyId",
+ },
+ {
+ $ref: "#/parameters/rowFilter.demandProjection.createdBy",
+ },
+ {
+ $ref: "#/parameters/rowFilter.demandProjection.createdAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.demandProjection.updatedAt",
+ },
+ {
+ $ref: "#/parameters/rowFilter.demandProjection.updatedBy",
+ },
+ {
+ $ref: "#/parameters/body.demandProjection",
+ },
+ {
+ $ref: "#/parameters/preferReturn",
+ },
+ ],
+ responses: {
+ "204": {
+ description: "No Content",
+ },
+ },
+ tags: ["demandProjection"],
+ },
+ },
"/supplierProcess": {
get: {
parameters: [
@@ -55407,6 +55671,9 @@ export default {
{
$ref: "#/parameters/rowFilter.companySettings.kanbanOutput",
},
+ {
+ $ref: "#/parameters/rowFilter.companySettings.gaugeCalibrationExpiredNotificationGroup",
+ },
{
$ref: "#/parameters/select",
},
@@ -55502,6 +55769,9 @@ export default {
{
$ref: "#/parameters/rowFilter.companySettings.kanbanOutput",
},
+ {
+ $ref: "#/parameters/rowFilter.companySettings.gaugeCalibrationExpiredNotificationGroup",
+ },
{
$ref: "#/parameters/preferReturn",
},
@@ -55551,6 +55821,9 @@ export default {
{
$ref: "#/parameters/rowFilter.companySettings.kanbanOutput",
},
+ {
+ $ref: "#/parameters/rowFilter.companySettings.gaugeCalibrationExpiredNotificationGroup",
+ },
{
$ref: "#/parameters/body.companySettings",
},
@@ -65336,7 +65609,7 @@ export default {
properties: {
id: {
description:
- "Note:\nThis is a Primary Key.<pk/>\nThis is a Foreign Key to `supplierLocation.id`.<fk table='supplierLocation' column='id'/>",
+ "Note:\nThis is a Foreign Key to `supplierLocation.id`.<fk table='supplierLocation' column='id'/>",
format: "text",
type: "string",
},
@@ -65385,7 +65658,7 @@ export default {
},
supplierLocationId: {
description:
- "Note:\nThis is a Foreign Key to `supplierLocation.id`.<fk table='supplierLocation' column='id'/>",
+ "Note:\nThis is a Primary Key.<pk/>\nThis is a Foreign Key to `supplierLocation.id`.<fk table='supplierLocation' column='id'/>",
format: "text",
type: "string",
},
@@ -65784,6 +66057,11 @@ export default {
format: "text",
type: "string",
},
+ lastCalibrationStatus: {
+ enum: ["Pending", "In-Calibration", "Out-of-Calibration"],
+ format: 'public."gaugeCalibrationStatus"',
+ type: "string",
+ },
gaugeCalibrationStatusWithDueDate: {
enum: ["Pending", "In-Calibration", "Out-of-Calibration"],
format: 'public."gaugeCalibrationStatus"',
@@ -65873,6 +66151,26 @@ export default {
format: "text",
type: "string",
},
+ supplierId: {
+ description:
+ "Note:\nThis is a Foreign Key to `supplier.id`.<fk table='supplier' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ temperature: {
+ format: "real",
+ type: "number",
+ },
+ humidity: {
+ format: "real",
+ type: "number",
+ },
+ approvedBy: {
+ description:
+ "Note:\nThis is a Foreign Key to `user.id`.<fk table='user' column='id'/>",
+ format: "text",
+ type: "string",
+ },
gaugeReadableId: {
format: "text",
type: "string",
@@ -73535,6 +73833,8 @@ export default {
"Tool",
"Fixture",
"Consumable",
+ "Issue",
+ "Gauge Calibration Record",
],
format: 'public."documentSourceType"',
type: "string",
@@ -82886,6 +83186,8 @@ export default {
"Tool",
"Fixture",
"Consumable",
+ "Issue",
+ "Gauge Calibration Record",
],
format: 'public."documentSourceType"',
type: "string",
@@ -84041,6 +84343,26 @@ export default {
format: "text",
type: "string",
},
+ supplierId: {
+ description:
+ "Note:\nThis is a Foreign Key to `supplier.id`.<fk table='supplier' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ temperature: {
+ format: "real",
+ type: "number",
+ },
+ humidity: {
+ format: "real",
+ type: "number",
+ },
+ approvedBy: {
+ description:
+ "Note:\nThis is a Foreign Key to `user.id`.<fk table='user' column='id'/>",
+ format: "text",
+ type: "string",
+ },
},
type: "object",
},
@@ -86992,6 +87314,7 @@ export default {
"customFields",
"createdAt",
"createdBy",
+ "lastCalibrationStatus",
],
properties: {
id: {
@@ -87105,6 +87428,91 @@ export default {
format: "text",
type: "string",
},
+ lastCalibrationStatus: {
+ default: "Pending",
+ enum: ["Pending", "In-Calibration", "Out-of-Calibration"],
+ format: 'public."gaugeCalibrationStatus"',
+ type: "string",
+ },
+ },
+ type: "object",
+ },
+ demandProjection: {
+ required: [
+ "itemId",
+ "locationId",
+ "periodId",
+ "forecastQuantity",
+ "companyId",
+ "createdBy",
+ "createdAt",
+ "updatedAt",
+ "updatedBy",
+ ],
+ properties: {
+ itemId: {
+ description:
+ "Note:\nThis is a Primary Key.<pk/>\nThis is a Foreign Key to `item.id`.<fk table='item' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ locationId: {
+ description:
+ "Note:\nThis is a Primary Key.<pk/>\nThis is a Foreign Key to `location.id`.<fk table='location' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ periodId: {
+ description:
+ "Note:\nThis is a Primary Key.<pk/>\nThis is a Foreign Key to `period.id`.<fk table='period' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ forecastQuantity: {
+ default: 0,
+ format: "numeric",
+ type: "number",
+ },
+ forecastMethod: {
+ format: "text",
+ type: "string",
+ },
+ confidence: {
+ format: "numeric",
+ type: "number",
+ },
+ notes: {
+ format: "text",
+ type: "string",
+ },
+ companyId: {
+ description:
+ "Note:\nThis is a Foreign Key to `company.id`.<fk table='company' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ createdBy: {
+ description:
+ "Note:\nThis is a Foreign Key to `user.id`.<fk table='user' column='id'/>",
+ format: "text",
+ type: "string",
+ },
+ createdAt: {
+ default: "now()",
+ format: "timestamp with time zone",
+ type: "string",
+ },
+ updatedAt: {
+ default: "now()",
+ format: "timestamp with time zone",
+ type: "string",
+ },
+ updatedBy: {
+ description:
+ "Note:\nThis is a Foreign Key to `user.id`.<fk table='user' column='id'/>",
+ format: "text",
+ type: "string",
+ },
},
type: "object",
},
@@ -87985,6 +88393,7 @@ export default {
"materialGeneratedIds",
"useMetric",
"kanbanOutput",
+ "gaugeCalibrationExpiredNotificationGroup",
],
properties: {
id: {
@@ -88057,6 +88466,13 @@ export default {
format: 'public."kanbanOutput"',
type: "string",
},
+ gaugeCalibrationExpiredNotificationGroup: {
+ format: "text[]",
+ items: {
+ type: "string",
+ },
+ type: "array",
+ },
},
type: "object",
},
@@ -92954,6 +93370,12 @@ export default {
in: "query",
type: "string",
},
+ "rowFilter.gauges.lastCalibrationStatus": {
+ name: "lastCalibrationStatus",
+ required: false,
+ in: "query",
+ type: "string",
+ },
"rowFilter.gauges.gaugeCalibrationStatusWithDueDate": {
name: "gaugeCalibrationStatusWithDueDate",
required: false,
@@ -93074,6 +93496,30 @@ export default {
in: "query",
type: "string",
},
+ "rowFilter.gaugeCalibrationRecords.supplierId": {
+ name: "supplierId",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.gaugeCalibrationRecords.temperature": {
+ name: "temperature",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.gaugeCalibrationRecords.humidity": {
+ name: "humidity",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.gaugeCalibrationRecords.approvedBy": {
+ name: "approvedBy",
+ required: false,
+ in: "query",
+ type: "string",
+ },
"rowFilter.gaugeCalibrationRecords.gaugeReadableId": {
name: "gaugeReadableId",
required: false,
@@ -113570,6 +114016,30 @@ export default {
in: "query",
type: "string",
},
+ "rowFilter.gaugeCalibrationRecord.supplierId": {
+ name: "supplierId",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.gaugeCalibrationRecord.temperature": {
+ name: "temperature",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.gaugeCalibrationRecord.humidity": {
+ name: "humidity",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.gaugeCalibrationRecord.approvedBy": {
+ name: "approvedBy",
+ required: false,
+ in: "query",
+ type: "string",
+ },
"body.purchaseInvoicePaymentRelation": {
name: "purchaseInvoicePaymentRelation",
description: "purchaseInvoicePaymentRelation",
@@ -117056,6 +117526,93 @@ export default {
in: "query",
type: "string",
},
+ "rowFilter.gauge.lastCalibrationStatus": {
+ name: "lastCalibrationStatus",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "body.demandProjection": {
+ name: "demandProjection",
+ description: "demandProjection",
+ required: false,
+ in: "body",
+ schema: {
+ $ref: "#/definitions/demandProjection",
+ },
+ },
+ "rowFilter.demandProjection.itemId": {
+ name: "itemId",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.demandProjection.locationId": {
+ name: "locationId",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.demandProjection.periodId": {
+ name: "periodId",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.demandProjection.forecastQuantity": {
+ name: "forecastQuantity",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.demandProjection.forecastMethod": {
+ name: "forecastMethod",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.demandProjection.confidence": {
+ name: "confidence",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.demandProjection.notes": {
+ name: "notes",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.demandProjection.companyId": {
+ name: "companyId",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.demandProjection.createdBy": {
+ name: "createdBy",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.demandProjection.createdAt": {
+ name: "createdAt",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.demandProjection.updatedAt": {
+ name: "updatedAt",
+ required: false,
+ in: "query",
+ type: "string",
+ },
+ "rowFilter.demandProjection.updatedBy": {
+ name: "updatedBy",
+ required: false,
+ in: "query",
+ type: "string",
+ },
"body.supplierProcess": {
name: "supplierProcess",
description: "supplierProcess",
@@ -118067,6 +118624,12 @@ export default {
in: "query",
type: "string",
},
+ "rowFilter.companySettings.gaugeCalibrationExpiredNotificationGroup": {
+ name: "gaugeCalibrationExpiredNotificationGroup",
+ required: false,
+ in: "query",
+ type: "string",
+ },
"body.part": {
name: "part",
description: "part",
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index c7c4435f84..143d9a8672 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -38887,6 +38887,9 @@ export type Database = {
gaugeTypeId: string | null
id: string | null
lastCalibrationDate: string | null
+ lastCalibrationStatus:
+ | Database["public"]["Enums"]["gaugeCalibrationStatus"]
+ | null
locationId: string | null
modelNumber: string | null
nextCalibrationDate: string | null
@@ -38914,6 +38917,9 @@ export type Database = {
gaugeTypeId?: string | null
id?: string | null
lastCalibrationDate?: string | null
+ lastCalibrationStatus?:
+ | Database["public"]["Enums"]["gaugeCalibrationStatus"]
+ | null
locationId?: string | null
modelNumber?: string | null
nextCalibrationDate?: string | null
@@ -38941,6 +38947,9 @@ export type Database = {
gaugeTypeId?: string | null
id?: string | null
lastCalibrationDate?: string | null
+ lastCalibrationStatus?:
+ | Database["public"]["Enums"]["gaugeCalibrationStatus"]
+ | null
locationId?: string | null
modelNumber?: string | null
nextCalibrationDate?: string | null
@@ -41900,14 +41909,14 @@ export type Database = {
},
{
foreignKeyName: "partner_id_fkey"
- columns: ["id"]
+ columns: ["supplierLocationId"]
isOneToOne: false
referencedRelation: "supplierLocation"
referencedColumns: ["id"]
},
{
foreignKeyName: "partner_id_fkey"
- columns: ["supplierLocationId"]
+ columns: ["id"]
isOneToOne: false
referencedRelation: "supplierLocation"
referencedColumns: ["id"]
@@ -45790,14 +45799,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["invoiceCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["invoiceCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.ts
index c7c4435f84..143d9a8672 100644
--- a/packages/database/supabase/functions/lib/types.ts
+++ b/packages/database/supabase/functions/lib/types.ts
@@ -38887,6 +38887,9 @@ export type Database = {
gaugeTypeId: string | null
id: string | null
lastCalibrationDate: string | null
+ lastCalibrationStatus:
+ | Database["public"]["Enums"]["gaugeCalibrationStatus"]
+ | null
locationId: string | null
modelNumber: string | null
nextCalibrationDate: string | null
@@ -38914,6 +38917,9 @@ export type Database = {
gaugeTypeId?: string | null
id?: string | null
lastCalibrationDate?: string | null
+ lastCalibrationStatus?:
+ | Database["public"]["Enums"]["gaugeCalibrationStatus"]
+ | null
locationId?: string | null
modelNumber?: string | null
nextCalibrationDate?: string | null
@@ -38941,6 +38947,9 @@ export type Database = {
gaugeTypeId?: string | null
id?: string | null
lastCalibrationDate?: string | null
+ lastCalibrationStatus?:
+ | Database["public"]["Enums"]["gaugeCalibrationStatus"]
+ | null
locationId?: string | null
modelNumber?: string | null
nextCalibrationDate?: string | null
@@ -41900,14 +41909,14 @@ export type Database = {
},
{
foreignKeyName: "partner_id_fkey"
- columns: ["id"]
+ columns: ["supplierLocationId"]
isOneToOne: false
referencedRelation: "supplierLocation"
referencedColumns: ["id"]
},
{
foreignKeyName: "partner_id_fkey"
- columns: ["supplierLocationId"]
+ columns: ["id"]
isOneToOne: false
referencedRelation: "supplierLocation"
referencedColumns: ["id"]
@@ -45790,14 +45799,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["invoiceCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["invoiceCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
diff --git a/packages/database/supabase/migrations/20251022203418_gauge-calibration-record.sql b/packages/database/supabase/migrations/20251022203418_gauge-calibration-record.sql
index 8262f6ddf9..0a5140aac9 100644
--- a/packages/database/supabase/migrations/20251022203418_gauge-calibration-record.sql
+++ b/packages/database/supabase/migrations/20251022203418_gauge-calibration-record.sql
@@ -5,6 +5,7 @@ UPDATE "gauge" SET "lastCalibrationStatus" = "gaugeCalibrationStatus";
ALTER TABLE "companySettings" ADD COLUMN "gaugeCalibrationExpiredNotificationGroup" TEXT[] NOT NULL DEFAULT '{}';
-- Recreate the gauges view to include the new lastCalibrationStatus column
+DROP VIEW IF EXISTS "gauges";
CREATE OR REPLACE VIEW "gauges" WITH(SECURITY_INVOKER=true) AS
SELECT
g.*,
diff --git a/packages/jobs/trigger/cleanup.ts b/packages/jobs/trigger/cleanup.ts
index 0f61ba83cc..f7edaded76 100644
--- a/packages/jobs/trigger/cleanup.ts
+++ b/packages/jobs/trigger/cleanup.ts
@@ -138,9 +138,9 @@ export const cleanup = schedules.task({
// Check for gauges going out of calibration
console.log("Checking for gauges going out of calibration...");
const outOfCalibrationGauges = await serviceRole
- .from("gauge")
+ .from("gauges")
.select("*")
- .eq("gaugeCalibrationStatus", "Out-of-Calibration")
+ .eq("gaugeCalibrationStatusWithDueDate", "Out-of-Calibration")
.neq("lastCalibrationStatus", "Out-of-Calibration");
if (outOfCalibrationGauges.error) {