Drizzle-kit not detecting views ?

Hi, I've created a view in the same file as my regular table:
export const userLevelsWithRank = pgView('user_levels_with_rank').as(
(qb) =>
qb
.select({
rank: sql<number>`rank() over (order by "level" desc, "xp" desc)`.as('rank')
})
.from(userLevels)
);
export const userLevelsWithRank = pgView('user_levels_with_rank').as(
(qb) =>
qb
.select({
rank: sql<number>`rank() over (order by "level" desc, "xp" desc)`.as('rank')
})
.from(userLevels)
);
But drizzle kit says that no changes were made.
No schema changes, nothing to migrate 😴
Did I miss something ?
9 Replies
Angelelz
Angelelz•11mo ago
this is an known limitation
Angelelz
Angelelz•11mo ago
You can see the warning in the docs https://orm.drizzle.team/docs/views
Drizzle ORM - next gen TypeScript ORM
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
Angelelz
Angelelz•11mo ago
You'll need to add the views manually to your migration file
Cyber Grandma
Cyber GrandmaOP•11mo ago
ohh, okay thanks mate I hope it is coming soon ;)
Rami
Rami•10mo ago
how do you actually query the view? await db.select().from(View) doesn't work for me. It is saying that relation "pg_view" does not exist. What is going on? @Cyber Grandma if you help me with that I can help you with centering a div
Angelelz
Angelelz•10mo ago
The view needs to have been defined in the database for you to use it If I remember correctly, drizzle-kit doesn't support views yet. So you'll need to define them manually
Rami
Rami•10mo ago
GitHub
Feat: Use views in relations by Angelelz · Pull Request #1778 · dri...
close #769 Added types and correct handling of Views to relations and alias Added correct handling of Views to the dialect for RQB and correct types to the query builder Added schema for integrati...
Rami
Rami•10mo ago
seems like drizzle-kit is not open source, and that's where the feature needs to be added, right?
Angelelz
Angelelz•10mo ago
Correct
Want results from more Discord servers?
Add your server