Simple relational query in sqlite

I am trying to follow the documents but using BetterSqlite3. I have the schema shown in https://orm.drizzle.team/docs/rqb:
import { integer, sqliteTable, text } from 'drizzle-orm/sqlite-core';
import { relations } from 'drizzle-orm';

export const users = sqliteTable('users', {
id: integer('id').primaryKey(),
name: text('name').notNull(),
});

export const usersRelations = relations(users, ({ many }) => ({
posts: many(posts)
}));

export const posts = sqliteTable('posts', {
id: integer('id').primaryKey(),
content: text('content').notNull(),
authorId: integer('author_id').notNull(),
});

export const postsRelations = relations(posts, ({ one }) => ({
author: one(users, { fields: [posts.authorId], references: [users.id] }),
}));
import { integer, sqliteTable, text } from 'drizzle-orm/sqlite-core';
import { relations } from 'drizzle-orm';

export const users = sqliteTable('users', {
id: integer('id').primaryKey(),
name: text('name').notNull(),
});

export const usersRelations = relations(users, ({ many }) => ({
posts: many(posts)
}));

export const posts = sqliteTable('posts', {
id: integer('id').primaryKey(),
content: text('content').notNull(),
authorId: integer('author_id').notNull(),
});

export const postsRelations = relations(posts, ({ one }) => ({
author: one(users, { fields: [posts.authorId], references: [users.id] }),
}));
The first problem I see is that when I run pnpm drizzle-kit generate:sqlite the foreign keys are not generated:
posts 3 columns 0 indexes 0 fks
users 2 columns 0 indexes 0 fks

[✓] Your SQL migration file ➜ drizzle/0000_silly_spitfire.sql 🚀
posts 3 columns 0 indexes 0 fks
users 2 columns 0 indexes 0 fks

[✓] Your SQL migration file ➜ drizzle/0000_silly_spitfire.sql 🚀
What am I missing?
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server