Module: Woods::Db::Migrations::CreateEmbeddings
- Defined in:
- lib/woods/db/migrations/003_create_embeddings.rb
Overview
Creates the woods_embeddings table for storing vector embeddings. Uses TEXT for embedding storage (JSON array) for database portability. Pgvector users should use the pgvector generator for native vector columns.
Constant Summary collapse
- VERSION =
3
Class Method Summary collapse
Class Method Details
.up(connection) ⇒ void
This method returns an undefined value.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/woods/db/migrations/003_create_embeddings.rb', line 14 def self.up(connection) connection.execute(<<~SQL) CREATE TABLE IF NOT EXISTS woods_embeddings ( id INTEGER PRIMARY KEY AUTOINCREMENT, unit_id INTEGER NOT NULL, chunk_type TEXT, embedding TEXT NOT NULL, content_hash TEXT NOT NULL, dimensions INTEGER NOT NULL, created_at TEXT NOT NULL DEFAULT (datetime('now')), FOREIGN KEY (unit_id) REFERENCES woods_units(id) ) SQL connection.execute(<<~SQL) CREATE INDEX IF NOT EXISTS idx_woods_embeddings_unit ON woods_embeddings(unit_id) SQL connection.execute(<<~SQL) CREATE INDEX IF NOT EXISTS idx_woods_embeddings_hash ON woods_embeddings(content_hash) SQL end |