module Memo::Database

Overview

Database initialization and schema management

Memo can operate in two modes:

  1. Shared database: Uses table_prefix (default "memo_") to avoid conflicts
  2. Standalone database: No prefix needed, tables named: services, embeddings, chunks, embed_queue

Extended Modules

Defined in:

memo/database.cr

Instance Method Summary

Instance Method Detail

def create(path : String) : DB::Database #

Create new database file and initialize schema (standalone mode)

Creates a new SQLite database at the specified path and loads Memo schema. Returns the database connection.


[View source]
def init(db : DB::Database) #

Initialize Memo schema in provided database (standalone mode)

Loads consolidated schema without table prefixes. Use when Memo has its own dedicated database file. Safe to call multiple times (uses IF NOT EXISTS)


[View source]
def init_text_db(db : DB::Database, schema_name : String = "text_store") #

Initialize text storage database schema

Creates the texts table for storing document content. Text is keyed by content hash (same as embeddings). This database is persistent and survives embedding regeneration.

Also creates FTS5 virtual table for full-text search.


[View source]
def load_schema(db : DB::Database) #

Load memo schema into the provided database (shared mode)

Creates tables with configured prefix: memo_embeddings, memo_chunks, memo_embed_queue Use when Memo shares database with application tables. Safe to call multiple times (uses IF NOT EXISTS)


[View source]