export const user = sqliteTable('user', {
id: integer('id').notNull().primaryKey(),
avatarId: integer('avatar_id').references(() => media.id, { onDelete: 'set null' }),
});
// ...
export const media = sqliteTable('media', {
id: integer('id').notNull().primaryKey(),
createdAt: integer('created_at', { mode: 'timestamp' })
.notNull()
.default(sql`(unixepoch())`),
updatedAt: integer('updated_at', { mode: 'timestamp' })
.notNull()
.default(sql`(unixepoch())`),
fileName: text('file_name', { mode: 'text', length: 255 }).notNull(),
mediaType: text('file_type', { mode: 'text' }).notNull(),
mimeType: text('mime_type', { mode: 'text', length: 100 }).notNull(),
size: integer('size', { mode: 'number' }).notNull(),
width: integer('width', { mode: 'number' }).notNull(),
height: integer('height', { mode: 'number' }).notNull(),
src: text('src', { mode: 'text' }).notNull(),
srcSet: text('srcset').notNull(),
alt: text('alt', { mode: 'text' }).notNull(),
});
export const user = sqliteTable('user', {
id: integer('id').notNull().primaryKey(),
avatarId: integer('avatar_id').references(() => media.id, { onDelete: 'set null' }),
});
// ...
export const media = sqliteTable('media', {
id: integer('id').notNull().primaryKey(),
createdAt: integer('created_at', { mode: 'timestamp' })
.notNull()
.default(sql`(unixepoch())`),
updatedAt: integer('updated_at', { mode: 'timestamp' })
.notNull()
.default(sql`(unixepoch())`),
fileName: text('file_name', { mode: 'text', length: 255 }).notNull(),
mediaType: text('file_type', { mode: 'text' }).notNull(),
mimeType: text('mime_type', { mode: 'text', length: 100 }).notNull(),
size: integer('size', { mode: 'number' }).notNull(),
width: integer('width', { mode: 'number' }).notNull(),
height: integer('height', { mode: 'number' }).notNull(),
src: text('src', { mode: 'text' }).notNull(),
srcSet: text('srcset').notNull(),
alt: text('alt', { mode: 'text' }).notNull(),
});