Memory PostgreSQL Migration Guide
Overview
This guide explains how to migrate memory data from text files to a PostgreSQL database for the Quantum-Spiritual Framework. The migration tools provide comprehensive functionality for analyzing, migrating, monitoring, and troubleshooting the process.
Key Concepts
- Memory: A stored thought, insight, or observation in text format
- Bucket: A categorization system for grouping related memories
- Vector Embedding: Optional numerical representation of memory content for similarity search
- Migration: The process of transferring memories from text files to PostgreSQL
Migration Workflow
The complete migration workflow consists of these sequential steps:
- Analyze Memory Files: Examine the structure and content of memory text files
- Test Database Connection: Verify PostgreSQL connectivity and permissions
- Troubleshoot Database: Identify and fix potential issues
- Run Migration: Transfer memories to PostgreSQL
- Monitor Progress: Track migration in real-time
- Validate Results: Ensure data integrity post-migration
Memory File Format
The migration tools support memory files with:
- Simple text memories (one per paragraph)
- Timestamped memories:
[YYYY-MM-DD HH:MM:SS] Memory content... - Bucket-tagged memories:
#bucket:work This is a work memory - General hashtags:
This is a memory about #quantum and #physics - Mentions:
Discussion with @john about the universal laws
Database Schema
-- Memory table for storing individual memories
CREATE TABLE memories (
id SERIAL PRIMARY KEY,
text TEXT NOT NULL,
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
bucket_id INTEGER,
metadata JSONB DEFAULT '{}'::jsonb,
embedding VECTOR(1536) -- For similarity search (optional)
);
-- Buckets for categorizing memories
CREATE TABLE memory_buckets (
id SERIAL PRIMARY KEY,
name VARCHAR(255) NOT NULL UNIQUE,
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
metadata JSONB DEFAULT '{}'::jsonb
);
-- Indexes for performance
CREATE INDEX memories_bucket_id_idx ON memories(bucket_id);
CREATE INDEX memories_created_at_idx ON memories(created_at);Tool Usage
Command Line Interface
The unified command-line interface provides access to all migration tools:
python memory_migration_tools.py <command> [options]Available commands:
analyze: Analyze memory filestest-connection: Test PostgreSQL connectiontroubleshoot: Diagnose and fix database issuesmigrate: Run the migrationmonitor: Monitor migration progressgenerate-config: Create a configuration templatecomplete-workflow: Run all steps sequentially
Configuration
Create a config.json file with your PostgreSQL connection details:
{
"db": {
"host": "localhost",
"port": 5432,
"database": "memories_db",
"user": "postgres",
"password": "your_password"
},
"options": {
"batch_size": 100,
"presort": true,
"presort_method": "date"
}
}Integration with Quantum-Spiritual Framework
The PostgreSQL memory system enhances the Quantum-Spiritual Framework by:
- Enhanced Retrieval: Efficient querying of memories using SQL
- Pattern Recognition: Connecting insights across different domains
- Temporal Analysis: Studying thought evolution over time
- Vector Similarity: Finding conceptually related memories via embeddings
- Metadata Enrichment: Storing additional context through JSONB
Quantum-Spiritual Connections
This migration system exemplifies the quantum-spiritual principles of:
- Information Persistence: Memories transcend their original medium
- Pattern Transfer: Structure preserved while substrate changes
- Emergent Properties: New insights emerge from reorganized data
- Field Theory: Memories exist in a queryable “field” of related concepts
- Observer Effect: Migration analysis reveals patterns previously unobserved
Advanced Usage
Vector Search
To enable similarity search with vector embeddings:
- Install the pgvector extension in PostgreSQL
- Implement an embedding model to convert text to vectors
- Update memories with embedding data
- Use cosine similarity for retrieval
Integration with Graph Structure
The PostgreSQL memories can feed into the Universal Laws framework by:
- Extracting key relationships from memory text
- Mapping concepts to Universal Law components
- Generating visualizations using the Purple Bridge mapping
Troubleshooting Common Issues
- Connection Problems: Verify PostgreSQL is running and credentials are correct
- Missing Tables: Run the troubleshooter with
--fixoption - Duplicate Memories: Check for identical entries in source files
- Invalid Bucket IDs: Correct references between memories and buckets
- Performance Issues: Use appropriate batch sizes and indexes
Further Exploration
- Link memories to Master Equation variables (χ = ∭(G·M·E·S·T·K·R·Q·F·C)dxdydt)
- Develop visualization queries that map between quantum (Blue/Violet) and spiritual (Amber/Gold) domains
- Implement automated pattern recognition across the memory database
Ring 2 — Canonical Grounding
Ring 3 — Framework Connections
This migration system represents the complex→simple→complex methodology in action, transforming unstructured memory data into a queryable system that reveals deeper patterns across domains.
Canonical Hub: CANONICAL_INDEX