feat: update schema
This commit is contained in:
@@ -1,22 +1,18 @@
|
||||
import { sqliteTable, text, integer } from "drizzle-orm/sqlite-core";
|
||||
import { sqliteTable, text, integer, foreignKey } from "drizzle-orm/sqlite-core";
|
||||
|
||||
export const users = sqliteTable("users", {
|
||||
id: integer("id").primaryKey({ autoIncrement: true }),
|
||||
name: text("name").notNull(),
|
||||
email: text("email").notNull().unique(),
|
||||
createdAt: integer("created_at", { mode: "timestamp" })
|
||||
.notNull()
|
||||
.$defaultFn(() => new Date()),
|
||||
id: integer().primaryKey({ autoIncrement: true }),
|
||||
name: text().notNull(),
|
||||
email: text().notNull().unique(),
|
||||
});
|
||||
|
||||
export const posts = sqliteTable("posts", {
|
||||
id: integer("id").primaryKey({ autoIncrement: true }),
|
||||
title: text("title").notNull(),
|
||||
content: text("content"),
|
||||
authorId: integer("author_id")
|
||||
.notNull()
|
||||
.references(() => users.id),
|
||||
createdAt: integer("created_at", { mode: "timestamp" })
|
||||
.notNull()
|
||||
.$defaultFn(() => new Date()),
|
||||
});
|
||||
export const files = sqliteTable("files", {
|
||||
id: integer().primaryKey({ autoIncrement: true }),
|
||||
ownerId: integer().notNull(),
|
||||
path: text().notNull(),
|
||||
}, (table) => [
|
||||
foreignKey({
|
||||
columns: [table.ownerId],
|
||||
foreignColumns: [users.id],
|
||||
}),
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user