feat: gallery macro

This commit is contained in:
2026-02-12 16:52:44 +01:00
parent 5c6fcb46ef
commit 924a165fb3
16 changed files with 1846 additions and 46 deletions

View File

@@ -182,6 +182,15 @@ export class DatabaseConnection {
created_at INTEGER NOT NULL
);
CREATE TABLE IF NOT EXISTS post_media (
id TEXT PRIMARY KEY,
project_id TEXT NOT NULL,
post_id TEXT NOT NULL,
media_id TEXT NOT NULL,
sort_order INTEGER NOT NULL DEFAULT 0,
created_at INTEGER NOT NULL
);
CREATE INDEX IF NOT EXISTS idx_posts_slug ON posts(slug);
CREATE INDEX IF NOT EXISTS idx_posts_status ON posts(status);
CREATE INDEX IF NOT EXISTS idx_posts_sync_status ON posts(sync_status);
@@ -190,6 +199,9 @@ export class DatabaseConnection {
CREATE INDEX IF NOT EXISTS idx_sync_log_status ON sync_log(status);
CREATE INDEX IF NOT EXISTS idx_post_links_source ON post_links(source_post_id);
CREATE INDEX IF NOT EXISTS idx_post_links_target ON post_links(target_post_id);
CREATE INDEX IF NOT EXISTS idx_post_media_post ON post_media(post_id);
CREATE INDEX IF NOT EXISTS idx_post_media_media ON post_media(media_id);
CREATE UNIQUE INDEX IF NOT EXISTS post_media_post_media_idx ON post_media(post_id, media_id);
CREATE UNIQUE INDEX IF NOT EXISTS posts_project_slug_idx ON posts(project_id, slug);
CREATE TABLE IF NOT EXISTS tags (

View File

@@ -96,6 +96,19 @@ export const postLinks = sqliteTable('post_links', {
createdAt: integer('created_at', { mode: 'timestamp' }).notNull(),
});
// Post-Media links - tracks which media files are linked to which posts
export const postMedia = sqliteTable('post_media', {
id: text('id').primaryKey(),
projectId: text('project_id').notNull(),
postId: text('post_id').notNull(),
mediaId: text('media_id').notNull(),
sortOrder: integer('sort_order').notNull().default(0), // For ordering media within a post
createdAt: integer('created_at', { mode: 'timestamp' }).notNull(),
}, (table) => ({
// Composite unique index: a media can only be linked once to a post
postMediaIdx: uniqueIndex('post_media_post_media_idx').on(table.postId, table.mediaId),
}));
// Tags table - stores tag metadata with optional colors
export const tags = sqliteTable('tags', {
id: text('id').primaryKey(),
@@ -143,6 +156,8 @@ export type Setting = typeof settings.$inferSelect;
export type NewSetting = typeof settings.$inferInsert;
export type PostLink = typeof postLinks.$inferSelect;
export type NewPostLink = typeof postLinks.$inferInsert;
export type PostMediaLink = typeof postMedia.$inferSelect;
export type NewPostMediaLink = typeof postMedia.$inferInsert;
export type Tag = typeof tags.$inferSelect;
export type NewTag = typeof tags.$inferInsert;
export type ChatConversation = typeof chatConversations.$inferSelect;