Module: Woods::Db::Migrations::CreateSnapshots
- Defined in:
- lib/woods/db/migrations/004_create_snapshots.rb
Overview
Creates the woods_snapshots table for temporal index tracking.
Each row represents one extraction run anchored to a git commit SHA. Stores aggregate stats and diff counts vs. the previous snapshot.
Constant Summary collapse
- VERSION =
4
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 37 38 39 40 41 |
# File 'lib/woods/db/migrations/004_create_snapshots.rb', line 15 def self.up(connection) # rubocop:disable Metrics/MethodLength connection.execute(<<~SQL) CREATE TABLE IF NOT EXISTS woods_snapshots ( id INTEGER PRIMARY KEY AUTOINCREMENT, git_sha TEXT NOT NULL, git_branch TEXT, extracted_at TEXT NOT NULL, rails_version TEXT, ruby_version TEXT, total_units INTEGER NOT NULL DEFAULT 0, unit_counts TEXT, gemfile_lock_sha TEXT, schema_sha TEXT, units_added INTEGER DEFAULT 0, units_modified INTEGER DEFAULT 0, units_deleted INTEGER DEFAULT 0, created_at TEXT NOT NULL DEFAULT (datetime('now')), UNIQUE(git_sha) ) SQL connection.execute(<<~SQL) CREATE INDEX IF NOT EXISTS idx_snapshots_extracted_at ON woods_snapshots(extracted_at) SQL connection.execute(<<~SQL) CREATE INDEX IF NOT EXISTS idx_snapshots_branch ON woods_snapshots(git_branch) SQL end |