Merge pull request #288 from Haydenkkk/fix/filename-2long

fix: update workspace_files path column to support larger sizes
This commit is contained in:
Yoko
2025-08-21 11:58:37 +08:00
committed by GitHub
4 changed files with 9 additions and 2 deletions

View File

@@ -762,7 +762,7 @@ var (
// WorkspaceFilesColumns holds the columns for the "workspace_files" table.
WorkspaceFilesColumns = []*schema.Column{
{Name: "id", Type: field.TypeUUID},
{Name: "path", Type: field.TypeString},
{Name: "path", Type: field.TypeString, Size: 2147483647},
{Name: "content", Type: field.TypeString, Nullable: true, Size: 2147483647},
{Name: "hash", Type: field.TypeString},
{Name: "language", Type: field.TypeString, Nullable: true},

View File

@@ -32,7 +32,7 @@ func (WorkspaceFile) Fields() []ent.Field {
field.UUID("id", uuid.UUID{}),
field.UUID("user_id", uuid.UUID{}).Comment("关联的用户ID"),
field.UUID("workspace_id", uuid.UUID{}).Comment("关联的工作区ID"),
field.String("path").Validate(func(s string) error {
field.Text("path").Validate(func(s string) error {
if s == "" {
return fmt.Errorf("path cannot be empty")
}

View File

@@ -0,0 +1,4 @@
-- Alter workspace_files table to change path column from TEXT to VARCHAR(255)
-- Note: This operation may fail if any existing path values exceed 255 characters
ALTER TABLE workspace_files
ALTER COLUMN path TYPE VARCHAR(255);

View File

@@ -0,0 +1,3 @@
-- Alter workspace_files table to change path column from VARCHAR(255) to TEXT
ALTER TABLE workspace_files
ALTER COLUMN path TYPE TEXT;