community presets draft

This commit is contained in:
wass08
2026-03-04 13:18:18 +01:00
parent c26c7da091
commit a86609aa5c
13 changed files with 2067 additions and 2 deletions
+3
View File
@@ -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'
+30
View File
@@ -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)
+35
View File
@@ -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: {}