community presets draft
This commit is contained in:
@@ -14,3 +14,6 @@ export * from './projects/assets'
|
||||
export * from './projects/likes'
|
||||
export * from './projects/models'
|
||||
export * from './projects/projects'
|
||||
|
||||
// Presets table
|
||||
export * from './presets/presets'
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import { pgTable, index, text, boolean, jsonb } from 'drizzle-orm/pg-core'
|
||||
import { createInsertSchema, createSelectSchema } from 'drizzle-zod'
|
||||
import { id, timestampsColumns } from '../../helpers'
|
||||
import { users } from '../auth/users'
|
||||
|
||||
export const presets = pgTable(
|
||||
'presets',
|
||||
(t) => ({
|
||||
id: id('preset'),
|
||||
type: t.text('type').notNull(), // 'door' | 'window'
|
||||
name: t.text('name').notNull(),
|
||||
data: t.jsonb('data').notNull(),
|
||||
thumbnailUrl: t.text('thumbnail_url'),
|
||||
userId: t
|
||||
.text('user_id')
|
||||
.references(() => users.id, { onDelete: 'cascade' }),
|
||||
isCommunity: t.boolean('is_community').notNull().default(false),
|
||||
...timestampsColumns,
|
||||
}),
|
||||
(t) => [
|
||||
index('presets_type_idx').on(t.type),
|
||||
index('presets_user_id_idx').on(t.userId),
|
||||
index('presets_is_community_idx').on(t.isCommunity),
|
||||
],
|
||||
).enableRLS()
|
||||
|
||||
export type Preset = typeof presets.$inferSelect
|
||||
export type NewPreset = typeof presets.$inferInsert
|
||||
export const insertPresetSchema = createInsertSchema(presets)
|
||||
export const selectPresetSchema = createSelectSchema(presets)
|
||||
@@ -116,6 +116,41 @@ export interface Database {
|
||||
updated_at?: string
|
||||
}
|
||||
}
|
||||
presets: {
|
||||
Row: {
|
||||
id: string
|
||||
type: string
|
||||
name: string
|
||||
data: Json
|
||||
thumbnail_url: string | null
|
||||
user_id: string | null
|
||||
is_community: boolean
|
||||
created_at: string
|
||||
updated_at: string
|
||||
}
|
||||
Insert: {
|
||||
id?: string
|
||||
type: string
|
||||
name: string
|
||||
data: Json
|
||||
thumbnail_url?: string | null
|
||||
user_id?: string | null
|
||||
is_community?: boolean
|
||||
created_at?: string
|
||||
updated_at?: string
|
||||
}
|
||||
Update: {
|
||||
id?: string
|
||||
type?: string
|
||||
name?: string
|
||||
data?: Json
|
||||
thumbnail_url?: string | null
|
||||
user_id?: string | null
|
||||
is_community?: boolean
|
||||
created_at?: string
|
||||
updated_at?: string
|
||||
}
|
||||
}
|
||||
}
|
||||
Views: {}
|
||||
Functions: {}
|
||||
|
||||
Reference in New Issue
Block a user