This is an automated email from the ASF dual-hosted git repository.

linkinstar pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/answer.git

commit 57f31ec7eb38ee9b4bf2f74f18a0416e74d752b9
Author: Yusuke Tanaka <[email protected]>
AuthorDate: Thu Dec 18 19:48:44 2025 +0900

    fix: expand avatar column length from 1024 to 2048
    
    The avatar column was too short to store long URLs from external OAuth
    providers. When users log in via connector-google plugin, the Google
    profile picture URL can exceed 1024 characters, causing a database error:
    
      Error 1406 (22001): Data too long for column 'avatar' at row 1
    
    This change expands the avatar column from VARCHAR(1024) to VARCHAR(2048).
    
    Note: While URLs can technically exceed 2048 characters per specification,
    2048 is the practical limit supported by most browsers and services.
    URLs longer than 2048 characters are extremely rare in real-world usage.
---
 internal/entity/user_entity.go    |  2 +-
 internal/migrations/migrations.go |  1 +
 internal/migrations/v29.go        | 37 +++++++++++++++++++++++++++++++++++++
 3 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/internal/entity/user_entity.go b/internal/entity/user_entity.go
index 66d61292..8e63fc95 100644
--- a/internal/entity/user_entity.go
+++ b/internal/entity/user_entity.go
@@ -60,7 +60,7 @@ type User struct {
        Status         int       `xorm:"not null default 1 INT(11) status"`
        AuthorityGroup int       `xorm:"not null default 1 INT(11) 
authority_group"`
        DisplayName    string    `xorm:"not null default '' VARCHAR(30) 
display_name"`
-       Avatar         string    `xorm:"not null default '' VARCHAR(1024) 
avatar"`
+       Avatar         string    `xorm:"not null default '' VARCHAR(2048) 
avatar"`
        Mobile         string    `xorm:"not null VARCHAR(20) mobile"`
        Bio            string    `xorm:"not null TEXT bio"`
        BioHTML        string    `xorm:"not null TEXT bio_html"`
diff --git a/internal/migrations/migrations.go 
b/internal/migrations/migrations.go
index 2fbfbb7f..7ea0bc98 100644
--- a/internal/migrations/migrations.go
+++ b/internal/migrations/migrations.go
@@ -104,6 +104,7 @@ var migrations = []Migration{
        NewMigration("v1.5.1", "add plugin kv storage", addPluginKVStorage, 
true),
        NewMigration("v1.6.0", "move user config to interface", 
moveUserConfigToInterface, true),
        NewMigration("v1.7.0", "add optional tags", addOptionalTags, true),
+       NewMigration("v1.7.1", "expand avatar column length", 
expandAvatarColumnLength, false),
 }
 
 func GetMigrations() []Migration {
diff --git a/internal/migrations/v29.go b/internal/migrations/v29.go
new file mode 100644
index 00000000..82e120d1
--- /dev/null
+++ b/internal/migrations/v29.go
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package migrations
+
+import (
+       "context"
+       "fmt"
+
+       "xorm.io/xorm"
+)
+
+func expandAvatarColumnLength(ctx context.Context, x *xorm.Engine) error {
+       type User struct {
+               Avatar string `xorm:"not null default '' VARCHAR(2048) avatar"`
+       }
+       if err := x.Context(ctx).Sync(new(User)); err != nil {
+               return fmt.Errorf("expand avatar column length failed: %w", err)
+       }
+       return nil
+}

Reply via email to