import { Plugin } from '@elizaos/core';
import { pgTable, uuid, text, timestamp, jsonb, boolean, integer } from 'drizzle-orm/pg-core';
import { sql } from 'drizzle-orm';
// Define tables
export const projectTable = pgTable('projects', {
id: uuid('id').primaryKey().defaultRandom(),
agentId: uuid('agent_id').notNull(),
name: text('name').notNull(),
description: text('description'),
status: text('status').default('active'),
metadata: jsonb('metadata').default(sql`'{}'::jsonb`),
createdAt: timestamp('created_at').defaultNow(),
updatedAt: timestamp('updated_at').defaultNow(),
});
export const taskTable = pgTable('project_tasks', {
id: uuid('id').primaryKey().defaultRandom(),
projectId: uuid('project_id').notNull().references(() => projectTable.id),
title: text('title').notNull(),
completed: boolean('completed').default(false),
priority: integer('priority').default(0),
dueDate: timestamp('due_date'),
createdAt: timestamp('created_at').defaultNow(),
});
// Create indexes
export const projectIndexes = {
agentIdIdx: index('project_agent_id_idx').on(projectTable.agentId),
statusIdx: index('project_status_idx').on(projectTable.status),
};
// Export plugin
export const projectPlugin: Plugin = {
name: 'project-management',
schema: {
projectTable,
taskTable,
...projectIndexes,
},
// ... other plugin properties
};