feat: sync deployed v1.0.0-rc.38-custom.42

Sync production source including routing, billing, Astra detection and public uptime. Update custom build instructions and license packaging.
This commit is contained in:
cneicy committed 2026-09-26 04:49:11 +08:00
1 parent aa6c3f50f4
commit ceddfd3d6b
828 files changed
+122253 -13702

No files matched your search

+43 -2
View File
@@ -1,6 +1,7 @@
package model
import (
"fmt"
"strings"
"github.com/shopspring/decimal"
@@ -10,8 +11,8 @@ import (
"gorm.io/gorm/schema"
)
// Embed the concrete dialectors to retain their transaction/savepoint and other
// optional GORM interfaces. Only schema comparison needs normalization.
// Embed the concrete dialectors to customize schema reconciliation while
// retaining transaction/savepoint and other optional GORM interfaces.
type mysqlMigrationDialector struct{ mysql.Dialector }
func (d mysqlMigrationDialector) Migrator(db *gorm.DB) gorm.Migrator {
@@ -66,6 +67,46 @@ func (m postgresSchemaMigrator) MigrateColumn(value any, field *schema.Field, co
return m.Migrator.MigrateColumn(value, field, column)
}
// Older schemas and database imports can use a different constraint name from
// the current naming strategy. Resolve single-column uniqueness from the
// catalog instead of asking GORM to drop an inferred uni_<table>_<column>.
func (m postgresSchemaMigrator) MigrateColumnUnique(value any, field *schema.Field, column gorm.ColumnType) error {
unique, ok := column.Unique()
if !ok || field.PrimaryKey || !unique || field.Unique {
return m.Migrator.MigrateColumnUnique(value, field, column)
}
return m.RunWithValue(value, func(stmt *gorm.Statement) error {
schemaName, tableName := m.CurrentSchema(stmt, stmt.Table)
return m.DB.Transaction(func(tx *gorm.DB) error {
if err := tx.Exec("LOCK TABLE ? IN ACCESS EXCLUSIVE MODE", m.CurrentTable(stmt)).Error; err != nil {
return err
}
var constraints []string
if err := tx.Raw(`
SELECT constraint_meta.conname
FROM pg_catalog.pg_constraint AS constraint_meta
JOIN pg_catalog.pg_class AS table_meta ON table_meta.oid = constraint_meta.conrelid
JOIN pg_catalog.pg_namespace AS schema_meta ON schema_meta.oid = table_meta.relnamespace
JOIN pg_catalog.pg_attribute AS attribute_meta
ON attribute_meta.attrelid = table_meta.oid
AND attribute_meta.attnum = constraint_meta.conkey[1]
WHERE schema_meta.nspname = ? AND table_meta.relname = ?
AND constraint_meta.contype = 'u'
AND cardinality(constraint_meta.conkey) = 1
AND attribute_meta.attname = ?
ORDER BY constraint_meta.conname`, schemaName, tableName, field.DBName).Scan(&constraints).Error; err != nil {
return err
}
for _, name := range constraints {
if err := tx.Migrator().DropConstraint(value, name); err != nil {
return fmt.Errorf("drop obsolete unique constraint %q on %s.%s: %w", name, stmt.Table, field.DBName, err)
}
}
return nil
})
})
}
type charColumnType struct{ migrationColumnType }
func (charColumnType) DatabaseTypeName() string { return "char" }