Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Composite Keys don't generate ref statements #11

Open
RiyeUK opened this issue May 10, 2024 · 1 comment
Open

Composite Keys don't generate ref statements #11

RiyeUK opened this issue May 10, 2024 · 1 comment

Comments

@RiyeUK
Copy link

RiyeUK commented May 10, 2024

With a table defined in the schema as so:

export const warehouseOffices = pgTable(
	'warehouse_offices',
	{
		officeId: integer('office_id')
			.notNull()
			.references(() => offices.id),
		warehouseId: integer('warehouse_id')
			.notNull()
			.references(() => warehouses.id),
	},
	(table) => {
		return {
			pk: primaryKey({ columns: [table.officeId, table.warehouseId] }),
		};
	}
);

The generated .dbml doesn't include any refs for this table:

table warehouse_offices {
  office_id integer [not null]
  warehouse_id integer [not null]

  indexes {
    (office_id, warehouse_id) [pk]
  }
}

I need to add these lines to the resulting .dbml:

ref: warehouse_offices.warehouse_id - warehouses.id
ref: warehouse_offices.office_id - offices.id
@L-Mario564
Copy link
Owner

What version of the ORM are you using? Do you know if this worked in a previous version?

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

No branches or pull requests

2 participants