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.

- added training modules to paths (#549)

Gaurav Bhatt9fe68b62ffb0
diff --git a/apps/erp/app/components/TrainingPanel.tsx b/apps/erp/app/components/TrainingPanel.tsx
new file mode 100644
index 0000000000..e8b5281ae6
--- /dev/null
+++ b/apps/erp/app/components/TrainingPanel.tsx
@@ -0,0 +1,87 @@
+import { Button, IconButton } from "@carbon/react";
+import { AnimatePresence, motion } from "framer-motion";
+import { LuExternalLink, LuX } from "react-icons/lu";
+import type { TrainingVideo } from "~/utils/training";
+import { getVideoEmbedUrl } from "~/utils/training";
+
+type TrainingPanelProps = {
+ training: TrainingVideo | null;
+ isOpen: boolean;
+ onDismiss: () => void;
+};
+
+export default function TrainingPanel({
+ training,
+ isOpen,
+ onDismiss
+}: TrainingPanelProps) {
+ if (!training) return null;
+
+ const embedUrl = getVideoEmbedUrl(training.videoUrl, training.videoType);
+
+ return (
+ <AnimatePresence mode="wait">
+ {isOpen && (
+ <motion.div
+ key={training.title}
+ initial={{ opacity: 0, y: 20, scale: 0.95, filter: "blur(4px)" }}
+ animate={{ opacity: 1, y: 0, scale: 1, filter: "blur(0px)" }}
+ exit={{ opacity: 0, y: 10, scale: 0.95, filter: "blur(4px)" }}
+ transition={{ duration: 0.3, ease: "easeOut" }}
+ className="fixed bottom-4 right-4 w-[380px] rounded-xl border bg-background shadow-lg z-40 overflow-hidden"
+ >
+ <div className="relative aspect-video w-full bg-muted">
+ <iframe
+ src={embedUrl}
+ title={training.title}
+ className="w-full h-full"
+ allowFullScreen
+ allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
+ />
+ <div className="absolute inset-x-0 bottom-0 h-16 bg-gradient-to-t from-background to-transparent pointer-events-none" />
+ <IconButton
+ aria-label="Close"
+ icon={<LuX />}
+ variant="ghost"
+ size="sm"
+ className="absolute top-2 right-2 bg-background/80 backdrop-blur-sm hover:bg-background"
+ onClick={onDismiss}
+ />
+ </div>
+
+ <div className="px-4 pt-3.5 pb-5 space-y-1">
+ <h3 className="text-sm font-semibold tracking-tight">
+ {training.title}
+ </h3>
+ <p className="text-xs text-muted-foreground">
+ {training.description}
+ </p>
+ </div>
+
+ <div className="px-4 pb-3.5 flex items-center justify-end gap-2">
+ <Button variant="secondary" size="sm" onClick={onDismiss}>
+ Dismiss
+ </Button>
+ {training.academyUrl ? (
+ <Button
+ size="sm"
+ rightIcon={<LuExternalLink />}
+ onClick={() => window.open(training.academyUrl, "_blank")}
+ >
+ View in Academy
+ </Button>
+ ) : (
+ <Button
+ size="sm"
+ rightIcon={<LuExternalLink />}
+ onClick={() => window.open(training.videoUrl, "_blank")}
+ >
+ Watch full video
+ </Button>
+ )}
+ </div>
+ </motion.div>
+ )}
+ </AnimatePresence>
+ );
+}
diff --git a/apps/erp/app/hooks/index.ts b/apps/erp/app/hooks/index.ts
index 471fac2692..bd067045dc 100644
--- a/apps/erp/app/hooks/index.ts
+++ b/apps/erp/app/hooks/index.ts
@@ -17,6 +17,7 @@ import { usePermissions } from "./usePermissions";
import { useRealtime } from "./useRealtime";
import { useScrollPosition } from "./useScrollPosition";
import { useSettings } from "./useSettings";
+import { useTrainingPanel } from "./useTrainingPanel";
import { useUser } from "./useUser";
export {
@@ -35,6 +36,7 @@ export {
useRouteData,
useScrollPosition,
useSettings,
+ useTrainingPanel,
useUrlParams,
useUser
};
diff --git a/apps/erp/app/hooks/useTrainingPanel.ts b/apps/erp/app/hooks/useTrainingPanel.ts
new file mode 100644
index 0000000000..7228c5bc19
--- /dev/null
+++ b/apps/erp/app/hooks/useTrainingPanel.ts
@@ -0,0 +1,43 @@
+import { useMemo } from "react";
+import { useFetcher, useLocation } from "react-router";
+import { path } from "~/utils/path";
+import { getTrainingForPath, getTrainingKey } from "~/utils/training";
+import { useUser } from "./useUser";
+
+const FLAG_PREFIX = "training:";
+
+export function useTrainingPanel() {
+ const { pathname } = useLocation();
+ const { flags } = useUser();
+ const fetcher = useFetcher({ key: "training-dismiss" });
+
+ const training = useMemo(() => getTrainingForPath(pathname), [pathname]);
+ const trainingKey = useMemo(() => getTrainingKey(pathname), [pathname]);
+
+ const flagKey = trainingKey ? `${FLAG_PREFIX}${trainingKey}` : null;
+
+ // Optimistic: check if there's a pending dismiss for THIS flag
+ const pendingDismissFlag = fetcher.formData?.get("flag") as string | null;
+ const isPendingDismiss = pendingDismissFlag === flagKey;
+
+ const isDismissed = flagKey
+ ? isPendingDismiss || flags[flagKey] === true
+ : false;
+
+ const isOpen = !!training && !!flagKey && !isDismissed;
+
+ const dismiss = () => {
+ if (!flagKey) return;
+ fetcher.submit(
+ { intent: "flag", flag: flagKey, value: "true" },
+ { method: "POST", action: path.to.acknowledge }
+ );
+ };
+
+ return {
+ isOpen,
+ training,
+ hasTraining: training !== null,
+ dismiss
+ };
+}
diff --git a/apps/erp/app/hooks/useUser.tsx b/apps/erp/app/hooks/useUser.tsx
index 6fb3e1e081..68cec331c9 100644
--- a/apps/erp/app/hooks/useUser.tsx
+++ b/apps/erp/app/hooks/useUser.tsx
@@ -28,10 +28,13 @@ type Defaults = {
locationId: string | null;
};
+type UserFlags = Record<string, boolean>;
+
type User = PersonalData & {
company: Company;
groups: Groups;
defaults: Defaults;
+ flags: UserFlags;
};
export function useUser(): User {
@@ -55,7 +58,8 @@ export function useUser(): User {
...data.user,
company: data.company,
groups: data.groups,
- defaults: data.defaults ?? { locationId: null }
+ defaults: data.defaults ?? { locationId: null },
+ flags: data.user.flags ?? {}
};
}
diff --git a/apps/erp/app/modules/users/users.models.ts b/apps/erp/app/modules/users/users.models.ts
index 24723b4685..7dba89fe64 100644
--- a/apps/erp/app/modules/users/users.models.ts
+++ b/apps/erp/app/modules/users/users.models.ts
@@ -96,3 +96,27 @@ export const userPermissionsValidator = z.object({
update: z.boolean(),
delete: z.boolean()
});
+
+export const validUserFlags = [
+ "academy",
+ "training:quotes",
+ "training:salesOrders",
+ "training:salesInvoices",
+ "training:jobs",
+ "training:suppliers",
+ "training:purchaseOrders",
+ "training:parts",
+ "training:inventory",
+ "training:quality"
+] as const;
+
+export type UserFlagKey = (typeof validUserFlags)[number];
+
+const userFlagKeyValidator = z.enum(validUserFlags);
+
+export const userFlagValidator = z.object({
+ flag: userFlagKeyValidator,
+ value: z.boolean()
+});
+
+export const userFlagsValidator = z.record(userFlagKeyValidator, z.boolean());
diff --git a/apps/erp/app/routes/x+/_layout.tsx b/apps/erp/app/routes/x+/_layout.tsx
index 6209997263..66c04b91c1 100644
--- a/apps/erp/app/routes/x+/_layout.tsx
+++ b/apps/erp/app/routes/x+/_layout.tsx
@@ -29,6 +29,8 @@ import {
} from "react-router";
import { RealtimeDataProvider } from "~/components";
import { PrimaryNavigation, Topbar } from "~/components/Layout";
+import TrainingPanel from "~/components/TrainingPanel";
+import { useTrainingPanel } from "~/hooks/useTrainingPanel";
import {
getCompanies,
getCompanyIntegrations,
@@ -150,6 +152,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
export default function AuthenticatedRoute() {
const { session, user } = useLoaderData<typeof loader>();
const navigate = useNavigate();
+ const { isOpen, training, dismiss } = useTrainingPanel();
useNProgress();
useKeyboardWedge({
@@ -193,6 +196,11 @@ export default function AuthenticatedRoute() {
</main>
</div>
</div>
+ <TrainingPanel
+ training={training}
+ isOpen={isOpen}
+ onDismiss={dismiss}
+ />
</TooltipProvider>
</RealtimeDataProvider>
</CarbonProvider>
diff --git a/apps/erp/app/routes/x+/acknowledge.tsx b/apps/erp/app/routes/x+/acknowledge.tsx
index 7961c95826..3a5c71bacf 100644
--- a/apps/erp/app/routes/x+/acknowledge.tsx
+++ b/apps/erp/app/routes/x+/acknowledge.tsx
@@ -1,6 +1,7 @@
import { requirePermissions } from "@carbon/auth/auth.server";
import type { ActionFunctionArgs } from "react-router";
import { redirect } from "react-router";
+import { userFlagValidator } from "~/modules/users";
export async function action({ request }: ActionFunctionArgs) {
const { client, userId } = await requirePermissions(request, {});
@@ -9,21 +10,7 @@ export async function action({ request }: ActionFunctionArgs) {
const intent = formData.get("intent") as string;
const redirectTo = formData.get("redirectTo") as string | null;
- if (intent === "academy") {
- await client
- .from("user")
- .update({
- acknowledgedUniversity: true
- })
- .eq("id", userId);
-
- if (redirectTo) {
- throw redirect(redirectTo);
- }
-
- return { success: true, message: "University acknowledged" };
- }
-
+ // Keep ITAR handling unchanged — compliance blocker
if (intent === "itar") {
const updateResult = await client
.from("user")
@@ -41,4 +28,42 @@ export async function action({ request }: ActionFunctionArgs) {
return { success: true, message: "ITAR acknowledged" };
}
+
+ // Generic flag handling — covers training dismissals and any future flags
+ if (intent === "flag") {
+ const parsed = userFlagValidator.safeParse({
+ flag: formData.get("flag"),
+ value: formData.get("value") === "true"
+ });
+
+ if (!parsed.success) {
+ return { success: false, message: parsed.error.issues[0].message };
+ }
+
+ const { flag, value } = parsed.data;
+
+ const { data: user } = await client
+ .from("user")
+ .select("flags")
+ .eq("id", userId)
+ .single();
+
+ const currentFlags = (user?.flags as Record<string, boolean> | null) ?? {};
+ const updatedFlags = { ...currentFlags, [flag]: value };
+
+ const updateResult = await client
+ .from("user")
+ .update({ flags: updatedFlags })
+ .eq("id", userId);
+
+ if (updateResult.error) {
+ return { success: false, message: "Failed to update flag" };
+ }
+
+ if (redirectTo) {
+ throw redirect(redirectTo);
+ }
+
+ return { success: true, message: "Flag updated" };
+ }
}
diff --git a/apps/erp/app/utils/training.ts b/apps/erp/app/utils/training.ts
new file mode 100644
index 0000000000..01b0ccec71
--- /dev/null
+++ b/apps/erp/app/utils/training.ts
@@ -0,0 +1,175 @@
+export type VideoType = "loom" | "youtube";
+
+export type TrainingVideo = {
+ title: string;
+ description: string;
+ videoUrl: string;
+ videoType: VideoType;
+ academyUrl?: string;
+};
+
+/**
+ * Central training config: submodule key → video data.
+ * This is the ONLY place you need to edit to add/change training content.
+ */
+export const trainingConfig: Record<string, TrainingVideo> = {
+ quotes: {
+ title: "Quotes in Carbon",
+ description:
+ "Learn how to record and manage quotes from customers in Carbon.",
+ videoUrl:
+ "https://www.loom.com/share/881c83e9df8044db848aee8c2ea782bd?sid=f4ca14ef-bc59-4a8f-94a6-d6e120ee3bb3",
+ videoType: "loom",
+ academyUrl: "https://learn.carbon.ms/course/selling/quoting-estimating"
+ },
+ salesOrders: {
+ title: "Sales Orders in Carbon",
+ description: "Learn how to create and manage sales orders in Carbon.",
+ videoUrl:
+ "https://www.loom.com/share/c5fa13046aaa445a99c43c24434ff2b0?sid=21e5dcc9-cc76-4098-b97e-069212095616",
+ videoType: "loom",
+ academyUrl: "https://learn.carbon.ms/course/selling/sales-shipment"
+ },
+ salesInvoices: {
+ title: "Sales Invoices in Carbon",
+ description: "Master the creation and management of sales invoices.",
+ videoUrl:
+ "https://www.loom.com/share/45713271bd444f939dcde717ca720faa?sid=9c45d855-b6fe-4b27-99f9-c019dc28d386",
+ videoType: "loom",
+ academyUrl: "https://learn.carbon.ms/course/selling/sales-shipment"
+ },
+ jobs: {
+ title: "Production Jobs in Carbon",
+ description:
+ "Learn the fundamentals of job management and how jobs drive production in Carbon.",
+ videoUrl:
+ "https://www.loom.com/share/ad79b6a529fb43ff864f4908eeaf1511?sid=2a041ddf-50be-4e13-9885-694c253af623",
+ videoType: "loom",
+ academyUrl:
+ "https://learn.carbon.ms/course/manufacturing/managing-production"
+ },
+ suppliers: {
+ title: "Purchasing in Carbon",
+ description:
+ "Learn about the complete purchasing process from supplier selection to payment.",
+ videoUrl:
+ "https://www.loom.com/share/51e0c6dd053b4a3e904fc795d4fc298f?sid=0bb2081d-6bc4-4efb-8361-d2717dda9781",
+ videoType: "loom",
+ academyUrl: "https://learn.carbon.ms/course/buying/purchasing-basics"
+ },
+ purchaseOrders: {
+ title: "Purchase Orders in Carbon",
+ description: "Learn how to create and manage purchase orders effectively.",
+ videoUrl:
+ "https://www.loom.com/share/51e0c6dd053b4a3e904fc795d4fc298f?sid=0bb2081d-6bc4-4efb-8361-d2717dda9781",
+ videoType: "loom",
+ academyUrl: "https://learn.carbon.ms/course/buying/purchasing-basics"
+ },
+ parts: {
+ title: "Parts & Materials in Carbon",
+ description:
+ "Learn the differences between item types and when to use each one in your business processes.",
+ videoUrl:
+ "https://www.loom.com/share/acad6206adde4d1185e83f57393f36e9?sid=3cec60b1-91e3-454b-a6dd-f08fe1035ef2",
+ videoType: "loom",
+ academyUrl: "https://learn.carbon.ms/course/parts-materials/defining-item"
+ },
+ inventory: {
+ title: "Inventory in Carbon",
+ description:
+ "Learn how to monitor and manage inventory levels, set reorder points, and handle stock movements.",
+ videoUrl:
+ "https://www.loom.com/share/66045f3ef31c4d93b734fad7df0006dc?sid=5f896ab7-1765-411c-afd2-c320a4df18a7",
+ videoType: "loom",
+ academyUrl:
+ "https://learn.carbon.ms/course/parts-materials/replenishing-item"
+ },
+ quality: {
+ title: "Quality in Carbon",
+ description:
+ "Learn how to track and manage non-conforming materials and quality issues.",
+ videoUrl:
+ "https://www.loom.com/share/51e0c6dd053b4a3e904fc795d4fc298f?sid=0bb2081d-6bc4-4efb-8361-d2717dda9781",
+ videoType: "loom",
+ academyUrl: "https://learn.carbon.ms/course/quality/tracking-quality"
+ }
+};
+
+/**
+ * Maps pathname prefixes → submodule keys.
+ * Each submodule can have multiple prefixes (list page + detail page).
+ */
+const routeToSubmodule: Array<{ prefixes: string[]; key: string }> = [
+ { prefixes: ["/x/sales/quotes", "/x/quote/"], key: "quotes" },
+ { prefixes: ["/x/sales/orders", "/x/sales-order/"], key: "salesOrders" },
+ {
+ prefixes: ["/x/sales/invoices", "/x/sales-invoice/"],
+ key: "salesInvoices"
+ },
+ { prefixes: ["/x/production/jobs", "/x/job/"], key: "jobs" },
+ {
+ prefixes: ["/x/purchasing/suppliers", "/x/supplier/"],
+ key: "suppliers"
+ },
+ {
+ prefixes: ["/x/purchasing/orders", "/x/purchase-order/"],
+ key: "purchaseOrders"
+ },
+ { prefixes: ["/x/items/parts", "/x/part/"], key: "parts" },
+ {
+ prefixes: [
+ "/x/inventory/receipts",
+ "/x/inventory/shipments",
+ "/x/inventory/inventory",
+ "/x/inventory/stock-transfers",
+ "/x/receipt/",
+ "/x/shipment/",
+ "/x/stock-transfer/"
+ ],
+ key: "inventory"
+ },
+ {
+ prefixes: ["/x/quality/issues", "/x/quality/actions", "/x/issue/"],
+ key: "quality"
+ }
+];
+
+/** Resolves current pathname to a TrainingVideo (or null). */
+export function getTrainingForPath(pathname: string): TrainingVideo | null {
+ for (const { prefixes, key } of routeToSubmodule) {
+ if (prefixes.some((p) => pathname.startsWith(p))) {
+ return trainingConfig[key] ?? null;
+ }
+ }
+ return null;
+}
+
+/** Returns submodule key for localStorage dismiss tracking. */
+export function getTrainingKey(pathname: string): string | null {
+ for (const { prefixes, key } of routeToSubmodule) {
+ if (prefixes.some((p) => pathname.startsWith(p))) {
+ return key;
+ }
+ }
+ return null;
+}
+
+/** Converts a share URL to an embeddable iframe URL. */
+export function getVideoEmbedUrl(
+ videoUrl: string,
+ videoType: VideoType
+): string {
+ if (videoType === "loom") {
+ const match = videoUrl.match(/loom\.com\/share\/([a-zA-Z0-9]+)/);
+ return match
+ ? `https://www.loom.com/embed/${match[1]}?hideEmbedTopBar=true`
+ : videoUrl;
+ }
+ if (videoType === "youtube") {
+ const match = videoUrl.match(
+ /(?:youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9_-]+)/
+ );
+ return match ? `https://www.youtube.com/embed/${match[1]}` : videoUrl;
+ }
+ return videoUrl;
+}
diff --git a/packages/database/src/swagger-docs-schema.ts b/packages/database/src/swagger-docs-schema.ts
index 8701fdedcb..34612031dc 100644
--- a/packages/database/src/swagger-docs-schema.ts
+++ b/packages/database/src/swagger-docs-schema.ts
@@ -10861,7 +10861,7 @@ export default {
$ref: "#/parameters/rowFilter.issues.items",
},
{
- $ref: "#/parameters/rowFilter.issues.ContainmentStatus",
+ $ref: "#/parameters/rowFilter.issues.containmentStatus",
},
{
$ref: "#/parameters/select",
@@ -50053,10 +50053,10 @@ export default {
$ref: "#/parameters/rowFilter.user.admin",
},
{
- $ref: "#/parameters/rowFilter.user.acknowledgedUniversity",
+ $ref: "#/parameters/rowFilter.user.acknowledgedITAR",
},
{
- $ref: "#/parameters/rowFilter.user.acknowledgedITAR",
+ $ref: "#/parameters/rowFilter.user.flags",
},
{
$ref: "#/parameters/select",
@@ -50154,10 +50154,10 @@ export default {
$ref: "#/parameters/rowFilter.user.admin",
},
{
- $ref: "#/parameters/rowFilter.user.acknowledgedUniversity",
+ $ref: "#/parameters/rowFilter.user.acknowledgedITAR",
},
{
- $ref: "#/parameters/rowFilter.user.acknowledgedITAR",
+ $ref: "#/parameters/rowFilter.user.flags",
},
{
$ref: "#/parameters/preferReturn",
@@ -50209,10 +50209,10 @@ export default {
$ref: "#/parameters/rowFilter.user.admin",
},
{
- $ref: "#/parameters/rowFilter.user.acknowledgedUniversity",
+ $ref: "#/parameters/rowFilter.user.acknowledgedITAR",
},
{
- $ref: "#/parameters/rowFilter.user.acknowledgedITAR",
+ $ref: "#/parameters/rowFilter.user.flags",
},
{
$ref: "#/parameters/body.user",
@@ -74431,7 +74431,7 @@ export default {
},
type: "array",
},
- ContainmentStatus: {
+ containmentStatus: {
format: "text",
type: "string",
},
@@ -92913,8 +92913,8 @@ export default {
"lastName",
"about",
"createdAt",
- "acknowledgedUniversity",
"acknowledgedITAR",
+ "flags",
],
properties: {
id: {
@@ -92973,16 +92973,14 @@ export default {
format: "boolean",
type: "boolean",
},
- acknowledgedUniversity: {
- default: false,
- format: "boolean",
- type: "boolean",
- },
acknowledgedITAR: {
default: false,
format: "boolean",
type: "boolean",
},
+ flags: {
+ format: "jsonb",
+ },
},
type: "object",
},
@@ -105619,8 +105617,8 @@ export default {
in: "query",
type: "string",
},
- "rowFilter.issues.ContainmentStatus": {
- name: "ContainmentStatus",
+ "rowFilter.issues.containmentStatus": {
+ name: "containmentStatus",
required: false,
in: "query",
type: "string",
@@ -126555,14 +126553,14 @@ export default {
in: "query",
type: "string",
},
- "rowFilter.user.acknowledgedUniversity": {
- name: "acknowledgedUniversity",
+ "rowFilter.user.acknowledgedITAR": {
+ name: "acknowledgedITAR",
required: false,
in: "query",
type: "string",
},
- "rowFilter.user.acknowledgedITAR": {
- name: "acknowledgedITAR",
+ "rowFilter.user.flags": {
+ name: "flags",
required: false,
in: "query",
type: "string",
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index 959f580980..9af29808d1 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -40401,7 +40401,6 @@ export type Database = {
Row: {
about: string
acknowledgedITAR: boolean
- acknowledgedUniversity: boolean
active: boolean | null
admin: boolean | null
avatarUrl: string | null
@@ -40409,6 +40408,7 @@ export type Database = {
developer: boolean | null
email: string
firstName: string
+ flags: Json
fullName: string | null
id: string
lastName: string
@@ -40417,7 +40417,6 @@ export type Database = {
Insert: {
about?: string
acknowledgedITAR?: boolean
- acknowledgedUniversity?: boolean
active?: boolean | null
admin?: boolean | null
avatarUrl?: string | null
@@ -40425,6 +40424,7 @@ export type Database = {
developer?: boolean | null
email: string
firstName?: string
+ flags?: Json
fullName?: string | null
id: string
lastName?: string
@@ -40433,7 +40433,6 @@ export type Database = {
Update: {
about?: string
acknowledgedITAR?: boolean
- acknowledgedUniversity?: boolean
active?: boolean | null
admin?: boolean | null
avatarUrl?: string | null
@@ -40441,6 +40440,7 @@ export type Database = {
developer?: boolean | null
email?: string
firstName?: string
+ flags?: Json
fullName?: string | null
id?: string
lastName?: string
@@ -44766,7 +44766,7 @@ export type Database = {
assignee: string | null
closeDate: string | null
companyId: string | null
- ContainmentStatus: string | null
+ containmentStatus: string | null
content: Json | null
createdAt: string | null
createdBy: string | null
@@ -49115,14 +49115,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["supplierCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["supplierCountryCode"]
+ 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 959f580980..9af29808d1 100644
--- a/packages/database/supabase/functions/lib/types.ts
+++ b/packages/database/supabase/functions/lib/types.ts
@@ -40401,7 +40401,6 @@ export type Database = {
Row: {
about: string
acknowledgedITAR: boolean
- acknowledgedUniversity: boolean
active: boolean | null
admin: boolean | null
avatarUrl: string | null
@@ -40409,6 +40408,7 @@ export type Database = {
developer: boolean | null
email: string
firstName: string
+ flags: Json
fullName: string | null
id: string
lastName: string
@@ -40417,7 +40417,6 @@ export type Database = {
Insert: {
about?: string
acknowledgedITAR?: boolean
- acknowledgedUniversity?: boolean
active?: boolean | null
admin?: boolean | null
avatarUrl?: string | null
@@ -40425,6 +40424,7 @@ export type Database = {
developer?: boolean | null
email: string
firstName?: string
+ flags?: Json
fullName?: string | null
id: string
lastName?: string
@@ -40433,7 +40433,6 @@ export type Database = {
Update: {
about?: string
acknowledgedITAR?: boolean
- acknowledgedUniversity?: boolean
active?: boolean | null
admin?: boolean | null
avatarUrl?: string | null
@@ -40441,6 +40440,7 @@ export type Database = {
developer?: boolean | null
email?: string
firstName?: string
+ flags?: Json
fullName?: string | null
id?: string
lastName?: string
@@ -44766,7 +44766,7 @@ export type Database = {
assignee: string | null
closeDate: string | null
companyId: string | null
- ContainmentStatus: string | null
+ containmentStatus: string | null
content: Json | null
createdAt: string | null
createdBy: string | null
@@ -49115,14 +49115,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["supplierCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["supplierCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
diff --git a/packages/database/supabase/migrations/20260203120000_user-flags.sql b/packages/database/supabase/migrations/20260203120000_user-flags.sql
new file mode 100644
index 0000000000..74af18e7a8
--- /dev/null
+++ b/packages/database/supabase/migrations/20260203120000_user-flags.sql
@@ -0,0 +1,10 @@
+-- Add a JSONB flags column to the user table for extensible boolean preferences
+ALTER TABLE "user" ADD COLUMN "flags" JSONB NOT NULL DEFAULT '{}';
+
+-- Migrate existing acknowledgedUniversity into the new flags column
+UPDATE "user"
+SET "flags" = jsonb_set("flags", '{academy}', 'true')
+WHERE "acknowledgedUniversity" = true;
+
+-- Drop the legacy column now that data lives in flags
+ALTER TABLE "user" DROP COLUMN "acknowledgedUniversity";