Module: Woods::Db::Migrations::CreateSnapshotUnits
- Defined in:
- lib/woods/db/migrations/005_create_snapshot_units.rb
Overview
Creates the woods_snapshot_units table for per-unit temporal tracking.
Each row links a unit (by identifier) to a snapshot, storing content hashes for efficient diff computation without duplicating full source code.
Constant Summary collapse
- VERSION =
5
Class Method Summary collapse
Class Method Details
.up(connection) ⇒ void
This method returns an undefined value.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/woods/db/migrations/005_create_snapshot_units.rb', line 15 def self.up(connection) connection.execute(<<~SQL) CREATE TABLE IF NOT EXISTS woods_snapshot_units ( id INTEGER PRIMARY KEY AUTOINCREMENT, snapshot_id INTEGER NOT NULL, identifier TEXT NOT NULL, unit_type TEXT NOT NULL, source_hash TEXT, metadata_hash TEXT, dependencies_hash TEXT, created_at TEXT NOT NULL DEFAULT (datetime('now')), FOREIGN KEY (snapshot_id) REFERENCES woods_snapshots(id), UNIQUE(snapshot_id, identifier) ) SQL connection.execute(<<~SQL) CREATE INDEX IF NOT EXISTS idx_snapshot_units_identifier ON woods_snapshot_units(identifier) SQL connection.execute(<<~SQL) CREATE INDEX IF NOT EXISTS idx_snapshot_units_snapshot ON woods_snapshot_units(snapshot_id) SQL end |