CREATE TABLE conversations (
 id INT AUTO_INCREMENT PRIMARY KEY,
 title VARCHAR(255),
 source VARCHAR(50),
 created_at DATETIME
);

CREATE TABLE messages (
 id INT AUTO_INCREMENT PRIMARY KEY,
 conversation_id INT,
 role VARCHAR(20),
 content LONGTEXT,
 created_at DATETIME,
 hash CHAR(40),
 processed TINYINT DEFAULT 0,
 FULLTEXT(content)
);

CREATE TABLE memories (
 id INT AUTO_INCREMENT PRIMARY KEY,
 content TEXT,
 weight FLOAT DEFAULT 1,
 strength FLOAT DEFAULT 1,
 last_used DATETIME
);

CREATE TABLE identity_profile (
 id INT AUTO_INCREMENT PRIMARY KEY,
 category VARCHAR(50),
 content TEXT,
 weight FLOAT DEFAULT 1,
 updated_at DATETIME
);

CREATE TABLE feedback (
 id INT AUTO_INCREMENT PRIMARY KEY,
 message_id INT,
 score INT,
 correction TEXT,
 created_at DATETIME
);

CREATE TABLE tasks (
 id INT AUTO_INCREMENT PRIMARY KEY,
 title VARCHAR(255),
 action TEXT,
 run_at DATETIME,
 status VARCHAR(20) DEFAULT 'pending',
 created_at DATETIME
);

CREATE TABLE capabilities (
 id INT AUTO_INCREMENT PRIMARY KEY,
 name VARCHAR(50),
 description TEXT,
 parameters TEXT,
 approval_required TINYINT DEFAULT 1
);
