Changeset b0685a8 for database


Ignore:
Timestamp:
01/23/26 18:27:06 (6 months ago)
Author:
Tome <gjorgievtome@…>
Branches:
main
Children:
ad211d1
Parents:
41a2f81
Message:

Allow adding multiple components per build

Location:
database
Files:
3 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • database/drizzle/queries/components.ts

    r41a2f81 rb0685a8  
    959959        if(!build || build.isApproved) return null;
    960960
    961         const existing = await tx
    962             .select()
    963             .from(buildComponentsTable)
    964             .where(
    965                 and(
    966                     eq(buildComponentsTable.buildId, buildId),
    967                     eq(buildComponentsTable.componentId, componentId)
    968                 )
    969             )
    970             .limit(1);
    971 
    972         if (existing.length) return null;
    973 
    974961        await tx
    975962            .insert(buildComponentsTable)
  • database/drizzle/schema/builds.ts

    r41a2f81 rb0685a8  
    1717
    1818export const buildComponentsTable = pgTable("build_component", {
     19        id: serial("id").primaryKey(),
    1920        buildId: integer("build_id")
    2021            .notNull()
     
    2425            .references(() => componentsTable.id, { onDelete: "cascade", onUpdate: "cascade" }),
    2526    },
    26     (t) => ({
    27         pk: primaryKey({ columns: [t.buildId, t.componentId] }),
    28     }),
    2927);
    3028
Note: See TracChangeset for help on using the changeset viewer.