migrations

package
v0.54.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 2, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MigrateAdditionalIndexes

func MigrateAdditionalIndexes(db *sql.DB) error

MigrateAdditionalIndexes adds performance optimization indexes identified during schema review.

Indexes added:

  • idx_issues_updated_at: For GetStaleIssues date filtering
  • idx_issues_status_priority: For common list query patterns
  • idx_labels_label_issue: Covering index for label lookups
  • idx_dependencies_issue_type: For blocked issues queries
  • idx_events_issue_type: For close reason queries

func MigrateAgentFields

func MigrateAgentFields(db *sql.DB) error

MigrateAgentFields adds agent-specific fields to the issues table. These fields support the agent-as-bead pattern:

  • hook_bead: current work attached to agent's hook (0..1 cardinality)
  • role_bead: reference to role definition bead
  • agent_state: agent-reported state (idle|running|stuck|stopped)
  • last_activity: timestamp for timeout detection
  • role_type: agent role (polecat|crew|witness|refinery|mayor|deacon)
  • rig: rig name (empty for town-level agents)

func MigrateAuthorColumns

func MigrateAuthorColumns(db *sql.DB) error

func MigrateBlockedIssuesCache

func MigrateBlockedIssuesCache(db *sql.DB) error

MigrateBlockedIssuesCache creates the blocked_issues_cache table for performance optimization This cache materializes the recursive CTE computation from GetReadyWork to avoid expensive recursive queries on every call

func MigrateBranchStatesTable

func MigrateBranchStatesTable(db *sql.DB) error

func MigrateChildCountersTable

func MigrateChildCountersTable(db *sql.DB) error

func MigrateCloseReasonColumn

func MigrateCloseReasonColumn(db *sql.DB) error

MigrateCloseReasonColumn adds the close_reason column to the issues table. This column stores the reason provided when closing an issue.

func MigrateClosedAtConstraint

func MigrateClosedAtConstraint(db *sql.DB) error

func MigrateClosedBySessionColumn

func MigrateClosedBySessionColumn(db *sql.DB) error

MigrateClosedBySessionColumn adds the closed_by_session column to the issues table. This tracks which Claude Code session closed the issue, enabling work attribution for entity CV building. See Gas Town decision 009-session-events-architecture.md.

func MigrateCompactedAtCommitColumn

func MigrateCompactedAtCommitColumn(db *sql.DB) error

func MigrateCompactionColumns

func MigrateCompactionColumns(db *sql.DB) error

func MigrateCompactionConfig

func MigrateCompactionConfig(db *sql.DB) error

func MigrateCompositeIndexes

func MigrateCompositeIndexes(db *sql.DB) error

func MigrateContentHashColumn

func MigrateContentHashColumn(db *sql.DB) error

func MigrateCreatedByColumn

func MigrateCreatedByColumn(db *sql.DB) error

MigrateCreatedByColumn adds the created_by column to the issues table. This tracks who created the issue, using the same actor chain as comment authors (--actor flag, BD_ACTOR env, or $USER). GH#748.

func MigrateCrystallizesColumn

func MigrateCrystallizesColumn(db *sql.DB) error

MigrateCrystallizesColumn adds the crystallizes column to the issues table. Crystallizes tracks whether work compounds over time (true: code, features) or evaporates (false: ops, support). Per Decision 006, this affects CV weighting. Default is false (conservative - work evaporates unless explicitly marked).

func MigrateDevlogBranchColumn

func MigrateDevlogBranchColumn(db *sql.DB) error

func MigrateDevlogCascades added in v0.53.1

func MigrateDevlogCascades(db *sql.DB) error

func MigrateDevlogCommitSHA

func MigrateDevlogCommitSHA(db *sql.DB) error

func MigrateDevlogEnrichmentStatus

func MigrateDevlogEnrichmentStatus(db *sql.DB) error

func MigrateDevlogFileHash

func MigrateDevlogFileHash(db *sql.DB) error

func MigrateDevlogGhostColumn

func MigrateDevlogGhostColumn(db *sql.DB) error

func MigrateDevlogMissingFlag

func MigrateDevlogMissingFlag(db *sql.DB) error

func MigrateDevlogSchema

func MigrateDevlogSchema(db *sql.DB) error

func MigrateDirtyIssuesTable

func MigrateDirtyIssuesTable(db *sql.DB) error

func MigrateDropEdgeColumns

func MigrateDropEdgeColumns(db *sql.DB) error

MigrateDropEdgeColumns removes the deprecated edge fields from the issues table. This is Phase 4 of the Edge Schema Consolidation (Decision 004).

Removes columns: - replies_to (now: replies-to dependency) - relates_to (now: relates-to dependencies) - duplicate_of (now: duplicates dependency) - superseded_by (now: supersedes dependency)

Prerequisites: - Migration 021 (migrate_edge_fields) must have already run to convert data - All code must be updated to use the dependencies API

SQLite doesn't support DROP COLUMN directly in older versions, so we recreate the table without the deprecated columns.

func MigrateDueDeferColumns

func MigrateDueDeferColumns(db *sql.DB) error

MigrateDueDeferColumns adds the due_at and defer_until columns to the issues table. These columns support time-based task scheduling (GH#820): - due_at: when the issue should be completed - defer_until: hide from bd ready until this time passes

func MigrateEdgeConsolidation

func MigrateEdgeConsolidation(db *sql.DB) error

MigrateEdgeConsolidation adds metadata and thread_id columns to the dependencies table. This is Phase 1 of the Edge Schema Consolidation (Decision 004): - metadata: JSON blob for type-specific edge data (similarity scores, reasons, etc.) - thread_id: For efficient conversation threading queries

These columns enable: - Edge metadata without schema changes (extensibility) - O(1) thread queries for Reddit-style conversations - HOP knowledge graph foundation

func MigrateEdgeFields

func MigrateEdgeFields(db *sql.DB) error

MigrateEdgeFields migrates existing issue fields to dependency edges. This is Phase 3 of the Edge Schema Consolidation (Decision 004).

Migrates: - replies_to -> replies-to dependency with thread_id - relates_to -> relates-to dependencies - duplicate_of -> duplicates dependency - superseded_by -> supersedes dependency

This migration is idempotent: it uses INSERT OR IGNORE to skip edges that already exist (from Phase 2 dual-write).

func MigrateEntityAliasRegistry added in v0.53.1

func MigrateEntityAliasRegistry(db *sql.DB) error

func MigrateEntityDepsHardening added in v0.53.1

func MigrateEntityDepsHardening(db *sql.DB) error

func MigrateEntityPreferredName added in v0.53.1

func MigrateEntityPreferredName(db *sql.DB) error

func MigrateEventFields

func MigrateEventFields(db *sql.DB) error

MigrateEventFields adds event-specific fields to the issues table. These fields support type: event beads for operational state changes. Fields:

  • event_kind: namespaced event type (e.g., patrol.muted, agent.started)
  • actor: entity URI who caused this event
  • target: entity URI or bead ID affected
  • payload: event-specific JSON data

func MigrateExportHashesTable

func MigrateExportHashesTable(db *sql.DB) error

func MigrateExternalRefColumn

func MigrateExternalRefColumn(db *sql.DB) (retErr error)

func MigrateExternalRefUnique

func MigrateExternalRefUnique(db *sql.DB) error

func MigrateExtractionEvolSchema

func MigrateExtractionEvolSchema(db *sql.DB) error

func MigrateGateColumns

func MigrateGateColumns(db *sql.DB) error

MigrateGateColumns adds gate-related columns to the issues table for async coordination. Gate fields enable agents to wait on external conditions (CI completion, human approval, etc.)

func MigrateHookedStatus

func MigrateHookedStatus(db *sql.DB) error

MigrateHookedStatus converts pinned work items to hooked status. 'pinned' now means identity/domain records (agents, roles). 'hooked' means work actively attached to an agent's hook (GUPP).

func MigrateIsTemplateColumn

func MigrateIsTemplateColumn(db *sql.DB) error

MigrateIsTemplateColumn adds the is_template column to the issues table. Template issues (molecules) are read-only templates that should be filtered from work views by default (beads-1ra).

func MigrateMessagingFields

func MigrateMessagingFields(db *sql.DB) error

MigrateMessagingFields adds messaging and graph link support columns to the issues table. These columns support inter-agent communication: - sender: who sent this message - ephemeral: can be bulk-deleted when closed - replies_to: issue ID for conversation threading - relates_to: JSON array of issue IDs for knowledge graph edges - duplicate_of: canonical issue ID (this is a duplicate) - superseded_by: replacement issue ID (this is obsolete)

func MigrateMolTypeColumn

func MigrateMolTypeColumn(db *sql.DB) error

MigrateMolTypeColumn adds mol_type column to the issues table. This field distinguishes molecule types (swarm/patrol/work) for swarm coordination. Values: 'swarm' (multi-polecat coordination), 'patrol' (recurring ops), 'work' (regular, default)

func MigrateOrphanDetection

func MigrateOrphanDetection(db *sql.DB) error

MigrateOrphanDetection detects orphaned child issues and logs them for user action Orphaned children are issues with hierarchical IDs (e.g., "parent.1") where the parent issue no longer exists in the database.

Hierarchical IDs have the format {parentID}.{N} where N is a numeric child suffix. This correctly handles prefixes that contain dots (e.g., "my.project-abc123" is NOT hierarchical, but "my.project-abc123.1" IS hierarchical). See GH#508.

This migration does NOT automatically delete or convert orphans - it only logs them so the user can decide whether to: - Delete the orphans if they're no longer needed - Convert them to top-level issues by renaming them - Restore the missing parent issues

func MigrateOwnerColumn

func MigrateOwnerColumn(db *sql.DB) error

MigrateOwnerColumn adds the owner column to the issues table. This tracks the human owner responsible for the issue, using git author email for HOP CV (curriculum vitae) attribution chains. See Decision 008.

func MigratePinnedColumn

func MigratePinnedColumn(db *sql.DB) error

MigratePinnedColumn adds the pinned column to the issues table. Pinned issues are persistent context markers that should not be treated as work items.

func MigratePopulateFTS

func MigratePopulateFTS(db *sql.DB) error

MigratePopulateFTS ensures FTS tables are populated if the base tables are not empty. Since we used content='...', standard INSERTs don't auto-populate existing data. We must issue a 'rebuild' command.

func MigrateQualityScoreColumn

func MigrateQualityScoreColumn(db *sql.DB) error

MigrateQualityScoreColumn adds the quality_score column to the issues table. This stores an aggregate quality score (0.0-1.0) set by Refineries on merge. NULL indicates no score has been assigned yet.

func MigrateRemoveDependsOnFK

func MigrateRemoveDependsOnFK(db *sql.DB) error

MigrateRemoveDependsOnFK removes the FOREIGN KEY constraint on depends_on_id to allow external dependencies (external:<project>:<capability>). See bd-zmmy for design context.

func MigrateRepoMtimesTable

func MigrateRepoMtimesTable(db *sql.DB) error

func MigrateSnapshotsTable

func MigrateSnapshotsTable(db *sql.DB) error

func MigrateSourceRepoColumn

func MigrateSourceRepoColumn(db *sql.DB) error

func MigrateSourceSystemColumn

func MigrateSourceSystemColumn(db *sql.DB) error

MigrateSourceSystemColumn adds the source_system column to the issues table. This tracks which adapter/system created the issue for federation support.

func MigrateTombstoneClosedAt

func MigrateTombstoneClosedAt(db *sql.DB) error

MigrateTombstoneClosedAt updates the closed_at constraint to allow tombstones to retain their closed_at timestamp from before deletion.

Previously: CHECK ((status = 'closed') = (closed_at IS NOT NULL)) - This required clearing closed_at when creating tombstones from closed issues

Now: CHECK (closed + tombstone OR non-closed/tombstone with no closed_at) - closed issues must have closed_at - tombstones may have closed_at (from before deletion) or not - other statuses must NOT have closed_at

This allows importing tombstones that were closed before being deleted, preserving the historical closed_at timestamp for audit purposes.

func MigrateTombstoneColumns

func MigrateTombstoneColumns(db *sql.DB) error

MigrateTombstoneColumns adds tombstone support columns to the issues table. These columns support inline soft-delete, replacing deletions.jsonl: - deleted_at: when the issue was deleted - deleted_by: who deleted the issue - delete_reason: why the issue was deleted - original_type: the issue type before deletion (for tombstones)

func MigrateWorkTypeColumn

func MigrateWorkTypeColumn(db *sql.DB) error

MigrateWorkTypeColumn adds work_type column to the issues table. This field distinguishes work assignment models per Decision 006. Values: 'mutex' (one worker, exclusive - default) or 'open_competition' (many submit, buyer picks)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL