Ignore:
Timestamp:
12/20/25 00:55:47 (7 months ago)
Author:
Tome <gjorgievtome@…>
Branches:
main
Children:
b69759d
Parents:
c30935a
Message:

add schema and queries

File:
1 edited

Legend:

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

    rc30935a r1ebac59  
    5353});
    5454
    55 export const pcCaseTable = pgTable("pc_case", {
     55export const pcCasesTable = pgTable("pc_case", {
    5656    componentId: integer("component_id")
    5757        .primaryKey()
     
    6565        caseId: integer("case_id")
    6666            .notNull()
    67             .references(() => pcCaseTable.componentId, {onDelete: "cascade", onUpdate: "cascade" }),
     67            .references(() => pcCasesTable.componentId, {onDelete: "cascade", onUpdate: "cascade" }),
    6868        formFactor: text("form_factor").notNull(),
     69        num_slots: integer("num_slots").notNull(),
    6970    },
    7071    (t) => ({
     
    7677        caseId: integer("case_id")
    7778            .notNull()
    78             .references(() => pcCaseTable.componentId, { onDelete: "cascade", onUpdate: "cascade"}),
     79            .references(() => pcCasesTable.componentId, { onDelete: "cascade", onUpdate: "cascade"}),
    7980        formFactor: text("form_factor").notNull(),
    8081    },
     
    8788        caseId: integer("case_id")
    8889            .notNull()
    89             .references(() => pcCaseTable.componentId, { onDelete: "cascade", onUpdate: "cascade"}),
     90            .references(() => pcCasesTable.componentId, { onDelete: "cascade", onUpdate: "cascade"}),
    9091        formFactor: text("form_factor").notNull(),
    9192    },
     
    9596);
    9697
    97 export const coolerTable = pgTable("cooler", {
     98export const coolersTable = pgTable("cooler", {
    9899    componentId: integer("component_id")
    99100        .primaryKey()
     
    108109        cooler_id: integer("cooler_id")
    109110            .notNull()
    110             .references(() => coolerTable.componentId, { onDelete: "cascade", onUpdate: "cascade" }),
     111            .references(() => coolersTable.componentId, { onDelete: "cascade", onUpdate: "cascade" }),
    111112        socket: text("socket").notNull(),
    112113    },
     
    116117);
    117118
    118 export const motherboardTable = pgTable("motherboard", {
     119export const motherboardsTable = pgTable("motherboard", {
    119120    componentId: integer("component_id")
    120121        .primaryKey()
     
    139140
    140141// Other Components
    141 export const memoryCardTable = pgTable("memory_card", {
     142export const memoryCardsTable = pgTable("memory_card", {
    142143    componentId: integer("component_id")
    143144        .primaryKey()
     
    147148});
    148149
    149 export const opticalDriveTable = pgTable("optical_drive", {
     150export const opticalDrivesTable = pgTable("optical_drive", {
    150151    componentId: integer("component_id")
    151152        .primaryKey()
     
    158159});
    159160
    160 export const soundCardTable = pgTable("sound_card", {
     161export const soundCardsTable = pgTable("sound_card", {
    161162    componentId: integer("component_id")
    162163        .primaryKey()
     
    166167    chipset: text("chipset").notNull(),
    167168    interface: text("interface").notNull(),
    168 });
    169 
    170 // SoundCard multi-values
    171 export const soundCardChannelsTable = pgTable("sound_card_channels", {
    172         soundCardId: integer("sound_card_id")
    173             .notNull()
    174             .references(() => soundCardTable.componentId, { onDelete: "cascade", onUpdate: "cascade" }),
    175         channel: text("channel").notNull(),
    176     },
    177     (t) => ({
    178         pk: primaryKey({ columns: [t.soundCardId, t.channel] }),
    179     })
    180 );
     169    channel: text("channel").notNull(),
     170});
    181171
    182172export const cablesTable = pgTable("cables", {
     
    188178});
    189179
    190 export const networkAdapterTable = pgTable("network_adapter", {
     180export const networkAdaptersTable = pgTable("network_adapter", {
    191181    componentId: integer("component_id")
    192182        .primaryKey()
     
    197187});
    198188
    199 export const networkCardTable = pgTable("network_card", {
     189export const networkCardsTable = pgTable("network_card", {
    200190    componentId: integer("component_id")
    201191        .primaryKey()
     
    221211export type powerSupplyInsert = typeof powerSupplyTable.$inferInsert;
    222212
    223 export type caseItem = typeof pcCaseTable.$inferSelect;
    224 export type caseInsert = typeof pcCaseTable.$inferInsert;
     213export type caseItem = typeof pcCasesTable.$inferSelect;
     214export type caseInsert = typeof pcCasesTable.$inferInsert;
    225215
    226216export type caseStorageFormFactorsItem = typeof caseStorageFormFactorsTable.$inferSelect;
     
    233223export type caseMoboFormFactorsInsert = typeof caseMoboFormFactorsTable.$inferInsert;
    234224
    235 export type coolerItem = typeof coolerTable.$inferSelect;
    236 export type coolerInsert = typeof coolerTable.$inferInsert;
     225export type coolerItem = typeof coolersTable.$inferSelect;
     226export type coolerInsert = typeof coolersTable.$inferInsert;
    237227
    238228export type coolerCPUSocketsItem = typeof coolerCPUSocketsTable.$inferSelect;
    239229export type coolerCPUSocketsInsert = typeof coolerCPUSocketsTable.$inferInsert;
    240230
    241 export type motherboardItem = typeof motherboardTable.$inferSelect;
    242 export type motherboardInsert = typeof motherboardTable.$inferInsert;
     231export type motherboardItem = typeof motherboardsTable.$inferSelect;
     232export type motherboardInsert = typeof motherboardsTable.$inferInsert;
    243233
    244234export type storageItem = typeof storageTable.$inferSelect;
    245235export type storageInsert = typeof storageTable.$inferInsert
    246236
    247 export type memoryCardItem = typeof memoryCardTable.$inferSelect;
    248 export type memoryCardInsert = typeof memoryCardTable.$inferInsert;
    249 
    250 export type opticalDriveItem = typeof opticalDriveTable.$inferSelect;
    251 export type opticalDriveInsert = typeof opticalDriveTable.$inferInsert;
    252 
    253 export type soundCardItem = typeof soundCardTable.$inferSelect;
    254 export type soundCardInsert = typeof soundCardTable.$inferInsert;
    255 
    256 export type soundCardChannelsItem = typeof soundCardChannelsTable.$inferSelect;
    257 export type soundCardChannelsInsert = typeof soundCardChannelsTable.$inferInsert;
     237export type memoryCardItem = typeof memoryCardsTable.$inferSelect;
     238export type memoryCardInsert = typeof memoryCardsTable.$inferInsert;
     239
     240export type opticalDriveItem = typeof opticalDrivesTable.$inferSelect;
     241export type opticalDriveInsert = typeof opticalDrivesTable.$inferInsert;
     242
     243export type soundCardItem = typeof soundCardsTable.$inferSelect;
     244export type soundCardInsert = typeof soundCardsTable.$inferInsert;
    258245
    259246export type cablesItem = typeof cablesTable.$inferSelect;
    260247export type cablesInsert = typeof cablesTable.$inferInsert;
    261248
    262 export type networkAdapterItem = typeof networkAdapterTable.$inferSelect;
    263 export type networkAdapterInsert = typeof networkAdapterTable.$inferInsert;
    264 
    265 export type networkCardItem = typeof networkCardTable.$inferSelect;
    266 export type networkCardInsert = typeof networkCardTable.$inferInsert;
    267 
     249export type networkAdapterItem = typeof networkAdaptersTable.$inferSelect;
     250export type networkAdapterInsert = typeof networkAdaptersTable.$inferInsert;
     251
     252export type networkCardItem = typeof networkCardsTable.$inferSelect;
     253export type networkCardInsert = typeof networkCardsTable.$inferInsert;
     254
Note: See TracChangeset for help on using the changeset viewer.