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 ( // 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, }, }, } // 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: "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: "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}, } // SessionsTable holds the schema information for the "sessions" table. SessionsTable = &schema.Table{ Name: "sessions", Columns: SessionsColumns, PrimaryKey: []*schema.Column{SessionsColumns[0]}, Indexes: []*schema.Index{ { Name: "session_title", Unique: false, Columns: []*schema.Column{SessionsColumns[1]}, }, { Name: "session_status", Unique: false, Columns: []*schema.Column{SessionsColumns[5]}, }, { Name: "session_category", Unique: false, Columns: []*schema.Column{SessionsColumns[14]}, }, { Name: "session_last_meaningful_output", Unique: false, Columns: []*schema.Column{SessionsColumns[19]}, }, { Name: "session_last_acknowledged", Unique: false, Columns: []*schema.Column{SessionsColumns[23]}, }, { Name: "session_created_at", Unique: false, Columns: []*schema.Column{SessionsColumns[8]}, }, }, } // 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]}, }, }, } // 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, }, }, } // 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{ ClaudeMetadataTable, ClaudeSessionsTable, DiffStatsTable, SessionsTable, TagsTable, WorktreesTable, SessionTagsTable, } )
Functions ¶
Types ¶
type Schema ¶
type Schema struct {
// contains filtered or unexported fields
}
Schema is the API for creating, migrating and dropping a schema.
Click to show internal directories.
Click to hide internal directories.