Skip to content

Add CustomApp types, the gc_custom_apps Drizzle schema, and its migration - #100

Merged
rudokemper merged 2 commits into
mainfrom
96/customapp-db-work
Aug 12, 2026
Merged

Add CustomApp types, the gc_custom_apps Drizzle schema, and its migration#100
rudokemper merged 2 commits into
mainfrom
96/customapp-db-work

Conversation

@rudokemper

Copy link
Copy Markdown
Member

Goal

Closes #96.

Screenshots

n/a

What I changed and why

  • Added gc_custom_apps Drizzle schema + migration.
  • Added shared CustomApp types/validation helpers and server list/replace utilities for the upcoming admin API and homepage grid.

How I convinced myself this is right

Plan validation, and following existing Drizzle / migration conventions.

What I'm not doing here

LLM use disclosure

Cursor Grok 4.5 implementation based on plan. I didn't spot anything that needed fixing.

@@ -0,0 +1,100 @@
import { asc, eq } from "drizzle-orm";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are importing just to export, not sure how I feel but maybe it's inevitable.

Comment thread server/utils/customApps.ts Outdated
Comment on lines +66 to +87
await configDb.transaction(async (tx) => {
await tx.delete(schema.gcCustomApps);

if (apps.length === 0) return;

await tx.insert(schema.gcCustomApps).values(
apps.map((app, index) => ({
id: app.id,
name: app.name,
description: app.description,
iconUrl: app.iconUrl,
tags: app.tags,
subdomain: app.subdomain,
enabled: app.enabled,
sortOrder: index,
createdAt: now,
updatedAt: now,
})),
);
});

return listCustomApps({ includeDisabled: true });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could simplify this slightly: Drizzle transactions can return a value, and Postgres supports .returning(), so we can return the transaction directly and map the inserted rows instead of doing a second listCustomApps() query afterward. See [Drizzle transactions](https://orm.drizzle.team/docs/transactions) and [Postgres returning](https://orm.drizzle.team/docs/insert#insert-returning).

So something like:

const rows = await tx
    .insert(schema.gcCustomApps)
    .values(
      apps.map((app, index) => ({
        id: app.id,
        name: app.name,
        description: app.description,
        iconUrl: app.iconUrl,
        tags: app.tags,
        subdomain: app.subdomain,
        enabled: app.enabled,
        sortOrder: index,
        createdAt: now,
        updatedAt: now,
      })),
    )
    .returning();

  return rows.map(mapCustomAppRow);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, agreed this is an improvement. Implemented in 3808078

@rudokemper
rudokemper merged commit 8fb70fe into main Aug 12, 2026
1 check passed
@rudokemper
rudokemper deleted the 96/customapp-db-work branch August 12, 2026 01:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Custom apps: Define CustomApp types, Drizzle schema, and migration for gc_custom_apps

2 participants