All other relations drop when creating a new one

export const homologationSchemas = createTable(
  "homologation_schemas",
  {
    id: serialUuid(),
    schema: jsonb().$type<AnyStateSchema>().notNull(),
    name: varchar().notNull(),
    description: text()
  },
  (hs) => ({
    schema_index: index("schema_idx").on(hs.schema),
  })
);

export const homologations = createTable(
  "homologations",
  {
    id: serialUuid(),
    name: varchar().notNull(),
    productId: uuid("product_id"),
    stateSchemaId: uuid("state_schema_id").notNull(),
  },
  (h) => ({
    state_index: index("state_idx").on(h.state),
  })
);

export const products = createTable(
  "products",
  {
    id: serialUuid(),

    name: varchar().notNull(),
  }
)


export const homologationSchemaRelation = relations(homologations, ({ one }) => ({
  stateSchema: one(homologationSchemas, {
    fields: [homologations.stateSchemaId],
    references: [homologationSchemas.id]
  }),
  }),
}))

// When I created this relation, the relation above just stops working (vscode doesn't show the property `product`, but it returns the data)
export const homologationProductRelation = relations(homologations, ({ one }) => ({
  product: one(products, {
    fields: [homologations.productId],
    references: [products.id],
    relationName: "relationname"
  })
}))

// idk
export const productHomologationsRelation = relations(products, ({ many }) => ({
  homologations: many(homologations, { relationName: "relationname" })
}))
Was this page helpful?