feat: support durable task cancellation without foreign keys
This commit is contained in:
@@ -183,8 +183,7 @@ func Status(ctx context.Context, db *sql.DB) ([]MigrationStatus, error) {
|
||||
return result, rows.Err()
|
||||
}
|
||||
|
||||
// CheckSchema rejects missing, modified, dirty and unexpected versions. It does
|
||||
// not execute DDL. A matched migration ledger is not proof against manual DDL drift.
|
||||
// CheckSchema 校验迁移记录并禁止外键,不执行 DDL;不代表已核验其他手工结构漂移。
|
||||
func CheckSchema(ctx context.Context, db *sql.DB) error {
|
||||
wanted, err := Migrations()
|
||||
if err != nil {
|
||||
@@ -203,5 +202,12 @@ func CheckSchema(ctx context.Context, db *sql.DB) error {
|
||||
return errors.New("schema is dirty or does not match this binary")
|
||||
}
|
||||
}
|
||||
var foreignKeys int
|
||||
if err := db.QueryRowContext(ctx, `SELECT COUNT(*) FROM information_schema.REFERENTIAL_CONSTRAINTS WHERE CONSTRAINT_SCHEMA=DATABASE() AND LEFT(TABLE_NAME,6) IN ('orbit_','pulse_','weave_')`).Scan(&foreignKeys); err != nil {
|
||||
return err
|
||||
}
|
||||
if foreignKeys != 0 {
|
||||
return errors.New("foreign keys are forbidden on Orbit tables; apply the supported schema before starting")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user