Typescript doesnt autocomplete columns on table

I have a monorepo with a db package, structure is as follows: . ├── drizzle.config.ts ├── migrations ├── package.json ├── src │ ├── index.ts │ ├── schema │ │ ├── account.ts │ │ ├── chunk.ts │ │ ├── entity.ts │ │ ├── graph.ts │ │ ├── index.ts │ │ ├── relation.ts │ │ ├── session.ts │ │ ├── source-document-to-entity.ts │ │ ├── source-document-to-relation.ts │ │ ├── source-document.ts │ │ ├── topic.ts │ │ ├── user.ts │ │ └── verification.ts │ └── utils │ └── base-columns.ts └── tsconfig.json In schema/index.ts I re export all my tables export * from './source-document'; and so on source-document.ts
import { baseColumns } from '@/utils/base-columns';
import { relations } from 'drizzle-orm';
import { pgEnum, pgTable } from 'drizzle-orm/pg-core';
import { sourceDocumentToEntityTable } from './source-document-to-entity';
import { sourceDocumentToRelationTable } from './source-document-to-relation';
import { topicTable } from './topic';

export const sourceDocumentTypeEnum = pgEnum('sourceDocumentType', [
'pdf',
'video',
'audio',
'image',
]);

export const sourceDocumentTable = pgTable('source_document', (t) => ({
...baseColumns(t),
topicId: t
.text()
.references(() => topicTable.id, { onDelete: 'cascade' })
.notNull(),
name: t.text().notNull(),
contentS3Key: t.text().notNull(),
originalS3Key: t.text().notNull(),
type: sourceDocumentTypeEnum('type').notNull(),
}));

export const sourceDocumentRelations = relations(
sourceDocumentTable,
({ one, many }) => ({
topic: one(topicTable, {
fields: [sourceDocumentTable.topicId],
references: [topicTable.id],
}),
entities: many(sourceDocumentToEntityTable),
relations: many(sourceDocumentToRelationTable),
})
);
import { baseColumns } from '@/utils/base-columns';
import { relations } from 'drizzle-orm';
import { pgEnum, pgTable } from 'drizzle-orm/pg-core';
import { sourceDocumentToEntityTable } from './source-document-to-entity';
import { sourceDocumentToRelationTable } from './source-document-to-relation';
import { topicTable } from './topic';

export const sourceDocumentTypeEnum = pgEnum('sourceDocumentType', [
'pdf',
'video',
'audio',
'image',
]);

export const sourceDocumentTable = pgTable('source_document', (t) => ({
...baseColumns(t),
topicId: t
.text()
.references(() => topicTable.id, { onDelete: 'cascade' })
.notNull(),
name: t.text().notNull(),
contentS3Key: t.text().notNull(),
originalS3Key: t.text().notNull(),
type: sourceDocumentTypeEnum('type').notNull(),
}));

export const sourceDocumentRelations = relations(
sourceDocumentTable,
({ one, many }) => ({
topic: one(topicTable, {
fields: [sourceDocumentTable.topicId],
references: [topicTable.id],
}),
entities: many(sourceDocumentToEntityTable),
relations: many(sourceDocumentToRelationTable),
})
);
Now when I import a table back into another package in my monorepo the columns don't show up, see the image. What am I doing wrong here?
No description
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?