diff --git a/server/Dockerfile b/server/Dockerfile index dbac3589..a57eaaef 100644 --- a/server/Dockerfile +++ b/server/Dockerfile @@ -24,7 +24,10 @@ WORKDIR /app COPY --from=build /app/skillhub-app/target/*.jar app.jar -RUN chown -R app:app /app +# Create storage directory and set permissions +RUN mkdir -p /var/lib/skillhub/storage && \ + chown -R app:app /app /var/lib/skillhub/storage + USER app EXPOSE 8080 diff --git a/server/skillhub-app/src/main/resources/db/migration/V7__fix_audit_log_jsonb_type.sql b/server/skillhub-app/src/main/resources/db/migration/V7__fix_audit_log_jsonb_type.sql new file mode 100644 index 00000000..becd1661 --- /dev/null +++ b/server/skillhub-app/src/main/resources/db/migration/V7__fix_audit_log_jsonb_type.sql @@ -0,0 +1,12 @@ +-- Fix audit_log detail_json column to properly handle JSONB type +-- This migration ensures existing data is compatible with the JSONB type + +-- The column is already defined as jsonb in V1, but we need to ensure +-- any existing string data can be properly cast to jsonb +ALTER TABLE audit_log +ALTER COLUMN detail_json TYPE jsonb +USING CASE + WHEN detail_json IS NULL THEN NULL + WHEN detail_json = '' THEN NULL + ELSE detail_json::jsonb +END; diff --git a/server/skillhub-domain/src/main/java/com/iflytek/skillhub/domain/audit/AuditLog.java b/server/skillhub-domain/src/main/java/com/iflytek/skillhub/domain/audit/AuditLog.java index 61352599..2c7e9eea 100644 --- a/server/skillhub-domain/src/main/java/com/iflytek/skillhub/domain/audit/AuditLog.java +++ b/server/skillhub-domain/src/main/java/com/iflytek/skillhub/domain/audit/AuditLog.java @@ -7,6 +7,8 @@ import jakarta.persistence.GenerationType; import jakarta.persistence.Id; import jakarta.persistence.PrePersist; import jakarta.persistence.Table; +import org.hibernate.annotations.JdbcTypeCode; +import org.hibernate.type.SqlTypes; import java.time.Instant; @Entity @@ -38,7 +40,8 @@ public class AuditLog { @Column(name = "user_agent", length = 512) private String userAgent; - @Column(name = "detail_json", columnDefinition = "jsonb") + @Column(name = "detail_json") + @JdbcTypeCode(SqlTypes.JSON) private String detailJson; @Column(name = "created_at", nullable = false, updatable = false)