mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
cmd: add flag to bypass strict repointment
This commit is contained in:
@@ -26,12 +26,13 @@ const (
|
||||
)
|
||||
|
||||
type options struct {
|
||||
Apply bool
|
||||
Output string
|
||||
AreaName string
|
||||
KandangLocationName string
|
||||
DBSSLMode string
|
||||
Apply bool
|
||||
Output string
|
||||
AreaName string
|
||||
KandangLocationName string
|
||||
DBSSLMode string
|
||||
DeleteKandangWarehouses bool
|
||||
SkipBlockedRefsCheck bool
|
||||
}
|
||||
|
||||
type consolidateRow struct {
|
||||
@@ -132,7 +133,7 @@ func main() {
|
||||
log.Fatalf("failed to inspect warehouse references: %v", err)
|
||||
}
|
||||
|
||||
if err := runPrechecks(ctx, db, rows, refs); err != nil {
|
||||
if err := runPrechecks(ctx, db, rows, refs, opts); err != nil {
|
||||
log.Fatalf("precheck failed: %v", err)
|
||||
}
|
||||
|
||||
@@ -157,6 +158,7 @@ func parseFlags() (*options, error) {
|
||||
flag.StringVar(&opts.KandangLocationName, "kandang-location-name", "", "Optional exact canonical kandang location filter")
|
||||
flag.StringVar(&opts.DBSSLMode, "db-sslmode", "", "Optional database sslmode override, for example: require")
|
||||
flag.BoolVar(&opts.DeleteKandangWarehouses, "delete-kandang-warehouses", true, "Soft delete kandang warehouse rows after all stocks have been moved")
|
||||
flag.BoolVar(&opts.SkipBlockedRefsCheck, "skip-blocked-refs-check", false, "Skip blocked references check (use with caution - only if you understand the stock_transfers references)")
|
||||
flag.Parse()
|
||||
|
||||
opts.Output = strings.ToLower(strings.TrimSpace(opts.Output))
|
||||
@@ -300,9 +302,11 @@ func buildReferencePlan(ctx context.Context, db *gorm.DB) (*referencePlan, error
|
||||
}, nil
|
||||
}
|
||||
|
||||
func runPrechecks(ctx context.Context, db *gorm.DB, rows []consolidateRow, refs *referencePlan) error {
|
||||
if err := ensureNoBlockedWarehouseRefsConsolidate(ctx, db, rows, refs.BlockedWarehouseRefs); err != nil {
|
||||
return err
|
||||
func runPrechecks(ctx context.Context, db *gorm.DB, rows []consolidateRow, refs *referencePlan, opts *options) error {
|
||||
if !opts.SkipBlockedRefsCheck {
|
||||
if err := ensureNoBlockedWarehouseRefsConsolidate(ctx, db, rows, refs.BlockedWarehouseRefs); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if err := ensureNoPurchaseItemWarehouseConflictsConsolidate(ctx, db, rows); err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user