Module: Woods::Db::Migrations::CreateUnits
- Defined in:
- lib/woods/db/migrations/001_create_units.rb
Overview
Creates the woods_units table for storing extracted unit metadata.
Constant Summary collapse
- VERSION =
1
Class Method Summary collapse
Class Method Details
.up(connection) ⇒ void
This method returns an undefined value.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/woods/db/migrations/001_create_units.rb', line 12 def self.up(connection) # rubocop:disable Metrics/MethodLength connection.execute(<<~SQL) CREATE TABLE IF NOT EXISTS woods_units ( id INTEGER PRIMARY KEY AUTOINCREMENT, unit_type TEXT NOT NULL, identifier TEXT NOT NULL, namespace TEXT, file_path TEXT NOT NULL, source_code TEXT, source_hash TEXT, metadata TEXT, created_at TEXT NOT NULL DEFAULT (datetime('now')), updated_at TEXT NOT NULL DEFAULT (datetime('now')), UNIQUE(identifier) ) SQL connection.execute(<<~SQL) CREATE INDEX IF NOT EXISTS idx_woods_units_type ON woods_units(unit_type) SQL connection.execute(<<~SQL) CREATE INDEX IF NOT EXISTS idx_woods_units_file_path ON woods_units(file_path) SQL end |