laf_RSW
laf_RSW
DTDrizzle Team
Created by laf_RSW on 3/8/2024 in #help
Trouble with tablesFilter
Im running a PostgreSQL Database to which i recently added the PostGIS extension. However if i try to push my schema it prompts me if i want to delete the tables "spatial_ref_sys" and "geometry_columns" both are created by the PostGIS extension. I dont want to delete those tables. But i also don't want to integrate them into my schema since they are managed by the extension. To try and combat this problem i added tablesFilter to my drizzle config. tablesFilter: ["!spatial_ref_sys","!geometry_columns"], This however changes nothing. But if i remove either of those filters it correctly filters out the table that i left in. Is there anything im missing?
7 replies
DTDrizzle Team
Created by laf_RSW on 1/31/2024 in #help
One-to-Many Self relation, Not enough information to infer relation
Im currently working on a piece of software for infrastructure management. This software contains so-called "controls" that need to be done periodically. Every control can be followed up by multiple controls (called follow up control). But each control can only have one parent control it follows up on. I have created the following schema:
// controls Table
export const controls = pgTable("controls", {
id: serial("id").primaryKey().notNull(),
passed: boolean("passed").notNull().default(false),
user_id: bigint("user_id", { mode: 'number' }).references(() => users.id, {onUpdate: 'cascade', onDelete: 'restrict'}).notNull(),
followUpForControl_id: bigint("followUpForControl_id", { mode: 'number' }).references((): AnyPgColumn => controls.id, {onUpdate: 'cascade', onDelete: 'restrict'}),
});

export const controlRelations = relations(controls, ({ one, many }) => ({
user: one(users, {
fields: [controls.user_id],
references: [users.id]
}),
followUpControls: many(controls, {
relationName: 'followUpControls'
}),
followUpForControl: one(controls, {
fields: [controls.followUpForControl_id],
references: [controls.id],
relationName: 'followUpForControl'
}),
}));
// controls Table
export const controls = pgTable("controls", {
id: serial("id").primaryKey().notNull(),
passed: boolean("passed").notNull().default(false),
user_id: bigint("user_id", { mode: 'number' }).references(() => users.id, {onUpdate: 'cascade', onDelete: 'restrict'}).notNull(),
followUpForControl_id: bigint("followUpForControl_id", { mode: 'number' }).references((): AnyPgColumn => controls.id, {onUpdate: 'cascade', onDelete: 'restrict'}),
});

export const controlRelations = relations(controls, ({ one, many }) => ({
user: one(users, {
fields: [controls.user_id],
references: [users.id]
}),
followUpControls: many(controls, {
relationName: 'followUpControls'
}),
followUpForControl: one(controls, {
fields: [controls.followUpForControl_id],
references: [controls.id],
relationName: 'followUpForControl'
}),
}));
However when i try to query with followUpControls i get "There is not enough information to infer relation "controls.followUpControls""
5 replies