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: revert lead time migration

Sidwebworks740b0caf26ee
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index 2f82a5f073..331e3f11ff 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -29319,7 +29319,6 @@ export type Database = {
Row: {
companyId: string
id: string
- leadTime: number | null
locationId: string | null
receiptRequestedDate: string | null
shippingCost: number | null
@@ -29331,7 +29330,6 @@ export type Database = {
Insert: {
companyId: string
id: string
- leadTime?: number | null
locationId?: string | null
receiptRequestedDate?: string | null
shippingCost?: number | null
@@ -29343,7 +29341,6 @@ export type Database = {
Update: {
companyId?: string
id?: string
- leadTime?: number | null
locationId?: string | null
receiptRequestedDate?: string | null
shippingCost?: number | null
@@ -32981,6 +32978,48 @@ export type Database = {
},
]
}
+ searchIndex_d62k69llq0m06f00o2q0: {
+ Row: {
+ createdAt: string
+ description: string | null
+ entityId: string
+ entityType: string
+ id: number
+ link: string
+ metadata: Json | null
+ searchVector: unknown
+ tags: string[] | null
+ title: string
+ updatedAt: string | null
+ }
+ Insert: {
+ createdAt?: string
+ description?: string | null
+ entityId: string
+ entityType: string
+ id?: number
+ link: string
+ metadata?: Json | null
+ searchVector?: unknown
+ tags?: string[] | null
+ title: string
+ updatedAt?: string | null
+ }
+ Update: {
+ createdAt?: string
+ description?: string | null
+ entityId?: string
+ entityType?: string
+ id?: number
+ link?: string
+ metadata?: Json | null
+ searchVector?: unknown
+ tags?: string[] | null
+ title?: string
+ updatedAt?: string | null
+ }
+ Relationships: []
+ }
searchIndexRegistry: {
Row: {
companyId: string
@@ -48680,14 +48719,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["supplierCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["supplierCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
@@ -50866,7 +50905,6 @@ export type Database = {
id: string | null
internalNotes: Json | null
itemType: Database["public"]["Enums"]["itemType"] | null
- leadTime: number | null
lines: number | null
locationId: string | null
locationName: string | null
@@ -51812,14 +51850,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"]
@@ -52362,14 +52400,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["paymentCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["paymentCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
diff --git a/packages/database/supabase/migrations/20260209163250_revert-quote-lead-time.sql b/packages/database/supabase/migrations/20260209163250_revert-quote-lead-time.sql
new file mode 100644
index 0000000000..b1ce8f59d1
--- /dev/null
+++ b/packages/database/supabase/migrations/20260209163250_revert-quote-lead-time.sql
@@ -0,0 +1,38 @@
+-- Revert leadTime changes from 20260206061346_quote-lead-time.sql
+
+-- Drop the view first since it depends on the leadTime column
+DROP VIEW IF EXISTS "quotes";
+
+-- Now drop the column
+ALTER TABLE "quoteShipment" DROP COLUMN IF EXISTS "leadTime";
+
+-- Recreate the view without leadTime
+CREATE OR REPLACE VIEW "quotes" WITH(SECURITY_INVOKER=true) AS
+ SELECT
+ q.*,
+ ql."thumbnailPath",
+ ql."itemType",
+ l."name" AS "locationName",
+ ql."lines",
+ ql."completedLines",
+ qs."shippingCost"
+ FROM "quote" q
+ LEFT JOIN (
+ SELECT
+ "quoteId",
+ COUNT("quoteLine"."id") FILTER (WHERE "quoteLine"."status" != 'No Quote') AS "lines",
+ COUNT("quoteLine"."id") FILTER (WHERE "quoteLine"."status" = 'Complete') AS "completedLines",
+ MIN(CASE
+ WHEN i."thumbnailPath" IS NULL AND mu."thumbnailPath" IS NOT NULL THEN mu."thumbnailPath"
+ ELSE i."thumbnailPath"
+ END) AS "thumbnailPath",
+ MIN(i."type") AS "itemType"
+ FROM "quoteLine"
+ INNER JOIN "item" i
+ ON i."id" = "quoteLine"."itemId"
+ LEFT JOIN "modelUpload" mu ON mu.id = i."modelUploadId"
+ GROUP BY "quoteId"
+ ) ql ON ql."quoteId" = q.id
+ LEFT JOIN "quoteShipment" qs ON qs."id" = q."id"
+ LEFT JOIN "location" l
+ ON l.id = q."locationId";