Help us shape the future of Go! Take the 2026 Go Developer Survey

migrate

package
v1.35.0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// WithGlobalUniqueID sets the universal ids options to the migration.
	// If this option is enabled, ent migration will allocate a 1<<32 range
	// for the ids of each entity (table).
	// Note that this option cannot be applied on tables that already exist.
	WithGlobalUniqueID = schema.WithGlobalUniqueID
	// WithDropColumn sets the drop column option to the migration.
	// If this option is enabled, ent migration will drop old columns
	// that were used for both fields and edges. This defaults to false.
	WithDropColumn = schema.WithDropColumn
	// WithDropIndex sets the drop index option to the migration.
	// If this option is enabled, ent migration will drop old indexes
	// that were defined in the schema. This defaults to false.
	// Note that unique constraints are defined using `UNIQUE INDEX`,
	// and therefore, it's recommended to enable this option to get more
	// flexibility in the schema changes.
	WithDropIndex = schema.WithDropIndex
	// WithForeignKeys enables creating foreign-key in schema DDL. This defaults to true.
	WithForeignKeys = schema.WithForeignKeys
)
View Source
var (
	// AnalyticsEventsColumns holds the columns for the "analytics_events" table.
	AnalyticsEventsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeString, Unique: true},
		{Name: "event_name", Type: field.TypeString},
		{Name: "event_category", Type: field.TypeString},
		{Name: "session_id", Type: field.TypeString, Nullable: true},
		{Name: "duration_ms", Type: field.TypeInt64, Nullable: true},
		{Name: "page", Type: field.TypeString, Nullable: true},
		{Name: "component", Type: field.TypeString, Nullable: true},
		{Name: "labels", Type: field.TypeJSON, Nullable: true},
		{Name: "created_at", Type: field.TypeTime},
	}
	// AnalyticsEventsTable holds the schema information for the "analytics_events" table.
	AnalyticsEventsTable = &schema.Table{
		Name:       "analytics_events",
		Columns:    AnalyticsEventsColumns,
		PrimaryKey: []*schema.Column{AnalyticsEventsColumns[0]},
		Indexes: []*schema.Index{
			{
				Name:    "analyticsevent_event_name",
				Unique:  false,
				Columns: []*schema.Column{AnalyticsEventsColumns[1]},
			},
			{
				Name:    "analyticsevent_event_category",
				Unique:  false,
				Columns: []*schema.Column{AnalyticsEventsColumns[2]},
			},
			{
				Name:    "analyticsevent_session_id",
				Unique:  false,
				Columns: []*schema.Column{AnalyticsEventsColumns[3]},
			},
			{
				Name:    "analyticsevent_created_at",
				Unique:  false,
				Columns: []*schema.Column{AnalyticsEventsColumns[8]},
			},
			{
				Name:    "analyticsevent_event_name_created_at",
				Unique:  false,
				Columns: []*schema.Column{AnalyticsEventsColumns[1], AnalyticsEventsColumns[8]},
			},
		},
	}
	// ApprovalRulesColumns holds the columns for the "approval_rules" table.
	ApprovalRulesColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "rule_id", Type: field.TypeString, Unique: true},
		{Name: "name", Type: field.TypeString},
		{Name: "tool_name", Type: field.TypeString, Nullable: true},
		{Name: "tool_pattern", Type: field.TypeString, Nullable: true},
		{Name: "tool_category", Type: field.TypeString, Nullable: true},
		{Name: "command_pattern", Type: field.TypeString, Nullable: true},
		{Name: "file_pattern", Type: field.TypeString, Nullable: true},
		{Name: "decision", Type: field.TypeInt},
		{Name: "risk_level", Type: field.TypeInt},
		{Name: "reason", Type: field.TypeString, Nullable: true},
		{Name: "alternative", Type: field.TypeString, Nullable: true},
		{Name: "priority", Type: field.TypeInt, Default: 0},
		{Name: "enabled", Type: field.TypeBool, Default: true},
		{Name: "source", Type: field.TypeString, Default: "user"},
		{Name: "created_at", Type: field.TypeTime},
		{Name: "updated_at", Type: field.TypeTime},
		{Name: "programs", Type: field.TypeJSON, Nullable: true},
		{Name: "subcommands", Type: field.TypeJSON, Nullable: true},
		{Name: "blocked_subcommands", Type: field.TypeJSON, Nullable: true},
		{Name: "required_flags", Type: field.TypeJSON, Nullable: true},
		{Name: "forbidden_flags", Type: field.TypeJSON, Nullable: true},
		{Name: "required_flag_prefixes", Type: field.TypeJSON, Nullable: true},
		{Name: "python_modes", Type: field.TypeJSON, Nullable: true},
		{Name: "safe_python_imports_only", Type: field.TypeBool, Default: false},
	}
	// ApprovalRulesTable holds the schema information for the "approval_rules" table.
	ApprovalRulesTable = &schema.Table{
		Name:       "approval_rules",
		Columns:    ApprovalRulesColumns,
		PrimaryKey: []*schema.Column{ApprovalRulesColumns[0]},
		Indexes: []*schema.Index{
			{
				Name:    "approvalrule_rule_id",
				Unique:  false,
				Columns: []*schema.Column{ApprovalRulesColumns[1]},
			},
			{
				Name:    "approvalrule_priority",
				Unique:  false,
				Columns: []*schema.Column{ApprovalRulesColumns[12]},
			},
			{
				Name:    "approvalrule_enabled",
				Unique:  false,
				Columns: []*schema.Column{ApprovalRulesColumns[13]},
			},
		},
	}
	// BacklogItemsColumns holds the columns for the "backlog_items" table.
	BacklogItemsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID},
		{Name: "title", Type: field.TypeString},
		{Name: "description", Type: field.TypeString, Nullable: true},
		{Name: "acceptance_criteria", Type: field.TypeString, Nullable: true},
		{Name: "priority", Type: field.TypeInt, Default: 3},
		{Name: "status", Type: field.TypeString, Default: "idea"},
		{Name: "repo_path", Type: field.TypeString, Nullable: true},
		{Name: "skip_review_gate", Type: field.TypeBool, Default: false},
		{Name: "skip_planning", Type: field.TypeBool, Default: false},
		{Name: "plan_approved", Type: field.TypeBool, Default: false},
		{Name: "plan_approved_at", Type: field.TypeTime, Nullable: true},
		{Name: "plan_artifacts_path", Type: field.TypeString, Nullable: true},
		{Name: "user_modified_fields", Type: field.TypeString, Nullable: true},
		{Name: "notes", Type: field.TypeString, Nullable: true},
		{Name: "external_id", Type: field.TypeString, Nullable: true},
		{Name: "user_modified_status_at", Type: field.TypeTime, Nullable: true},
		{Name: "archived_at", Type: field.TypeTime, Nullable: true},
		{Name: "created_at", Type: field.TypeTime},
		{Name: "updated_at", Type: field.TypeTime},
		{Name: "item_source_backlog_items", Type: field.TypeUUID, Nullable: true},
	}
	// BacklogItemsTable holds the schema information for the "backlog_items" table.
	BacklogItemsTable = &schema.Table{
		Name:       "backlog_items",
		Columns:    BacklogItemsColumns,
		PrimaryKey: []*schema.Column{BacklogItemsColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "backlog_items_item_sources_backlog_items",
				Columns:    []*schema.Column{BacklogItemsColumns[19]},
				RefColumns: []*schema.Column{ItemSourcesColumns[0]},
				OnDelete:   schema.SetNull,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "backlogitem_status_priority",
				Unique:  false,
				Columns: []*schema.Column{BacklogItemsColumns[5], BacklogItemsColumns[4]},
			},
			{
				Name:    "backlogitem_status_updated_at",
				Unique:  false,
				Columns: []*schema.Column{BacklogItemsColumns[5], BacklogItemsColumns[18]},
			},
			{
				Name:    "backlogitem_external_id",
				Unique:  false,
				Columns: []*schema.Column{BacklogItemsColumns[14]},
			},
			{
				Name:    "backlogitem_status",
				Unique:  false,
				Columns: []*schema.Column{BacklogItemsColumns[5]},
			},
		},
	}
	// BacklogStatusEventsColumns holds the columns for the "backlog_status_events" table.
	BacklogStatusEventsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID},
		{Name: "from_status", Type: field.TypeString},
		{Name: "to_status", Type: field.TypeString},
		{Name: "triggered_by", Type: field.TypeString, Default: "user"},
		{Name: "created_at", Type: field.TypeTime},
		{Name: "item_id", Type: field.TypeUUID},
	}
	// BacklogStatusEventsTable holds the schema information for the "backlog_status_events" table.
	BacklogStatusEventsTable = &schema.Table{
		Name:       "backlog_status_events",
		Columns:    BacklogStatusEventsColumns,
		PrimaryKey: []*schema.Column{BacklogStatusEventsColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "backlog_status_events_backlog_items_status_events",
				Columns:    []*schema.Column{BacklogStatusEventsColumns[5]},
				RefColumns: []*schema.Column{BacklogItemsColumns[0]},
				OnDelete:   schema.Cascade,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "backlogstatusevent_item_id_created_at",
				Unique:  false,
				Columns: []*schema.Column{BacklogStatusEventsColumns[5], BacklogStatusEventsColumns[4]},
			},
		},
	}
	// ClassificationAnalyticsColumns holds the columns for the "classification_analytics" table.
	ClassificationAnalyticsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "analytics_id", Type: field.TypeString, Unique: true},
		{Name: "session_id", Type: field.TypeString, Nullable: true},
		{Name: "tool_name", Type: field.TypeString},
		{Name: "command_preview", Type: field.TypeString, Nullable: true},
		{Name: "cwd", Type: field.TypeString, Nullable: true},
		{Name: "decision", Type: field.TypeString},
		{Name: "risk_level", Type: field.TypeString},
		{Name: "rule_id", Type: field.TypeString, Nullable: true},
		{Name: "rule_name", Type: field.TypeString, Nullable: true},
		{Name: "reason", Type: field.TypeString, Nullable: true},
		{Name: "alternative", Type: field.TypeString, Nullable: true},
		{Name: "duration_ms", Type: field.TypeInt64, Default: 0},
		{Name: "approval_id", Type: field.TypeString, Nullable: true},
		{Name: "command_program", Type: field.TypeString, Nullable: true},
		{Name: "command_category", Type: field.TypeString, Nullable: true},
		{Name: "command_subcategory", Type: field.TypeString, Nullable: true},
		{Name: "python_imports", Type: field.TypeJSON, Nullable: true},
		{Name: "created_at", Type: field.TypeTime},
	}
	// ClassificationAnalyticsTable holds the schema information for the "classification_analytics" table.
	ClassificationAnalyticsTable = &schema.Table{
		Name:       "classification_analytics",
		Columns:    ClassificationAnalyticsColumns,
		PrimaryKey: []*schema.Column{ClassificationAnalyticsColumns[0]},
		Indexes: []*schema.Index{
			{
				Name:    "classificationanalytics_session_id",
				Unique:  false,
				Columns: []*schema.Column{ClassificationAnalyticsColumns[2]},
			},
			{
				Name:    "classificationanalytics_decision",
				Unique:  false,
				Columns: []*schema.Column{ClassificationAnalyticsColumns[6]},
			},
			{
				Name:    "classificationanalytics_risk_level",
				Unique:  false,
				Columns: []*schema.Column{ClassificationAnalyticsColumns[7]},
			},
			{
				Name:    "classificationanalytics_rule_id",
				Unique:  false,
				Columns: []*schema.Column{ClassificationAnalyticsColumns[8]},
			},
			{
				Name:    "classificationanalytics_created_at",
				Unique:  false,
				Columns: []*schema.Column{ClassificationAnalyticsColumns[18]},
			},
			{
				Name:    "classificationanalytics_command_program_created_at",
				Unique:  false,
				Columns: []*schema.Column{ClassificationAnalyticsColumns[14], ClassificationAnalyticsColumns[18]},
			},
		},
	}
	// ClaudeMetadataColumns holds the columns for the "claude_metadata" table.
	ClaudeMetadataColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "key", Type: field.TypeString},
		{Name: "value", Type: field.TypeString},
		{Name: "claude_session_metadata", Type: field.TypeInt},
	}
	// ClaudeMetadataTable holds the schema information for the "claude_metadata" table.
	ClaudeMetadataTable = &schema.Table{
		Name:       "claude_metadata",
		Columns:    ClaudeMetadataColumns,
		PrimaryKey: []*schema.Column{ClaudeMetadataColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "claude_metadata_claude_sessions_metadata",
				Columns:    []*schema.Column{ClaudeMetadataColumns[3]},
				RefColumns: []*schema.Column{ClaudeSessionsColumns[0]},
				OnDelete:   schema.NoAction,
			},
		},
	}
	// ClaudeSessionsColumns holds the columns for the "claude_sessions" table.
	ClaudeSessionsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "claude_session_id", Type: field.TypeString},
		{Name: "conversation_id", Type: field.TypeString, Nullable: true},
		{Name: "project_name", Type: field.TypeString, Nullable: true},
		{Name: "last_attached", Type: field.TypeTime, Nullable: true},
		{Name: "auto_reattach", Type: field.TypeBool, Default: false},
		{Name: "preferred_session_name", Type: field.TypeString, Nullable: true},
		{Name: "create_new_on_missing", Type: field.TypeBool, Default: false},
		{Name: "show_session_selector", Type: field.TypeBool, Default: false},
		{Name: "session_timeout_minutes", Type: field.TypeInt, Default: 30},
		{Name: "session_claude_session", Type: field.TypeInt, Unique: true},
	}
	// ClaudeSessionsTable holds the schema information for the "claude_sessions" table.
	ClaudeSessionsTable = &schema.Table{
		Name:       "claude_sessions",
		Columns:    ClaudeSessionsColumns,
		PrimaryKey: []*schema.Column{ClaudeSessionsColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "claude_sessions_sessions_claude_session",
				Columns:    []*schema.Column{ClaudeSessionsColumns[10]},
				RefColumns: []*schema.Column{SessionsColumns[0]},
				OnDelete:   schema.NoAction,
			},
		},
	}
	// DiffStatsColumns holds the columns for the "diff_stats" table.
	DiffStatsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "added", Type: field.TypeInt, Default: 0},
		{Name: "removed", Type: field.TypeInt, Default: 0},
		{Name: "content", Type: field.TypeString, Nullable: true, Size: 2147483647},
		{Name: "session_diff_stats", Type: field.TypeInt, Unique: true},
	}
	// DiffStatsTable holds the schema information for the "diff_stats" table.
	DiffStatsTable = &schema.Table{
		Name:       "diff_stats",
		Columns:    DiffStatsColumns,
		PrimaryKey: []*schema.Column{DiffStatsColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "diff_stats_sessions_diff_stats",
				Columns:    []*schema.Column{DiffStatsColumns[4]},
				RefColumns: []*schema.Column{SessionsColumns[0]},
				OnDelete:   schema.NoAction,
			},
		},
	}
	// ErrorEventsColumns holds the columns for the "error_events" table.
	ErrorEventsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "fingerprint", Type: field.TypeString, Unique: true},
		{Name: "error_type", Type: field.TypeString},
		{Name: "message", Type: field.TypeString},
		{Name: "stack_trace", Type: field.TypeString, Size: 2147483647},
		{Name: "rpc_procedure", Type: field.TypeString, Nullable: true},
		{Name: "occurrence_count", Type: field.TypeInt, Default: 1},
		{Name: "first_seen", Type: field.TypeTime},
		{Name: "last_seen", Type: field.TypeTime},
		{Name: "acknowledged", Type: field.TypeBool, Default: false},
		{Name: "acknowledged_at", Type: field.TypeTime, Nullable: true},
	}
	// ErrorEventsTable holds the schema information for the "error_events" table.
	ErrorEventsTable = &schema.Table{
		Name:       "error_events",
		Columns:    ErrorEventsColumns,
		PrimaryKey: []*schema.Column{ErrorEventsColumns[0]},
		Indexes: []*schema.Index{
			{
				Name:    "errorevent_last_seen",
				Unique:  false,
				Columns: []*schema.Column{ErrorEventsColumns[8]},
			},
			{
				Name:    "errorevent_acknowledged",
				Unique:  false,
				Columns: []*schema.Column{ErrorEventsColumns[9]},
			},
		},
	}
	// EscapeEventsColumns holds the columns for the "escape_events" table.
	EscapeEventsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeString, Unique: true},
		{Name: "session_id", Type: field.TypeString},
		{Name: "stage", Type: field.TypeString},
		{Name: "sequence_type", Type: field.TypeString},
		{Name: "sequence_subtype", Type: field.TypeString, Nullable: true},
		{Name: "byte_length", Type: field.TypeInt},
		{Name: "payload_hash", Type: field.TypeString, Nullable: true},
		{Name: "raw_bytes", Type: field.TypeBytes, Nullable: true},
		{Name: "mangled", Type: field.TypeBool, Default: false},
		{Name: "mangle_type", Type: field.TypeString, Nullable: true},
		{Name: "wall_time", Type: field.TypeTime},
		{Name: "session_seq", Type: field.TypeInt64},
	}
	// EscapeEventsTable holds the schema information for the "escape_events" table.
	EscapeEventsTable = &schema.Table{
		Name:       "escape_events",
		Columns:    EscapeEventsColumns,
		PrimaryKey: []*schema.Column{EscapeEventsColumns[0]},
		Indexes: []*schema.Index{
			{
				Name:    "escapeevent_session_id",
				Unique:  false,
				Columns: []*schema.Column{EscapeEventsColumns[1]},
			},
			{
				Name:    "escapeevent_session_id_stage",
				Unique:  false,
				Columns: []*schema.Column{EscapeEventsColumns[1], EscapeEventsColumns[2]},
			},
			{
				Name:    "escapeevent_session_id_session_seq",
				Unique:  false,
				Columns: []*schema.Column{EscapeEventsColumns[1], EscapeEventsColumns[11]},
			},
			{
				Name:    "escapeevent_wall_time",
				Unique:  false,
				Columns: []*schema.Column{EscapeEventsColumns[10]},
			},
			{
				Name:    "escapeevent_mangled",
				Unique:  false,
				Columns: []*schema.Column{EscapeEventsColumns[8]},
			},
			{
				Name:    "escapeevent_sequence_type",
				Unique:  false,
				Columns: []*schema.Column{EscapeEventsColumns[3]},
			},
		},
	}
	// ItemSessionsColumns holds the columns for the "item_sessions" table.
	ItemSessionsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID},
		{Name: "session_uuid", Type: field.TypeString},
		{Name: "session_role", Type: field.TypeString},
		{Name: "started_at", Type: field.TypeTime, Nullable: true},
		{Name: "ended_at", Type: field.TypeTime, Nullable: true},
		{Name: "ac_snapshot", Type: field.TypeString, Nullable: true},
		{Name: "triage_result", Type: field.TypeString, Nullable: true},
		{Name: "last_commit_sha", Type: field.TypeString, Nullable: true},
		{Name: "last_commit_at", Type: field.TypeTime, Nullable: true},
		{Name: "last_commit_message", Type: field.TypeString, Nullable: true},
		{Name: "commit_count_since_spawn", Type: field.TypeInt, Default: 0},
		{Name: "last_file_touch_at", Type: field.TypeTime, Nullable: true},
		{Name: "last_progress_at", Type: field.TypeTime, Nullable: true},
		{Name: "created_at", Type: field.TypeTime},
		{Name: "backlog_item_item_sessions", Type: field.TypeUUID},
	}
	// ItemSessionsTable holds the schema information for the "item_sessions" table.
	ItemSessionsTable = &schema.Table{
		Name:       "item_sessions",
		Columns:    ItemSessionsColumns,
		PrimaryKey: []*schema.Column{ItemSessionsColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "item_sessions_backlog_items_item_sessions",
				Columns:    []*schema.Column{ItemSessionsColumns[14]},
				RefColumns: []*schema.Column{BacklogItemsColumns[0]},
				OnDelete:   schema.NoAction,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "itemsession_session_uuid",
				Unique:  false,
				Columns: []*schema.Column{ItemSessionsColumns[1]},
			},
			{
				Name:    "itemsession_created_at_backlog_item_item_sessions",
				Unique:  false,
				Columns: []*schema.Column{ItemSessionsColumns[13], ItemSessionsColumns[14]},
			},
		},
	}
	// ItemSourcesColumns holds the columns for the "item_sources" table.
	ItemSourcesColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID},
		{Name: "plugin_id", Type: field.TypeString},
		{Name: "display_name", Type: field.TypeString},
		{Name: "config", Type: field.TypeString, Nullable: true},
		{Name: "enabled", Type: field.TypeBool, Default: true},
		{Name: "sync_cursor", Type: field.TypeString, Nullable: true},
		{Name: "last_synced_at", Type: field.TypeTime, Nullable: true},
		{Name: "created_at", Type: field.TypeTime},
		{Name: "updated_at", Type: field.TypeTime},
	}
	// ItemSourcesTable holds the schema information for the "item_sources" table.
	ItemSourcesTable = &schema.Table{
		Name:       "item_sources",
		Columns:    ItemSourcesColumns,
		PrimaryKey: []*schema.Column{ItemSourcesColumns[0]},
		Indexes: []*schema.Index{
			{
				Name:    "itemsource_plugin_id",
				Unique:  false,
				Columns: []*schema.Column{ItemSourcesColumns[1]},
			},
			{
				Name:    "itemsource_enabled",
				Unique:  false,
				Columns: []*schema.Column{ItemSourcesColumns[4]},
			},
		},
	}
	// ProjectsColumns holds the columns for the "projects" table.
	ProjectsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "name", Type: field.TypeString, Unique: true},
		{Name: "description", Type: field.TypeString, Nullable: true},
		{Name: "created_at", Type: field.TypeTime},
		{Name: "updated_at", Type: field.TypeTime},
	}
	// ProjectsTable holds the schema information for the "projects" table.
	ProjectsTable = &schema.Table{
		Name:       "projects",
		Columns:    ProjectsColumns,
		PrimaryKey: []*schema.Column{ProjectsColumns[0]},
		Indexes: []*schema.Index{
			{
				Name:    "project_name",
				Unique:  false,
				Columns: []*schema.Column{ProjectsColumns[1]},
			},
		},
	}
	// ReviewVerdictsColumns holds the columns for the "review_verdicts" table.
	ReviewVerdictsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID},
		{Name: "overall_outcome", Type: field.TypeString},
		{Name: "per_criterion", Type: field.TypeString, Nullable: true},
		{Name: "summary", Type: field.TypeString, Nullable: true},
		{Name: "diff_hash", Type: field.TypeString, Nullable: true},
		{Name: "prompt_hash", Type: field.TypeString, Nullable: true},
		{Name: "diff_token_count", Type: field.TypeInt, Nullable: true},
		{Name: "diff_truncated", Type: field.TypeBool, Default: false},
		{Name: "override_by", Type: field.TypeString, Nullable: true},
		{Name: "override_reason", Type: field.TypeString, Nullable: true},
		{Name: "override_at", Type: field.TypeTime, Nullable: true},
		{Name: "created_at", Type: field.TypeTime},
		{Name: "item_session_review_verdict", Type: field.TypeUUID, Unique: true},
	}
	// ReviewVerdictsTable holds the schema information for the "review_verdicts" table.
	ReviewVerdictsTable = &schema.Table{
		Name:       "review_verdicts",
		Columns:    ReviewVerdictsColumns,
		PrimaryKey: []*schema.Column{ReviewVerdictsColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "review_verdicts_item_sessions_review_verdict",
				Columns:    []*schema.Column{ReviewVerdictsColumns[12]},
				RefColumns: []*schema.Column{ItemSessionsColumns[0]},
				OnDelete:   schema.NoAction,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "reviewverdict_item_session_review_verdict",
				Unique:  true,
				Columns: []*schema.Column{ReviewVerdictsColumns[12]},
			},
		},
	}
	// SessionsColumns holds the columns for the "sessions" table.
	SessionsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "title", Type: field.TypeString, Unique: true},
		{Name: "uuid", Type: field.TypeString, Nullable: true, Default: ""},
		{Name: "path", Type: field.TypeString},
		{Name: "working_dir", Type: field.TypeString, Nullable: true},
		{Name: "branch", Type: field.TypeString, Nullable: true},
		{Name: "status", Type: field.TypeInt},
		{Name: "height", Type: field.TypeInt, Nullable: true},
		{Name: "width", Type: field.TypeInt, Nullable: true},
		{Name: "created_at", Type: field.TypeTime},
		{Name: "updated_at", Type: field.TypeTime},
		{Name: "auto_yes", Type: field.TypeBool, Default: false},
		{Name: "autonomous_mode", Type: field.TypeBool, Default: false},
		{Name: "prompt", Type: field.TypeString, Nullable: true},
		{Name: "program", Type: field.TypeString},
		{Name: "existing_worktree", Type: field.TypeString, Nullable: true},
		{Name: "category", Type: field.TypeString, Nullable: true},
		{Name: "is_expanded", Type: field.TypeBool, Default: true},
		{Name: "session_type", Type: field.TypeString, Nullable: true},
		{Name: "tmux_prefix", Type: field.TypeString, Nullable: true},
		{Name: "last_terminal_update", Type: field.TypeTime, Nullable: true},
		{Name: "last_meaningful_output", Type: field.TypeTime, Nullable: true},
		{Name: "last_output_signature", Type: field.TypeString, Nullable: true},
		{Name: "last_added_to_queue", Type: field.TypeTime, Nullable: true},
		{Name: "last_viewed", Type: field.TypeTime, Nullable: true},
		{Name: "last_acknowledged", Type: field.TypeTime, Nullable: true},
		{Name: "mcp_server_url", Type: field.TypeString, Nullable: true},
		{Name: "initial_prompt", Type: field.TypeString, Nullable: true},
		{Name: "one_shot", Type: field.TypeBool, Default: false},
		{Name: "last_user_response", Type: field.TypeTime, Nullable: true},
		{Name: "processing_grace_until", Type: field.TypeTime, Nullable: true},
		{Name: "last_prompt_detected", Type: field.TypeTime, Nullable: true},
		{Name: "last_prompt_signature", Type: field.TypeString, Nullable: true},
		{Name: "hidden", Type: field.TypeBool, Default: false},
		{Name: "pause_reason", Type: field.TypeString, Nullable: true},
		{Name: "workflow_id", Type: field.TypeString, Nullable: true},
		{Name: "archived_at", Type: field.TypeTime, Nullable: true},
		{Name: "github_pr_url", Type: field.TypeString, Nullable: true},
		{Name: "github_pr_number", Type: field.TypeInt, Nullable: true, Default: 0},
		{Name: "github_owner", Type: field.TypeString, Nullable: true},
		{Name: "github_repo", Type: field.TypeString, Nullable: true},
		{Name: "session_artifacts", Type: field.TypeString, Nullable: true, Default: ""},
		{Name: "project_sessions", Type: field.TypeInt, Nullable: true},
	}
	// SessionsTable holds the schema information for the "sessions" table.
	SessionsTable = &schema.Table{
		Name:       "sessions",
		Columns:    SessionsColumns,
		PrimaryKey: []*schema.Column{SessionsColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "sessions_projects_sessions",
				Columns:    []*schema.Column{SessionsColumns[42]},
				RefColumns: []*schema.Column{ProjectsColumns[0]},
				OnDelete:   schema.SetNull,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "session_title",
				Unique:  false,
				Columns: []*schema.Column{SessionsColumns[1]},
			},
			{
				Name:    "session_status",
				Unique:  false,
				Columns: []*schema.Column{SessionsColumns[6]},
			},
			{
				Name:    "session_category",
				Unique:  false,
				Columns: []*schema.Column{SessionsColumns[16]},
			},
			{
				Name:    "session_last_meaningful_output",
				Unique:  false,
				Columns: []*schema.Column{SessionsColumns[21]},
			},
			{
				Name:    "session_last_acknowledged",
				Unique:  false,
				Columns: []*schema.Column{SessionsColumns[25]},
			},
			{
				Name:    "session_created_at",
				Unique:  false,
				Columns: []*schema.Column{SessionsColumns[9]},
			},
			{
				Name:    "session_workflow_id",
				Unique:  false,
				Columns: []*schema.Column{SessionsColumns[35]},
			},
			{
				Name:    "session_archived_at",
				Unique:  false,
				Columns: []*schema.Column{SessionsColumns[36]},
			},
		},
	}
	// SessionGoalsColumns holds the columns for the "session_goals" table.
	SessionGoalsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID},
		{Name: "session_uuid", Type: field.TypeString},
		{Name: "goal", Type: field.TypeString, Size: 2000},
		{Name: "status", Type: field.TypeString, Default: "idle"},
		{Name: "tasks", Type: field.TypeString, Nullable: true},
		{Name: "set_by", Type: field.TypeString, Nullable: true},
		{Name: "created_at", Type: field.TypeTime},
		{Name: "updated_at", Type: field.TypeTime},
	}
	// SessionGoalsTable holds the schema information for the "session_goals" table.
	SessionGoalsTable = &schema.Table{
		Name:       "session_goals",
		Columns:    SessionGoalsColumns,
		PrimaryKey: []*schema.Column{SessionGoalsColumns[0]},
		Indexes: []*schema.Index{
			{
				Name:    "sessiongoal_session_uuid",
				Unique:  true,
				Columns: []*schema.Column{SessionGoalsColumns[1]},
			},
			{
				Name:    "sessiongoal_status",
				Unique:  false,
				Columns: []*schema.Column{SessionGoalsColumns[3]},
			},
		},
	}
	// ShellsColumns holds the columns for the "shells" table.
	ShellsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeString},
		{Name: "name", Type: field.TypeString},
		{Name: "command", Type: field.TypeString, Default: ""},
		{Name: "working_dir", Type: field.TypeString, Nullable: true},
		{Name: "tmux_session_name", Type: field.TypeString},
		{Name: "status", Type: field.TypeString, Default: "running"},
		{Name: "exit_code", Type: field.TypeInt, Nullable: true},
		{Name: "order_index", Type: field.TypeInt, Default: 0},
		{Name: "started_at", Type: field.TypeTime},
		{Name: "stopped_at", Type: field.TypeTime, Nullable: true},
		{Name: "session_shells", Type: field.TypeInt},
	}
	// ShellsTable holds the schema information for the "shells" table.
	ShellsTable = &schema.Table{
		Name:       "shells",
		Columns:    ShellsColumns,
		PrimaryKey: []*schema.Column{ShellsColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "shells_sessions_shells",
				Columns:    []*schema.Column{ShellsColumns[10]},
				RefColumns: []*schema.Column{SessionsColumns[0]},
				OnDelete:   schema.NoAction,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "shell_status",
				Unique:  false,
				Columns: []*schema.Column{ShellsColumns[5]},
			},
			{
				Name:    "shell_order_index",
				Unique:  false,
				Columns: []*schema.Column{ShellsColumns[7]},
			},
		},
	}
	// SourceSyncEventsColumns holds the columns for the "source_sync_events" table.
	SourceSyncEventsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID},
		{Name: "started_at", Type: field.TypeTime},
		{Name: "finished_at", Type: field.TypeTime, Nullable: true},
		{Name: "items_created", Type: field.TypeInt, Default: 0},
		{Name: "items_updated", Type: field.TypeInt, Default: 0},
		{Name: "items_skipped", Type: field.TypeInt, Default: 0},
		{Name: "items_errored", Type: field.TypeInt, Default: 0},
		{Name: "error_message", Type: field.TypeString, Nullable: true},
		{Name: "cursor_after", Type: field.TypeString, Nullable: true},
		{Name: "item_source_sync_events", Type: field.TypeUUID},
	}
	// SourceSyncEventsTable holds the schema information for the "source_sync_events" table.
	SourceSyncEventsTable = &schema.Table{
		Name:       "source_sync_events",
		Columns:    SourceSyncEventsColumns,
		PrimaryKey: []*schema.Column{SourceSyncEventsColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "source_sync_events_item_sources_sync_events",
				Columns:    []*schema.Column{SourceSyncEventsColumns[9]},
				RefColumns: []*schema.Column{ItemSourcesColumns[0]},
				OnDelete:   schema.NoAction,
			},
		},
		Indexes: []*schema.Index{
			{
				Name:    "sourcesyncevent_item_source_sync_events",
				Unique:  false,
				Columns: []*schema.Column{SourceSyncEventsColumns[9]},
			},
		},
	}
	// TagsColumns holds the columns for the "tags" table.
	TagsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "name", Type: field.TypeString, Unique: true},
	}
	// TagsTable holds the schema information for the "tags" table.
	TagsTable = &schema.Table{
		Name:       "tags",
		Columns:    TagsColumns,
		PrimaryKey: []*schema.Column{TagsColumns[0]},
		Indexes: []*schema.Index{
			{
				Name:    "tag_name",
				Unique:  false,
				Columns: []*schema.Column{TagsColumns[1]},
			},
		},
	}
	// WorkflowsColumns holds the columns for the "workflows" table.
	WorkflowsColumns = []*schema.Column{
		{Name: "id", Type: field.TypeUUID},
		{Name: "slug", Type: field.TypeString, Unique: true},
		{Name: "name", Type: field.TypeString},
		{Name: "description", Type: field.TypeString, Nullable: true},
		{Name: "command", Type: field.TypeString},
		{Name: "target_directory", Type: field.TypeString, Nullable: true},
		{Name: "input_template", Type: field.TypeString, Nullable: true},
		{Name: "session_type", Type: field.TypeString, Nullable: true, Default: "directory"},
		{Name: "model", Type: field.TypeString, Nullable: true},
		{Name: "agent_type", Type: field.TypeString, Nullable: true},
		{Name: "cron_expression", Type: field.TypeString, Nullable: true},
		{Name: "cron_enabled", Type: field.TypeBool, Default: false},
		{Name: "created_at", Type: field.TypeTime},
		{Name: "updated_at", Type: field.TypeTime},
		{Name: "keep_sessions", Type: field.TypeInt, Nullable: true, Default: 0},
		{Name: "archive_after_hours", Type: field.TypeInt, Nullable: true, Default: 0},
	}
	// WorkflowsTable holds the schema information for the "workflows" table.
	WorkflowsTable = &schema.Table{
		Name:       "workflows",
		Columns:    WorkflowsColumns,
		PrimaryKey: []*schema.Column{WorkflowsColumns[0]},
		Indexes: []*schema.Index{
			{
				Name:    "workflow_slug",
				Unique:  false,
				Columns: []*schema.Column{WorkflowsColumns[1]},
			},
			{
				Name:    "workflow_cron_enabled",
				Unique:  false,
				Columns: []*schema.Column{WorkflowsColumns[11]},
			},
			{
				Name:    "workflow_created_at",
				Unique:  false,
				Columns: []*schema.Column{WorkflowsColumns[12]},
			},
		},
	}
	// WorktreesColumns holds the columns for the "worktrees" table.
	WorktreesColumns = []*schema.Column{
		{Name: "id", Type: field.TypeInt, Increment: true},
		{Name: "repo_path", Type: field.TypeString},
		{Name: "worktree_path", Type: field.TypeString},
		{Name: "session_name", Type: field.TypeString},
		{Name: "branch_name", Type: field.TypeString},
		{Name: "base_commit_sha", Type: field.TypeString},
		{Name: "session_worktree", Type: field.TypeInt, Unique: true},
	}
	// WorktreesTable holds the schema information for the "worktrees" table.
	WorktreesTable = &schema.Table{
		Name:       "worktrees",
		Columns:    WorktreesColumns,
		PrimaryKey: []*schema.Column{WorktreesColumns[0]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "worktrees_sessions_worktree",
				Columns:    []*schema.Column{WorktreesColumns[6]},
				RefColumns: []*schema.Column{SessionsColumns[0]},
				OnDelete:   schema.NoAction,
			},
		},
	}
	// BacklogItemSessionsColumns holds the columns for the "backlog_item_sessions" table.
	BacklogItemSessionsColumns = []*schema.Column{
		{Name: "backlog_item_id", Type: field.TypeUUID},
		{Name: "session_id", Type: field.TypeInt},
	}
	// BacklogItemSessionsTable holds the schema information for the "backlog_item_sessions" table.
	BacklogItemSessionsTable = &schema.Table{
		Name:       "backlog_item_sessions",
		Columns:    BacklogItemSessionsColumns,
		PrimaryKey: []*schema.Column{BacklogItemSessionsColumns[0], BacklogItemSessionsColumns[1]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "backlog_item_sessions_backlog_item_id",
				Columns:    []*schema.Column{BacklogItemSessionsColumns[0]},
				RefColumns: []*schema.Column{BacklogItemsColumns[0]},
				OnDelete:   schema.Cascade,
			},
			{
				Symbol:     "backlog_item_sessions_session_id",
				Columns:    []*schema.Column{BacklogItemSessionsColumns[1]},
				RefColumns: []*schema.Column{SessionsColumns[0]},
				OnDelete:   schema.Cascade,
			},
		},
	}
	// SessionTagsColumns holds the columns for the "session_tags" table.
	SessionTagsColumns = []*schema.Column{
		{Name: "session_id", Type: field.TypeInt},
		{Name: "tag_id", Type: field.TypeInt},
	}
	// SessionTagsTable holds the schema information for the "session_tags" table.
	SessionTagsTable = &schema.Table{
		Name:       "session_tags",
		Columns:    SessionTagsColumns,
		PrimaryKey: []*schema.Column{SessionTagsColumns[0], SessionTagsColumns[1]},
		ForeignKeys: []*schema.ForeignKey{
			{
				Symbol:     "session_tags_session_id",
				Columns:    []*schema.Column{SessionTagsColumns[0]},
				RefColumns: []*schema.Column{SessionsColumns[0]},
				OnDelete:   schema.Cascade,
			},
			{
				Symbol:     "session_tags_tag_id",
				Columns:    []*schema.Column{SessionTagsColumns[1]},
				RefColumns: []*schema.Column{TagsColumns[0]},
				OnDelete:   schema.Cascade,
			},
		},
	}
	// Tables holds all the tables in the schema.
	Tables = []*schema.Table{
		AnalyticsEventsTable,
		ApprovalRulesTable,
		BacklogItemsTable,
		BacklogStatusEventsTable,
		ClassificationAnalyticsTable,
		ClaudeMetadataTable,
		ClaudeSessionsTable,
		DiffStatsTable,
		ErrorEventsTable,
		EscapeEventsTable,
		ItemSessionsTable,
		ItemSourcesTable,
		ProjectsTable,
		ReviewVerdictsTable,
		SessionsTable,
		SessionGoalsTable,
		ShellsTable,
		SourceSyncEventsTable,
		TagsTable,
		WorkflowsTable,
		WorktreesTable,
		BacklogItemSessionsTable,
		SessionTagsTable,
	}
)

Functions

func Create

func Create(ctx context.Context, s *Schema, tables []*schema.Table, opts ...schema.MigrateOption) error

Create creates all table resources using the given schema driver.

Types

type Schema

type Schema struct {
	// contains filtered or unexported fields
}

Schema is the API for creating, migrating and dropping a schema.

func NewSchema

func NewSchema(drv dialect.Driver) *Schema

NewSchema creates a new schema client.

func (*Schema) Create

func (s *Schema) Create(ctx context.Context, opts ...schema.MigrateOption) error

Create creates all schema resources.

func (*Schema) WriteTo

func (s *Schema) WriteTo(ctx context.Context, w io.Writer, opts ...schema.MigrateOption) error

WriteTo writes the schema changes to w instead of running them against the database.

if err := client.Schema.WriteTo(context.Background(), os.Stdout); err != nil {
	log.Fatal(err)
}

Jump to

Keyboard shortcuts

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