diff --git a/scripts/dialect-convert/convert.py b/scripts/dialect-convert/convert.py index 497734934..2135a978d 100644 --- a/scripts/dialect-convert/convert.py +++ b/scripts/dialect-convert/convert.py @@ -274,6 +274,11 @@ def __init__(self, profile: dict): self.table_columns: dict[str, set[str]] = collections.defaultdict(set) self.dropped_columns: dict[str, set[str]] = collections.defaultdict(set) self.relations: set[str] = set() + self.pending_statements: list[str] = [] + # SQLite refuses DROP COLUMN when an index or CHECK still references the + # column, so track both to decide whether a drop can be emitted. + self.check_columns: dict[str, set[str]] = collections.defaultdict(set) + self.table_indexes: dict[str, list[tuple[str, set[str]]]] = collections.defaultdict(list) self.skipped: list[tuple[str, str, str]] = [] self.downgrades: list[tuple[str, str, str]] = [] @@ -318,8 +323,10 @@ def portable_check(self, expr: str) -> str | None: candidate = _rename_functions(RE["cast"].sub("", expr).strip(), self.p) return candidate if self.is_portable(candidate) else None - def portable_default(self, expr: str) -> str | None: + def portable_default(self, expr: str, is_array: bool = False) -> str | None: value = RE["epoch"].sub("__EPOCH__", expr.strip()) + if is_array and value.strip() in ("'{}'", '"{}"'): + return "'[]'" value = RE["cast"].sub("", value).strip() low = value.lower() if "nextval(" in low or "gen_random_uuid" in low or "uuid_generate" in low: @@ -466,6 +473,13 @@ def _table_item(self, f: str, table: str, item: str) -> str: return self._table_constraint(f, table, item) return self._column(f, table, item) + def _pin(self, table: str, expr: str) -> None: + """Record columns a surviving constraint references. + + SQLite refuses DROP COLUMN while any index or constraint mentions the + column, so every emitted constraint pins whatever it names.""" + self.check_columns[table.lower()].update(_identifiers(expr)) + def _table_constraint(self, f: str, table: str, c: str) -> str: up = c.upper() if "EXCLUDE USING" in up: @@ -496,7 +510,10 @@ def _table_constraint(self, f: str, table: str, c: str) -> str: if portable is None: self.skip(f, "non_portable_check", c) return "" + self._pin(table, portable) out = out[:open_idx + 1] + portable + out[close_idx:] + + self._pin(table, out) return out def _column(self, f: str, table: str, col: str) -> str: @@ -518,7 +535,9 @@ def _column(self, f: str, table: str, col: str) -> str: return "" self.table_columns[table.lower()].add(name.lower()) - suffix = self._modifiers(f, table, name, modifiers) + suffix = self._modifiers( + f, table, name, modifiers, is_array=bool(RE["array_suffix"].search(sql_type)) + ) return f'"{name}" {mapped}' + (f" {suffix}" if suffix else "") def _generated_column(self, f: str, table: str, name: str, rest: str) -> str: @@ -543,7 +562,9 @@ def _generated_column(self, f: str, table: str, name: str, rest: str) -> str: self.table_columns[table.lower()].add(name.lower()) return f'"{name}" {mapped} GENERATED ALWAYS AS ({portable}) {stored}' - def _modifiers(self, f: str, table: str, column: str, mods: str) -> str: + def _modifiers( + self, f: str, table: str, column: str, mods: str, is_array: bool = False + ) -> str: value = RE["collate"].sub("", RE["identity"].sub("", mods.strip())) value = RE["not_valid"].sub("", value) parts: list[str] = [] @@ -552,7 +573,7 @@ def _modifiers(self, f: str, table: str, column: str, mods: str) -> str: if dm: expr, remainder = _split_default(value[dm.end():]) value = (value[:dm.start()] + " " + remainder).strip() - portable = self.portable_default(expr) + portable = self.portable_default(expr, is_array=is_array) if portable is not None: parts.append("DEFAULT " + portable) else: @@ -566,6 +587,8 @@ def _modifiers(self, f: str, table: str, column: str, mods: str) -> str: portable = self.portable_check(value[open_idx + 1:close_idx]) if portable is not None: parts.append(f"CHECK ({portable})") + self._pin(table, portable) + self._pin(table, column) else: self.skip(f, "non_portable_check", f"{table}.{column}") value = (value[:cm.start()] + value[close_idx + 1:]).strip() @@ -594,6 +617,9 @@ def _alter_table(self, f: str, s: str) -> str: emitted = [] for action in split_top_level(actions): converted = self._alter_action(f, table, action) + if self.pending_statements: + emitted.extend(self.pending_statements) + self.pending_statements = [] if converted: emitted.append(f'ALTER TABLE "{table}" {converted};') return ("\n\n" + SPLIT_MARKER + "\n\n").join(emitted) @@ -605,14 +631,7 @@ def _alter_action(self, f: str, table: str, action: str) -> str: if RE["add_column"].match(a): return self._add_column(f, table, a) if up.startswith("DROP COLUMN"): - if not self.p["supports_drop_column"]: - self.skip(f, "drop_column_unsupported", f"{table}: {a}") - return "" - dm = RE["drop_column"].match(a) - col = (dm.group(2) or dm.group(1)) if dm else "" - self.dropped_columns[table.lower()].add(col.lower()) - self.table_columns[table.lower()].discard(col.lower()) - return f'DROP COLUMN "{col}"' + return self._drop_column(f, table, a) if up.startswith(("RENAME COLUMN", "RENAME TO")): return a if up.startswith(("ADD CONSTRAINT", "ADD PRIMARY KEY", "ADD FOREIGN KEY", "ADD UNIQUE", "ADD CHECK", "ADD EXCLUDE")): @@ -631,6 +650,41 @@ def _alter_action(self, f: str, table: str, action: str) -> str: self.skip(f, "no_op", f"{table}: {a}") return "" + def _drop_column(self, f: str, table: str, action: str) -> str: + dm = RE["drop_column"].match(action) + if not dm: + self.skip(f, "unrecognized_statement", f"{table}: {action}") + return "" + + col = (dm.group(2) or dm.group(1)).lower() + key = table.lower() + + if not self.p["supports_drop_column"]: + self.skip(f, "drop_column_unsupported", f"{table}.{col}") + return "" + + # A surviving CHECK pinned to the column makes the drop illegal, and there + # is no way to alter a CHECK out of the way in SQLite. + if col not in self.table_columns[key]: + self.skip(f, "drop_column_never_created", f"{table}.{col}") + return "" + + if col in self.check_columns[key]: + self.skip(f, "drop_column_pinned_by_constraint", f"{table}.{col}") + return "" + + blocking = [name for name, cols in self.table_indexes[key] if col in cols] + for name in blocking: + self.pending_statements.append(f'DROP INDEX IF EXISTS "{name}";') + self.table_indexes[key] = [ + (name, cols) for name, cols in self.table_indexes[key] if col not in cols + ] + + self.dropped_columns[key].add(col) + self.table_columns[key].discard(col) + + return f'DROP COLUMN "{col}"' + def _add_column(self, f: str, table: str, action: str) -> str: definition = RE["add_column"].match(action).group(1).strip() m = RE["column_def"].match(definition) @@ -687,6 +741,11 @@ def _create_index(self, f: str, s: str) -> str: columns = RE["cast"].sub("", RE["nulls_order"].sub("", RE["opclass"].sub("", columns))) tail = RE["cast"].sub("", RE["with_opts"].sub("", RE["include"].sub("", tail))) tail = re.sub(r"(?i)\s+TABLESPACE\s+\w+", "", tail).strip() or ";" + + self.table_indexes[table.lower()].append( + (_unquote(m.group(2)), _identifiers(columns) | _identifiers(tail)) + ) + return f"{header.rstrip()} ({columns}){tail}" def _view(self, f: str, s: str) -> str: @@ -716,6 +775,20 @@ def _matview(self, f: str, s: str) -> str: # helpers # -------------------------------------------------------------------------- +IDENTIFIER_RE = re.compile(r'"([^"]+)"|\b([a-z_][a-z0-9_]*)\b', re.I) + + +def _identifiers(expr: str) -> set[str]: + """Lowercased identifiers appearing in an expression, keywords included. + + Over-approximating is safe here: an extra name only makes a DROP COLUMN more + conservative, never less.""" + found = set() + for quoted, bare in IDENTIFIER_RE.findall(expr or ""): + found.add((quoted or bare).lower()) + return found + + def _unquote(v: str) -> str: return v.strip().strip('"') diff --git a/scripts/dialect-convert/profiles.py b/scripts/dialect-convert/profiles.py index 91fb1b126..6d31b278b 100644 --- a/scripts/dialect-convert/profiles.py +++ b/scripts/dialect-convert/profiles.py @@ -15,7 +15,10 @@ "int4": "INTEGER", "smallint": "INTEGER", "int2": "INTEGER", "bigserial": "INTEGER", "serial": "INTEGER", "smallserial": "INTEGER", "boolean": "INTEGER", "bool": "INTEGER", "real": "REAL", "float4": "REAL", "float8": "REAL", "double precision": "REAL", - "numeric": "NUMERIC", "decimal": "NUMERIC", "money": "NUMERIC", + # REAL rather than NUMERIC: NUMERIC affinity demotes integral values to + # INTEGER, which then refuses to scan into a Go float64. Precision is the + # same either way, and SQLite has no exact decimal regardless. + "numeric": "REAL", "decimal": "REAL", "money": "REAL", "text": "TEXT", "citext": "TEXT", "varchar": "TEXT", "character varying": "TEXT", "char": "TEXT", "character": "TEXT", "uuid": "TEXT", "json": "TEXT", "jsonb": "TEXT", "xml": "TEXT", "inet": "TEXT", "cidr": "TEXT", "macaddr": "TEXT", "interval": "TEXT", @@ -51,7 +54,7 @@ "index_methods": {"", "btree"}, "supports_add_constraint": False, "supports_alter_column": False, - "supports_drop_column": False, + "supports_drop_column": True, "supports_stored_generated_in_alter": False, "materialized_view_as_view": True, } diff --git a/services/tms/internal/core/domain/accounttype/accounttype.go b/services/tms/internal/core/domain/accounttype/accounttype.go index 54e558863..d7e33d28e 100644 --- a/services/tms/internal/core/domain/accounttype/accounttype.go +++ b/services/tms/internal/core/domain/accounttype/accounttype.go @@ -35,7 +35,7 @@ type AccountType struct { Description string `json:"description" bun:"description,type:TEXT,nullzero"` Category Category `json:"category" bun:"category,type:account_category_enum,notnull"` Color string `json:"color" bun:"color,type:VARCHAR(10),nullzero"` - IsSystem bool `json:"isSystem" bun:"is_system,type:BOOLEAN,default:false"` + IsSystem bool `json:"isSystem" bun:"is_system,type:BOOLEAN"` Version int64 `json:"version" bun:"version,type:BIGINT"` CreatedAt int64 `json:"createdAt" bun:"created_at,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,notnull,default:extract(epoch from current_timestamp)::bigint"` diff --git a/services/tms/internal/core/domain/agent/agentexception.go b/services/tms/internal/core/domain/agent/agentexception.go index 45f22e876..2ad8a2405 100644 --- a/services/tms/internal/core/domain/agent/agentexception.go +++ b/services/tms/internal/core/domain/agent/agentexception.go @@ -37,8 +37,8 @@ type AgentException struct { SubjectType SubjectType `json:"subjectType" bun:"subject_type,type:agent_subject_type_enum,notnull"` SubjectID pulid.ID `json:"subjectId" bun:"subject_id,type:VARCHAR(100),notnull"` AttemptSummary string `json:"attemptSummary" bun:"attempt_summary,type:TEXT,notnull"` - Evidence []EvidenceRef `json:"evidence" bun:"evidence,type:JSONB,notnull,default:'[]'::jsonb"` - BlastRadius int `json:"blastRadius" bun:"blast_radius,type:INTEGER,notnull,default:0"` + Evidence []EvidenceRef `json:"evidence" bun:"evidence,type:JSONB,notnull,default:'[]'"` + BlastRadius int `json:"blastRadius" bun:"blast_radius,type:INTEGER,notnull"` ResolutionState ResolutionState `json:"resolutionState" bun:"resolution_state,type:agent_resolution_state_enum,notnull,default:'Open'"` ResolutionNotes string `json:"resolutionNotes" bun:"resolution_notes,type:TEXT,nullzero"` diff --git a/services/tms/internal/core/domain/agent/agentproposal.go b/services/tms/internal/core/domain/agent/agentproposal.go index 90dee46b3..a4081abe6 100644 --- a/services/tms/internal/core/domain/agent/agentproposal.go +++ b/services/tms/internal/core/domain/agent/agentproposal.go @@ -35,10 +35,10 @@ type AgentProposal struct { RunID pulid.ID `json:"runId" bun:"run_id,type:VARCHAR(100),notnull"` ToolName string `json:"toolName" bun:"tool_name,type:VARCHAR(100),notnull"` - ToolParams map[string]any `json:"toolParams" bun:"tool_params,type:JSONB,notnull,default:'{}'::jsonb"` + ToolParams map[string]any `json:"toolParams" bun:"tool_params,type:JSONB,notnull,default:'{}'"` Confidence decimal.Decimal `json:"confidence" bun:"confidence,type:NUMERIC(5,4),notnull,default:0"` Rationale string `json:"rationale" bun:"rationale,type:TEXT,notnull"` - Evidence []EvidenceRef `json:"evidence" bun:"evidence,type:JSONB,notnull,default:'[]'::jsonb"` + Evidence []EvidenceRef `json:"evidence" bun:"evidence,type:JSONB,notnull,default:'[]'"` AutonomyTier AutonomyTier `json:"autonomyTier" bun:"autonomy_tier,type:agent_autonomy_tier_enum,notnull,default:'Propose'"` Status ProposalStatus `json:"status" bun:"status,type:agent_proposal_status_enum,notnull,default:'Pending'"` diff --git a/services/tms/internal/core/domain/apikey/usage.go b/services/tms/internal/core/domain/apikey/usage.go index 14b16b6bd..14f0539df 100644 --- a/services/tms/internal/core/domain/apikey/usage.go +++ b/services/tms/internal/core/domain/apikey/usage.go @@ -16,7 +16,7 @@ type UsageDaily struct { OrganizationID pulid.ID `json:"organizationId" bun:"organization_id,type:VARCHAR(100),notnull"` BusinessUnitID pulid.ID `json:"businessUnitId" bun:"business_unit_id,type:VARCHAR(100),notnull"` UsageDate time.Time `json:"usageDate" bun:"usage_date,pk,type:date,notnull"` - RequestCount int64 `json:"requestCount" bun:"request_count,notnull,default:0"` + RequestCount int64 `json:"requestCount" bun:"request_count,notnull"` } func (u *UsageDaily) Validate(multiErr *errortypes.MultiError) { diff --git a/services/tms/internal/core/domain/audit/auditentry.go b/services/tms/internal/core/domain/audit/auditentry.go index a173b7c10..479e5e617 100644 --- a/services/tms/internal/core/domain/audit/auditentry.go +++ b/services/tms/internal/core/domain/audit/auditentry.go @@ -36,10 +36,10 @@ type Entry struct { BusinessUnitID pulid.ID `json:"businessUnitId" bun:"business_unit_id,type:VARCHAR(100),notnull"` OrganizationID pulid.ID `json:"organizationId" bun:"organization_id,type:VARCHAR(100),notnull"` Timestamp int64 `json:"timestamp" bun:"timestamp,notnull,default:extract(epoch from current_timestamp)::bigint"` - Changes map[string]any `json:"changes,omitempty" bun:"changes,type:JSONB,default:'{}'::jsonb"` - PreviousState map[string]any `json:"previousState,omitempty" bun:"previous_state,type:JSONB,default:'{}'::jsonb"` - CurrentState map[string]any `json:"currentState,omitempty" bun:"current_state,type:JSONB,default:'{}'::jsonb"` - Metadata map[string]any `json:"metadata,omitempty" bun:"metadata,type:JSONB,default:'{}'::jsonb"` + Changes map[string]any `json:"changes,omitempty" bun:"changes,type:JSONB,default:'{}'"` + PreviousState map[string]any `json:"previousState,omitempty" bun:"previous_state,type:JSONB,default:'{}'"` + CurrentState map[string]any `json:"currentState,omitempty" bun:"current_state,type:JSONB,default:'{}'"` + Metadata map[string]any `json:"metadata,omitempty" bun:"metadata,type:JSONB,default:'{}'"` Resource permission.Resource `json:"resource" bun:"resource,type:VARCHAR(50),notnull"` // Should be the same as the resource in the permission service Operation permission.Operation `json:"operation" bun:"operation,type:VARCHAR(50),notnull"` // Should be the same as the operation in the permission service ResourceID string `json:"resourceId" bun:"resource_id,type:VARCHAR(100),notnull"` @@ -48,8 +48,8 @@ type Entry struct { Comment string `json:"comment,omitempty" bun:"comment,type:TEXT"` IPAddress string `json:"ipAddress,omitempty" bun:"ip_address,type:VARCHAR(45)"` // IPv6 addresses need space Category Category `json:"category" bun:"category,type:audit_category_enum,notnull,default:'System'"` - SensitiveData bool `json:"sensitiveData" bun:"sensitive_data,notnull,default:false"` - Critical bool `json:"critical" bun:"critical,notnull,default:false"` + SensitiveData bool `json:"sensitiveData" bun:"sensitive_data,notnull"` + Critical bool `json:"critical" bun:"critical,notnull"` User *tenant.User `json:"user,omitempty" bun:"rel:belongs-to,join:user_id=id"` APIKey *apikey.Key `json:"apiKey,omitempty" bun:"rel:belongs-to,join:api_key_id=id"` Organization *tenant.Organization `json:"-" bun:"rel:belongs-to,join:organization_id=id"` diff --git a/services/tms/internal/core/domain/audit/dlqentry.go b/services/tms/internal/core/domain/audit/dlqentry.go index 009a26edb..d7e2f7307 100644 --- a/services/tms/internal/core/domain/audit/dlqentry.go +++ b/services/tms/internal/core/domain/audit/dlqentry.go @@ -27,7 +27,7 @@ type DLQEntry struct { OriginalEntryID pulid.ID `json:"originalEntryId" bun:"original_entry_id,type:VARCHAR(100),notnull"` EntryData map[string]any `json:"entryData" bun:"entry_data,type:JSONB,notnull"` FailureTime int64 `json:"failureTime" bun:"failure_time,notnull"` - RetryCount int `json:"retryCount" bun:"retry_count,notnull,default:0"` + RetryCount int `json:"retryCount" bun:"retry_count,notnull"` LastError string `json:"lastError" bun:"last_error,type:TEXT"` NextRetryAt int64 `json:"nextRetryAt" bun:"next_retry_at"` Status DLQStatus `json:"status" bun:"status,type:VARCHAR(20),notnull,default:'pending'"` diff --git a/services/tms/internal/core/domain/bankreceipt/bankreceipt.go b/services/tms/internal/core/domain/bankreceipt/bankreceipt.go index bce9b5995..4bf23d5a5 100644 --- a/services/tms/internal/core/domain/bankreceipt/bankreceipt.go +++ b/services/tms/internal/core/domain/bankreceipt/bankreceipt.go @@ -28,7 +28,7 @@ type BankReceipt struct { ExceptionReason string `json:"exceptionReason" bun:"exception_reason,type:TEXT,nullzero"` CreatedByID pulid.ID `json:"createdById" bun:"created_by_id,type:VARCHAR(100),notnull"` UpdatedByID pulid.ID `json:"updatedById" bun:"updated_by_id,type:VARCHAR(100),nullzero"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` } diff --git a/services/tms/internal/core/domain/bankreceiptbatch/bankreceiptbatch.go b/services/tms/internal/core/domain/bankreceiptbatch/bankreceiptbatch.go index 275f40db4..cad5fb867 100644 --- a/services/tms/internal/core/domain/bankreceiptbatch/bankreceiptbatch.go +++ b/services/tms/internal/core/domain/bankreceiptbatch/bankreceiptbatch.go @@ -19,15 +19,15 @@ type BankReceiptBatch struct { Source string `json:"source" bun:"source,type:VARCHAR(100),notnull"` Reference string `json:"reference" bun:"reference,type:VARCHAR(100),nullzero"` Status Status `json:"status" bun:"status,type:VARCHAR(50),notnull"` - ImportedCount int64 `json:"importedCount" bun:"imported_count,type:BIGINT,notnull,default:0"` - MatchedCount int64 `json:"matchedCount" bun:"matched_count,type:BIGINT,notnull,default:0"` - ExceptionCount int64 `json:"exceptionCount" bun:"exception_count,type:BIGINT,notnull,default:0"` - ImportedAmountMinor int64 `json:"importedAmountMinor" bun:"imported_amount_minor,type:BIGINT,notnull,default:0"` - MatchedAmountMinor int64 `json:"matchedAmountMinor" bun:"matched_amount_minor,type:BIGINT,notnull,default:0"` - ExceptionAmountMinor int64 `json:"exceptionAmountMinor" bun:"exception_amount_minor,type:BIGINT,notnull,default:0"` + ImportedCount int64 `json:"importedCount" bun:"imported_count,type:BIGINT,notnull"` + MatchedCount int64 `json:"matchedCount" bun:"matched_count,type:BIGINT,notnull"` + ExceptionCount int64 `json:"exceptionCount" bun:"exception_count,type:BIGINT,notnull"` + ImportedAmountMinor int64 `json:"importedAmountMinor" bun:"imported_amount_minor,type:BIGINT,notnull"` + MatchedAmountMinor int64 `json:"matchedAmountMinor" bun:"matched_amount_minor,type:BIGINT,notnull"` + ExceptionAmountMinor int64 `json:"exceptionAmountMinor" bun:"exception_amount_minor,type:BIGINT,notnull"` CreatedByID pulid.ID `json:"createdById" bun:"created_by_id,type:VARCHAR(100),notnull"` UpdatedByID pulid.ID `json:"updatedById" bun:"updated_by_id,type:VARCHAR(100),nullzero"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` } diff --git a/services/tms/internal/core/domain/bankreceiptworkitem/bankreceiptworkitem.go b/services/tms/internal/core/domain/bankreceiptworkitem/bankreceiptworkitem.go index e27122654..ffa27fc89 100644 --- a/services/tms/internal/core/domain/bankreceiptworkitem/bankreceiptworkitem.go +++ b/services/tms/internal/core/domain/bankreceiptworkitem/bankreceiptworkitem.go @@ -26,7 +26,7 @@ type WorkItem struct { ResolvedAt *int64 `json:"resolvedAt" bun:"resolved_at,type:BIGINT,nullzero"` CreatedByID pulid.ID `json:"createdById" bun:"created_by_id,type:VARCHAR(100),notnull"` UpdatedByID pulid.ID `json:"updatedById" bun:"updated_by_id,type:VARCHAR(100),nullzero"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` } diff --git a/services/tms/internal/core/domain/billingqueue/billingqueue.go b/services/tms/internal/core/domain/billingqueue/billingqueue.go index 14cc3d363..25d102073 100644 --- a/services/tms/internal/core/domain/billingqueue/billingqueue.go +++ b/services/tms/internal/core/domain/billingqueue/billingqueue.go @@ -42,16 +42,16 @@ type BillingQueueItem struct { CanceledByID *pulid.ID `json:"canceledById" bun:"canceled_by_id,type:VARCHAR(100),nullzero"` CanceledAt *int64 `json:"canceledAt" bun:"canceled_at,type:BIGINT,nullzero"` CancelReason string `json:"cancelReason" bun:"cancel_reason,type:VARCHAR(100),nullzero"` - IsAdjustmentOrigin bool `json:"isAdjustmentOrigin" bun:"is_adjustment_origin,type:BOOLEAN,notnull,default:false"` + IsAdjustmentOrigin bool `json:"isAdjustmentOrigin" bun:"is_adjustment_origin,type:BOOLEAN,notnull"` SourceInvoiceID *pulid.ID `json:"sourceInvoiceId" bun:"source_invoice_id,type:VARCHAR(100),nullzero"` SourceInvoiceAdjustmentID *pulid.ID `json:"sourceInvoiceAdjustmentId" bun:"source_invoice_adjustment_id,type:VARCHAR(100),nullzero"` SourceCreditMemoInvoiceID *pulid.ID `json:"sourceCreditMemoInvoiceId" bun:"source_credit_memo_invoice_id,type:VARCHAR(100),nullzero"` CorrectionGroupID *pulid.ID `json:"correctionGroupId" bun:"correction_group_id,type:VARCHAR(100),nullzero"` RebillStrategy string `json:"rebillStrategy" bun:"rebill_strategy,type:VARCHAR(50),nullzero"` - RequiresReplacementReview bool `json:"requiresReplacementReview" bun:"requires_replacement_review,type:BOOLEAN,notnull,default:false"` + RequiresReplacementReview bool `json:"requiresReplacementReview" bun:"requires_replacement_review,type:BOOLEAN,notnull"` RerateVariancePercent decimal.Decimal `json:"rerateVariancePercent" bun:"rerate_variance_percent,type:NUMERIC(9,6),notnull,default:0"` - AdjustmentContext map[string]any `json:"adjustmentContext" bun:"adjustment_context,type:JSONB,notnull,default:'{}'::jsonb"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + AdjustmentContext map[string]any `json:"adjustmentContext" bun:"adjustment_context,type:JSONB,notnull,default:'{}'"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` diff --git a/services/tms/internal/core/domain/billingqueuefilterpreset/billingqueuefilterpreset.go b/services/tms/internal/core/domain/billingqueuefilterpreset/billingqueuefilterpreset.go index 75449b1f2..8fc9c2ca2 100644 --- a/services/tms/internal/core/domain/billingqueuefilterpreset/billingqueuefilterpreset.go +++ b/services/tms/internal/core/domain/billingqueuefilterpreset/billingqueuefilterpreset.go @@ -25,8 +25,8 @@ type BillingQueueFilterPreset struct { UserID pulid.ID `json:"userId" bun:"user_id,type:VARCHAR(100),notnull"` Name string `json:"name" bun:"name,type:VARCHAR(100),notnull"` Filters map[string]any `json:"filters" bun:"filters,type:JSONB,notnull,default:'{}'"` - IsDefault bool `json:"isDefault" bun:"is_default,type:BOOLEAN,notnull,default:false"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + IsDefault bool `json:"isDefault" bun:"is_default,type:BOOLEAN,notnull"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` } diff --git a/services/tms/internal/core/domain/commodity/commodity.go b/services/tms/internal/core/domain/commodity/commodity.go index 5413054ab..92ec5d8ab 100644 --- a/services/tms/internal/core/domain/commodity/commodity.go +++ b/services/tms/internal/core/domain/commodity/commodity.go @@ -63,8 +63,8 @@ type Commodity struct { MaxQuantityPerShipment *float64 `json:"maxQuantityPerShipment" bun:"max_quantity_per_shipment,type:NUMERIC(10,2),nullzero"` FreightClass FreightClass `json:"freightClass" bun:"freight_class,type:freight_class_enum,nullzero"` LoadingInstructions string `json:"loadingInstructions" bun:"loading_instructions,type:TEXT,nullzero"` - Stackable bool `json:"stackable" bun:"stackable,type:BOOLEAN,default:false"` - Fragile bool `json:"fragile" bun:"fragile,type:BOOLEAN,default:false"` + Stackable bool `json:"stackable" bun:"stackable,type:BOOLEAN"` + Fragile bool `json:"fragile" bun:"fragile,type:BOOLEAN"` SearchVector string `json:"-" bun:"search_vector,type:TSVECTOR,scanonly"` Rank string `json:"-" bun:"rank,type:VARCHAR(100),scanonly"` Version int64 `json:"version" bun:"version,type:BIGINT"` diff --git a/services/tms/internal/core/domain/costingcontrol/category.go b/services/tms/internal/core/domain/costingcontrol/category.go index 01e960f44..c9bc9a46b 100644 --- a/services/tms/internal/core/domain/costingcontrol/category.go +++ b/services/tms/internal/core/domain/costingcontrol/category.go @@ -34,7 +34,7 @@ type CostCategory struct { BenchmarkRatePerMile decimal.Decimal `json:"benchmarkRatePerMile" bun:"benchmark_rate_per_mile,type:NUMERIC(19,6),notnull,default:0"` OverrideRatePerMile decimal.NullDecimal `json:"overrideRatePerMile" bun:"override_rate_per_mile,type:NUMERIC(19,6),nullzero"` IsActive bool `json:"isActive" bun:"is_active,type:BOOLEAN,notnull,default:true"` - SortOrder int16 `json:"sortOrder" bun:"sort_order,type:SMALLINT,notnull,default:0"` + SortOrder int16 `json:"sortOrder" bun:"sort_order,type:SMALLINT,notnull"` Version int64 `json:"version" bun:"version,type:BIGINT"` CreatedAt int64 `json:"createdAt" bun:"created_at,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,notnull,default:extract(epoch from current_timestamp)::bigint"` diff --git a/services/tms/internal/core/domain/costingcontrol/costingcontrol.go b/services/tms/internal/core/domain/costingcontrol/costingcontrol.go index 4033d839e..18a62b2d4 100644 --- a/services/tms/internal/core/domain/costingcontrol/costingcontrol.go +++ b/services/tms/internal/core/domain/costingcontrol/costingcontrol.go @@ -30,7 +30,7 @@ type CostingControl struct { UseLiveFuelPrice bool `json:"useLiveFuelPrice" bun:"use_live_fuel_price,type:BOOLEAN,notnull,default:true"` MilesPerGallon decimal.Decimal `json:"milesPerGallon" bun:"miles_per_gallon,type:NUMERIC(6,2),notnull,default:6.5"` IncludeDeadheadMiles bool `json:"includeDeadheadMiles" bun:"include_deadhead_miles,type:BOOLEAN,notnull,default:true"` - GLActualsEnabled bool `json:"glActualsEnabled" bun:"gl_actuals_enabled,type:BOOLEAN,notnull,default:false"` + GLActualsEnabled bool `json:"glActualsEnabled" bun:"gl_actuals_enabled,type:BOOLEAN,notnull"` GLRollingMonths int16 `json:"glRollingMonths" bun:"gl_rolling_months,type:SMALLINT,notnull,default:3"` PlannedMonthlyMiles *int64 `json:"plannedMonthlyMiles" bun:"planned_monthly_miles,type:BIGINT,nullzero"` TargetMarginPercent decimal.NullDecimal `json:"targetMarginPercent" bun:"target_margin_percent,type:NUMERIC(6,3),nullzero"` diff --git a/services/tms/internal/core/domain/customer/billingprofile.go b/services/tms/internal/core/domain/customer/billingprofile.go index f72b20599..ff0d474fa 100644 --- a/services/tms/internal/core/domain/customer/billingprofile.go +++ b/services/tms/internal/core/domain/customer/billingprofile.go @@ -34,16 +34,16 @@ type CustomerBillingProfile struct { BillingCycleType BillingCycleType `json:"billingCycleType" bun:"billing_cycle_type,type:billing_cycle_type_enum,nullzero,default:'Immediate'"` BillingCycleDayOfWeek *int8 `json:"billingCycleDayOfWeek" bun:"billing_cycle_day_of_week,type:SMALLINT,nullzero"` PaymentTerm PaymentTerm `json:"paymentTerm" bun:"payment_term,type:payment_term_enum,nullzero,default:'Net30'"` - HasBillingControlOverrides bool `json:"hasBillingControlOverrides" bun:"has_billing_control_overrides,type:BOOLEAN,notnull,default:false"` + HasBillingControlOverrides bool `json:"hasBillingControlOverrides" bun:"has_billing_control_overrides,type:BOOLEAN,notnull"` CreditLimit decimal.NullDecimal `json:"creditLimit" bun:"credit_limit,type:NUMERIC(12,2),nullzero"` CreditBalance decimal.Decimal `json:"creditBalance" bun:"credit_balance,type:NUMERIC(12,2),notnull,default:0"` CreditStatus CreditStatus `json:"creditStatus" bun:"credit_status,type:credit_status_enum,notnull,default:'Active'"` - EnforceCreditLimit bool `json:"enforceCreditLimit" bun:"enforce_credit_limit,type:BOOLEAN,notnull,default:false"` - AutoCreditHold bool `json:"autoCreditHold" bun:"auto_credit_hold,type:BOOLEAN,notnull,default:false"` + EnforceCreditLimit bool `json:"enforceCreditLimit" bun:"enforce_credit_limit,type:BOOLEAN,notnull"` + AutoCreditHold bool `json:"autoCreditHold" bun:"auto_credit_hold,type:BOOLEAN,notnull"` CreditHoldReason string `json:"creditHoldReason" bun:"credit_hold_reason,type:TEXT,nullzero"` InvoiceMethod InvoiceMethod `json:"invoiceMethod" bun:"invoice_method,type:invoice_method_enum,notnull,default:'Individual'"` AutoSendInvoiceOnGeneration bool `json:"autoSendInvoiceOnGeneration" bun:"auto_send_invoice_on_generation,type:BOOLEAN,notnull,default:true"` - AllowInvoiceConsolidation bool `json:"allowInvoiceConsolidation" bun:"allow_invoice_consolidation,type:BOOLEAN,notnull,default:false"` + AllowInvoiceConsolidation bool `json:"allowInvoiceConsolidation" bun:"allow_invoice_consolidation,type:BOOLEAN,notnull"` ConsolidationPeriodDays int8 `json:"consolidationPeriodDays" bun:"consolidation_period_days,type:INTEGER,notnull,default:7"` ConsolidationGroupBy ConsolidationGroupBy `json:"consolidationGroupBy" bun:"consolidation_group_by,type:consolidation_group_by_enum,notnull,default:'None'"` InvoiceNumberFormat InvoiceNumberFormat `json:"invoiceNumberFormat" bun:"invoice_number_format,type:invoice_number_format_enum,notnull,default:'Default'"` @@ -51,22 +51,22 @@ type CustomerBillingProfile struct { InvoiceCopies int8 `json:"invoiceCopies" bun:"invoice_copies,type:SMALLINT,notnull,default:1"` RevenueAccountID *pulid.ID `json:"revenueAccountId" bun:"revenue_account_id,type:VARCHAR(100),nullzero"` ARAccountID *pulid.ID `json:"arAccountId" bun:"ar_account_id,type:VARCHAR(100),nullzero"` - ApplyLateCharges bool `json:"applyLateCharges" bun:"apply_late_charges,type:BOOLEAN,notnull,default:false"` + ApplyLateCharges bool `json:"applyLateCharges" bun:"apply_late_charges,type:BOOLEAN,notnull"` LateChargeRate decimal.NullDecimal `json:"lateChargeRate" bun:"late_charge_rate,type:NUMERIC(5,2),nullzero"` - GracePeriodDays int8 `json:"gracePeriodDays" bun:"grace_period_days,type:SMALLINT,notnull,default:0"` - TaxExempt bool `json:"taxExempt" bun:"tax_exempt,type:BOOLEAN,notnull,default:false"` + GracePeriodDays int8 `json:"gracePeriodDays" bun:"grace_period_days,type:SMALLINT,notnull"` + TaxExempt bool `json:"taxExempt" bun:"tax_exempt,type:BOOLEAN,notnull"` TaxExemptNumber string `json:"taxExemptNumber" bun:"tax_exempt_number,type:VARCHAR(50),nullzero"` EnforceCustomerBillingReq bool `json:"enforceCustomerBillingReq" bun:"enforce_customer_billing_req,type:BOOLEAN,notnull,default:true"` ValidateCustomerRates bool `json:"validateCustomerRates" bun:"validate_customer_rates,type:BOOLEAN,notnull,default:true"` AutoTransfer bool `json:"autoTransfer" bun:"auto_transfer,type:BOOLEAN,notnull,default:true"` AutoMarkReadyToBill bool `json:"autoMarkReadyToBill" bun:"auto_mark_ready_to_bill,type:BOOLEAN,notnull,default:true"` AutoBill bool `json:"autoBill" bun:"auto_bill,type:BOOLEAN,notnull,default:true"` - CountLateOnlyOnAppointmentStops bool `json:"countLateOnlyOnAppointmentStops" bun:"count_late_only_on_appointment_stops,type:BOOLEAN,notnull,default:false"` + CountLateOnlyOnAppointmentStops bool `json:"countLateOnlyOnAppointmentStops" bun:"count_late_only_on_appointment_stops,type:BOOLEAN,notnull"` AutoApplyAccessorials bool `json:"autoApplyAccessorials" bun:"auto_apply_accessorials,type:BOOLEAN,notnull,default:true"` BillingCurrency string `json:"billingCurrency" bun:"billing_currency,type:VARCHAR(3),notnull,default:'USD'"` - RequirePONumber bool `json:"requirePONumber" bun:"require_po_number,type:BOOLEAN,notnull,default:false"` - RequireBOLNumber bool `json:"requireBOLNumber" bun:"require_bol_number,type:BOOLEAN,notnull,default:false"` - RequireDeliveryNumber bool `json:"requireDeliveryNumber" bun:"require_delivery_number,type:BOOLEAN,notnull,default:false"` + RequirePONumber bool `json:"requirePONumber" bun:"require_po_number,type:BOOLEAN,notnull"` + RequireBOLNumber bool `json:"requireBOLNumber" bun:"require_bol_number,type:BOOLEAN,notnull"` + RequireDeliveryNumber bool `json:"requireDeliveryNumber" bun:"require_delivery_number,type:BOOLEAN,notnull"` InvoiceAdjustmentSupportingDocumentPolicy InvoiceAdjustmentSupportingDocumentPolicy `json:"invoiceAdjustmentSupportingDocumentPolicy" bun:"invoice_adjustment_supporting_document_policy,type:invoice_adjustment_supporting_document_policy_enum,notnull,default:'Inherit'"` DefaultBillerID *pulid.ID `json:"defaultBillerId" bun:"default_biller_id,type:VARCHAR(100),nullzero"` BillingNotes string `json:"billingNotes" bun:"billing_notes,type:TEXT,nullzero"` diff --git a/services/tms/internal/core/domain/customer/customer.go b/services/tms/internal/core/domain/customer/customer.go index 0bdf8f890..3b817bec9 100644 --- a/services/tms/internal/core/domain/customer/customer.go +++ b/services/tms/internal/core/domain/customer/customer.go @@ -38,14 +38,14 @@ type Customer struct { AddressLine2 string `json:"addressLine2" bun:"address_line_2,type:VARCHAR(150),nullzero"` City string `json:"city" bun:"city,type:VARCHAR(100),nullzero"` PostalCode string `json:"postalCode" bun:"postal_code,type:us_postal_code,notnull"` - IsGeocoded bool `json:"isGeocoded" bun:"is_geocoded,type:BOOLEAN,default:false"` + IsGeocoded bool `json:"isGeocoded" bun:"is_geocoded,type:BOOLEAN"` Longitude *float64 `json:"longitude" bun:"longitude,type:FLOAT,nullzero"` Latitude *float64 `json:"latitude" bun:"latitude,type:FLOAT,nullzero"` PlaceID string `json:"placeId" bun:"place_id,type:TEXT,nullzero"` ExternalID string `json:"externalId" bun:"external_id,type:TEXT,nullzero"` Geom *postgis.Point `json:"-" bun:"geom,type:geography,scanonly"` AllowConsolidation bool `json:"allowConsolidation" bun:"allow_consolidation,type:BOOLEAN,default:true"` - ExclusiveConsolidation bool `json:"exclusiveConsolidation" bun:"exclusive_consolidation,type:BOOLEAN,default:false"` + ExclusiveConsolidation bool `json:"exclusiveConsolidation" bun:"exclusive_consolidation,type:BOOLEAN"` ConsolidationPriority int `json:"consolidationPriority" bun:"consolidation_priority,type:INTEGER,default:1"` SearchVector string `json:"-" bun:"search_vector,type:TSVECTOR,scanonly"` Rank string `json:"-" bun:"rank,type:VARCHAR(100),scanonly"` diff --git a/services/tms/internal/core/domain/customer/emailprofile.go b/services/tms/internal/core/domain/customer/emailprofile.go index c219cf379..a6f79b21a 100644 --- a/services/tms/internal/core/domain/customer/emailprofile.go +++ b/services/tms/internal/core/domain/customer/emailprofile.go @@ -28,8 +28,8 @@ type CustomerEmailProfile struct { CCRecipients string `json:"ccRecipients" bun:"cc_recipients,type:TEXT,nullzero"` BCCRecipients string `json:"bccRecipients" bun:"bcc_recipients,type:TEXT,nullzero"` AttachmentName string `json:"attachmentName" bun:"attachment_name,type:VARCHAR(255)"` - ReadReceipt bool `json:"readReceipt" bun:"read_receipt,type:BOOLEAN,notnull,default:false"` - IncludeShipmentDetail bool `json:"includeShipmentDetail" bun:"include_shipment_detail,type:BOOLEAN,notnull,default:false"` + ReadReceipt bool `json:"readReceipt" bun:"read_receipt,type:BOOLEAN,notnull"` + IncludeShipmentDetail bool `json:"includeShipmentDetail" bun:"include_shipment_detail,type:BOOLEAN,notnull"` Version int64 `json:"version" bun:"version,type:BIGINT"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` diff --git a/services/tms/internal/core/domain/customerpayment/customerpayment.go b/services/tms/internal/core/domain/customerpayment/customerpayment.go index 55e8b15ea..af7c526fd 100644 --- a/services/tms/internal/core/domain/customerpayment/customerpayment.go +++ b/services/tms/internal/core/domain/customerpayment/customerpayment.go @@ -26,8 +26,8 @@ type Payment struct { PaymentDate int64 `json:"paymentDate" bun:"payment_date,type:BIGINT,notnull"` AccountingDate int64 `json:"accountingDate" bun:"accounting_date,type:BIGINT,notnull"` AmountMinor int64 `json:"amountMinor" bun:"amount_minor,type:BIGINT,notnull"` - AppliedAmountMinor int64 `json:"appliedAmountMinor" bun:"applied_amount_minor,type:BIGINT,notnull,default:0"` - UnappliedAmountMinor int64 `json:"unappliedAmountMinor" bun:"unapplied_amount_minor,type:BIGINT,notnull,default:0"` + AppliedAmountMinor int64 `json:"appliedAmountMinor" bun:"applied_amount_minor,type:BIGINT,notnull"` + UnappliedAmountMinor int64 `json:"unappliedAmountMinor" bun:"unapplied_amount_minor,type:BIGINT,notnull"` Status Status `json:"status" bun:"status,type:VARCHAR(50),notnull"` PaymentMethod Method `json:"paymentMethod" bun:"payment_method,type:VARCHAR(50),notnull"` ReferenceNumber string `json:"referenceNumber" bun:"reference_number,type:VARCHAR(100),nullzero"` @@ -40,7 +40,7 @@ type Payment struct { ReversalReason string `json:"reversalReason" bun:"reversal_reason,type:TEXT,nullzero"` CreatedByID pulid.ID `json:"createdById" bun:"created_by_id,type:VARCHAR(100),notnull"` UpdatedByID pulid.ID `json:"updatedById" bun:"updated_by_id,type:VARCHAR(100),nullzero"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` @@ -56,7 +56,7 @@ type Application struct { CustomerPaymentID pulid.ID `json:"customerPaymentId" bun:"customer_payment_id,type:VARCHAR(100),notnull"` InvoiceID pulid.ID `json:"invoiceId" bun:"invoice_id,type:VARCHAR(100),notnull"` AppliedAmountMinor int64 `json:"appliedAmountMinor" bun:"applied_amount_minor,type:BIGINT,notnull"` - ShortPayAmountMinor int64 `json:"shortPayAmountMinor" bun:"short_pay_amount_minor,type:BIGINT,notnull,default:0"` + ShortPayAmountMinor int64 `json:"shortPayAmountMinor" bun:"short_pay_amount_minor,type:BIGINT,notnull"` LineNumber int `json:"lineNumber" bun:"line_number,type:INTEGER,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` diff --git a/services/tms/internal/core/domain/customfield/customfield.go b/services/tms/internal/core/domain/customfield/customfield.go index ac2e534ad..9b5ccb947 100644 --- a/services/tms/internal/core/domain/customfield/customfield.go +++ b/services/tms/internal/core/domain/customfield/customfield.go @@ -35,9 +35,9 @@ type CustomFieldDefinition struct { Label string `json:"label" bun:"label,type:VARCHAR(150),notnull"` Description string `json:"description" bun:"description,type:TEXT,nullzero"` FieldType FieldType `json:"fieldType" bun:"field_type,type:custom_field_type_enum,notnull"` - IsRequired bool `json:"isRequired" bun:"is_required,default:false"` + IsRequired bool `json:"isRequired" bun:"is_required"` IsActive bool `json:"isActive" bun:"is_active,default:true"` - DisplayOrder int `json:"displayOrder" bun:"display_order,default:0"` + DisplayOrder int `json:"displayOrder" bun:"display_order"` Color string `json:"color" bun:"color,type:VARCHAR(20),nullzero"` Options []SelectOption `json:"options" bun:"options,type:JSONB"` ValidationRules *ValidationRules `json:"validationRules" bun:"validation_rules,type:JSONB"` diff --git a/services/tms/internal/core/domain/dedicatedlane/patternconfig.go b/services/tms/internal/core/domain/dedicatedlane/patternconfig.go index e079f1fa0..4744e06e3 100644 --- a/services/tms/internal/core/domain/dedicatedlane/patternconfig.go +++ b/services/tms/internal/core/domain/dedicatedlane/patternconfig.go @@ -27,7 +27,7 @@ type PatternConfig struct { BusinessUnitID pulid.ID `json:"businessUnitId" bun:"business_unit_id,type:VARCHAR(100),pk,notnull"` OrganizationID pulid.ID `json:"organizationId" bun:"organization_id,type:VARCHAR(100),pk,notnull"` Enabled bool `json:"enabled" bun:"enabled,type:BOOLEAN,notnull,default:true"` - RequireExactMatch bool `json:"requireExactMatch" bun:"require_exact_match,type:BOOLEAN,notnull,default:false"` + RequireExactMatch bool `json:"requireExactMatch" bun:"require_exact_match,type:BOOLEAN,notnull"` WeightRecentShipments bool `json:"weightRecentShipments" bun:"weight_recent_shipments,type:BOOLEAN,notnull,default:true"` MinConfidenceScore decimal.Decimal `json:"minConfidenceScore" bun:"min_confidence_score,type:NUMERIC(5,4),notnull,default:0.7"` MinFrequency int64 `json:"minFrequency" bun:"min_frequency,type:INTEGER,notnull,default:3"` diff --git a/services/tms/internal/core/domain/detention/evidence.go b/services/tms/internal/core/domain/detention/evidence.go index 656164a50..e522679f3 100644 --- a/services/tms/internal/core/domain/detention/evidence.go +++ b/services/tms/internal/core/domain/detention/evidence.go @@ -38,7 +38,7 @@ type DetentionEvidence struct { BusinessUnitID pulid.ID `json:"businessUnitId" bun:"business_unit_id,pk,type:VARCHAR(100),notnull"` OrganizationID pulid.ID `json:"organizationId" bun:"organization_id,pk,type:VARCHAR(100),notnull"` DetentionOccurrenceID pulid.ID `json:"detentionOccurrenceId" bun:"detention_occurrence_id,type:VARCHAR(100),notnull"` - Sequence int32 `json:"sequence" bun:"sequence,type:INTEGER,notnull,default:0"` + Sequence int32 `json:"sequence" bun:"sequence,type:INTEGER,notnull"` Kind EvidenceKind `json:"kind" bun:"kind,type:detention_evidence_kind_enum,notnull"` Source EvidenceSource `json:"source" bun:"source,type:detention_evidence_source_enum,notnull"` Summary string `json:"summary" bun:"summary,type:TEXT,notnull"` diff --git a/services/tms/internal/core/domain/detention/notice.go b/services/tms/internal/core/domain/detention/notice.go index 082292023..4ebe72ea9 100644 --- a/services/tms/internal/core/domain/detention/notice.go +++ b/services/tms/internal/core/domain/detention/notice.go @@ -59,9 +59,9 @@ type DetentionNotice struct { FailureReason string `json:"failureReason" bun:"failure_reason,type:TEXT,nullzero"` ProviderMessageID string `json:"providerMessageId" bun:"provider_message_id,type:VARCHAR(255),nullzero"` SentByID *pulid.ID `json:"sentById" bun:"sent_by_id,type:VARCHAR(100),nullzero"` - WasAutomatic bool `json:"wasAutomatic" bun:"was_automatic,type:BOOLEAN,notnull,default:false"` - SatisfiesRequirement bool `json:"satisfiesRequirement" bun:"satisfies_requirement,type:BOOLEAN,notnull,default:false"` - QuotedFreeMinutes int32 `json:"quotedFreeMinutes" bun:"quoted_free_minutes,type:INTEGER,notnull,default:0"` + WasAutomatic bool `json:"wasAutomatic" bun:"was_automatic,type:BOOLEAN,notnull"` + SatisfiesRequirement bool `json:"satisfiesRequirement" bun:"satisfies_requirement,type:BOOLEAN,notnull"` + QuotedFreeMinutes int32 `json:"quotedFreeMinutes" bun:"quoted_free_minutes,type:INTEGER,notnull"` QuotedRate decimal.NullDecimal `json:"quotedRate" bun:"quoted_rate,type:NUMERIC(19,4),nullzero"` QuotedAmount decimal.NullDecimal `json:"quotedAmount" bun:"quoted_amount,type:NUMERIC(19,4),nullzero"` Version int64 `json:"version" bun:"version,type:BIGINT"` diff --git a/services/tms/internal/core/domain/detention/occurrence.go b/services/tms/internal/core/domain/detention/occurrence.go index 9d4314281..4f26ce90b 100644 --- a/services/tms/internal/core/domain/detention/occurrence.go +++ b/services/tms/internal/core/domain/detention/occurrence.go @@ -52,27 +52,27 @@ type DetentionOccurrence struct { NoticeDueAt *int64 `json:"noticeDueAt" bun:"notice_due_at,type:BIGINT,nullzero"` NoticeDeadlineAt *int64 `json:"noticeDeadlineAt" bun:"notice_deadline_at,type:BIGINT,nullzero"` IsOpen bool `json:"isOpen" bun:"is_open,type:BOOLEAN,notnull,default:true"` - ArrivedLate bool `json:"arrivedLate" bun:"arrived_late,type:BOOLEAN,notnull,default:false"` - LateByMinutes int32 `json:"lateByMinutes" bun:"late_by_minutes,type:INTEGER,notnull,default:0"` - FreeMinutesGranted int32 `json:"freeMinutesGranted" bun:"free_minutes_granted,type:INTEGER,notnull,default:0"` - RawDwellMinutes int32 `json:"rawDwellMinutes" bun:"raw_dwell_minutes,type:INTEGER,notnull,default:0"` - BillableMinutes int32 `json:"billableMinutes" bun:"billable_minutes,type:INTEGER,notnull,default:0"` - RoundedMinutes int32 `json:"roundedMinutes" bun:"rounded_minutes,type:INTEGER,notnull,default:0"` + ArrivedLate bool `json:"arrivedLate" bun:"arrived_late,type:BOOLEAN,notnull"` + LateByMinutes int32 `json:"lateByMinutes" bun:"late_by_minutes,type:INTEGER,notnull"` + FreeMinutesGranted int32 `json:"freeMinutesGranted" bun:"free_minutes_granted,type:INTEGER,notnull"` + RawDwellMinutes int32 `json:"rawDwellMinutes" bun:"raw_dwell_minutes,type:INTEGER,notnull"` + BillableMinutes int32 `json:"billableMinutes" bun:"billable_minutes,type:INTEGER,notnull"` + RoundedMinutes int32 `json:"roundedMinutes" bun:"rounded_minutes,type:INTEGER,notnull"` BillableUnits decimal.Decimal `json:"billableUnits" bun:"billable_units,type:NUMERIC(12,4),notnull,default:0"` GrossAmount decimal.Decimal `json:"grossAmount" bun:"gross_amount,type:NUMERIC(19,4),notnull,default:0"` BillableAmount decimal.Decimal `json:"billableAmount" bun:"billable_amount,type:NUMERIC(19,4),notnull,default:0"` - DriverPayMinutes int32 `json:"driverPayMinutes" bun:"driver_pay_minutes,type:INTEGER,notnull,default:0"` + DriverPayMinutes int32 `json:"driverPayMinutes" bun:"driver_pay_minutes,type:INTEGER,notnull"` DriverPayAmount decimal.Decimal `json:"driverPayAmount" bun:"driver_pay_amount,type:NUMERIC(19,4),notnull,default:0"` NetMargin decimal.Decimal `json:"netMargin" bun:"net_margin,type:NUMERIC(19,4),notnull,default:0"` CapApplied CapKind `json:"capApplied" bun:"cap_applied,type:detention_cap_kind_enum,notnull,default:'None'"` - ConvertedToLayover bool `json:"convertedToLayover" bun:"converted_to_layover,type:BOOLEAN,notnull,default:false"` + ConvertedToLayover bool `json:"convertedToLayover" bun:"converted_to_layover,type:BOOLEAN,notnull"` Currency string `json:"currency" bun:"currency,type:VARCHAR(3),notnull,default:'USD'"` Status OccurrenceStatus `json:"status" bun:"status,type:detention_occurrence_status_enum,notnull,default:'Accruing'"` NotificationStatus NotificationStatus `json:"notificationStatus" bun:"notification_status,type:detention_notification_status_enum,notnull,default:'NotRequired'"` NoticeSentAt *int64 `json:"noticeSentAt" bun:"notice_sent_at,type:BIGINT,nullzero"` - SuppressedByGate bool `json:"suppressedByGate" bun:"suppressed_by_gate,type:BOOLEAN,notnull,default:false"` - RequiresApproval bool `json:"requiresApproval" bun:"requires_approval,type:BOOLEAN,notnull,default:false"` + SuppressedByGate bool `json:"suppressedByGate" bun:"suppressed_by_gate,type:BOOLEAN,notnull"` + RequiresApproval bool `json:"requiresApproval" bun:"requires_approval,type:BOOLEAN,notnull"` ApprovedByID *pulid.ID `json:"approvedById" bun:"approved_by_id,type:VARCHAR(100),nullzero"` ApprovedAt *int64 `json:"approvedAt" bun:"approved_at,type:BIGINT,nullzero"` WaiverReason *WaiverReason `json:"waiverReason" bun:"waiver_reason,type:detention_waiver_reason_enum,nullzero"` @@ -83,7 +83,7 @@ type DetentionOccurrence struct { DisputeNote string `json:"disputeNote" bun:"dispute_note,type:TEXT,nullzero"` DisputedAt *int64 `json:"disputedAt" bun:"disputed_at,type:BIGINT,nullzero"` - CollectabilityScore int16 `json:"collectabilityScore" bun:"collectability_score,type:SMALLINT,notnull,default:0"` + CollectabilityScore int16 `json:"collectabilityScore" bun:"collectability_score,type:SMALLINT,notnull"` EvidenceHead string `json:"evidenceHead" bun:"evidence_head,type:VARCHAR(64),nullzero"` AdditionalChargeID *pulid.ID `json:"additionalChargeId" bun:"additional_charge_id,type:VARCHAR(100),nullzero"` diff --git a/services/tms/internal/core/domain/detention/policy.go b/services/tms/internal/core/domain/detention/policy.go index 366c9387b..ebf3b909a 100644 --- a/services/tms/internal/core/domain/detention/policy.go +++ b/services/tms/internal/core/domain/detention/policy.go @@ -50,9 +50,9 @@ type DetentionPolicy struct { Description string `json:"description" bun:"description,type:TEXT,nullzero"` Status PolicyStatus `json:"status" bun:"status,type:detention_policy_status_enum,notnull,default:'Draft'"` - IsOrgDefault bool `json:"isOrgDefault" bun:"is_org_default,type:BOOLEAN,notnull,default:false"` - Priority int16 `json:"priority" bun:"priority,type:SMALLINT,notnull,default:0"` - SpecificityScore int32 `json:"specificityScore" bun:"specificity_score,type:INTEGER,notnull,default:0"` + IsOrgDefault bool `json:"isOrgDefault" bun:"is_org_default,type:BOOLEAN,notnull"` + Priority int16 `json:"priority" bun:"priority,type:SMALLINT,notnull"` + SpecificityScore int32 `json:"specificityScore" bun:"specificity_score,type:INTEGER,notnull"` CustomerID *pulid.ID `json:"customerId" bun:"customer_id,type:VARCHAR(100),nullzero"` LocationID *pulid.ID `json:"locationId" bun:"location_id,type:VARCHAR(100),nullzero"` ShipmentTypeIDs []pulid.ID `json:"shipmentTypeIds" bun:"shipment_type_ids,type:JSONB,nullzero"` @@ -60,17 +60,17 @@ type DetentionPolicy struct { CommodityIDs []pulid.ID `json:"commodityIds" bun:"commodity_ids,type:JSONB,nullzero"` StopTypes []shipment.StopType `json:"stopTypes" bun:"stop_types,type:JSONB,nullzero"` - AppointmentStopsOnly bool `json:"appointmentStopsOnly" bun:"appointment_stops_only,type:BOOLEAN,notnull,default:false"` + AppointmentStopsOnly bool `json:"appointmentStopsOnly" bun:"appointment_stops_only,type:BOOLEAN,notnull"` EffectiveStartDate *int64 `json:"effectiveStartDate" bun:"effective_start_date,type:BIGINT,nullzero"` EffectiveEndDate *int64 `json:"effectiveEndDate" bun:"effective_end_date,type:BIGINT,nullzero"` ClockStartBasis ClockStartBasis `json:"clockStartBasis" bun:"clock_start_basis,type:detention_clock_start_basis_enum,notnull,default:'LaterOfArrivalOrAppointment'"` LateArrivalRule LateArrivalRule `json:"lateArrivalRule" bun:"late_arrival_rule,type:detention_late_arrival_rule_enum,notnull,default:'NoEffect'"` - LateArrivalGraceMinutes int16 `json:"lateArrivalGraceMinutes" bun:"late_arrival_grace_minutes,type:SMALLINT,notnull,default:0"` + LateArrivalGraceMinutes int16 `json:"lateArrivalGraceMinutes" bun:"late_arrival_grace_minutes,type:SMALLINT,notnull"` BillingFreeMinutes int32 `json:"billingFreeMinutes" bun:"billing_free_minutes,type:INTEGER,notnull,default:120"` PickupFreeMinutes *int32 `json:"pickupFreeMinutes" bun:"pickup_free_minutes,type:INTEGER,nullzero"` DeliveryFreeMinutes *int32 `json:"deliveryFreeMinutes" bun:"delivery_free_minutes,type:INTEGER,nullzero"` PayFreeMinutes *int32 `json:"payFreeMinutes" bun:"pay_free_minutes,type:INTEGER,nullzero"` - MinimumBillableMinutes int32 `json:"minimumBillableMinutes" bun:"minimum_billable_minutes,type:INTEGER,notnull,default:0"` + MinimumBillableMinutes int32 `json:"minimumBillableMinutes" bun:"minimum_billable_minutes,type:INTEGER,notnull"` BillingIncrementMinutes int16 `json:"billingIncrementMinutes" bun:"billing_increment_minutes,type:SMALLINT,notnull,default:15"` RoundingMode RoundingMode `json:"roundingMode" bun:"rounding_mode,type:detention_rounding_mode_enum,notnull,default:'Up'"` RateSource RateSource `json:"rateSource" bun:"rate_source,type:detention_rate_source_enum,notnull,default:'Accessorial'"` @@ -85,11 +85,11 @@ type DetentionPolicy struct { NotificationRequirement NotificationRequirement `json:"notificationRequirement" bun:"notification_requirement,type:detention_notification_requirement_enum,notnull,default:'None'"` NotificationLeadMinutes int16 `json:"notificationLeadMinutes" bun:"notification_lead_minutes,type:SMALLINT,notnull,default:30"` - NotificationDeadlineMinutes int16 `json:"notificationDeadlineMinutes" bun:"notification_deadline_minutes,type:SMALLINT,notnull,default:0"` + NotificationDeadlineMinutes int16 `json:"notificationDeadlineMinutes" bun:"notification_deadline_minutes,type:SMALLINT,notnull"` UnnotifiedBehavior UnnotifiedBehavior `json:"unnotifiedBehavior" bun:"unnotified_behavior,type:detention_unnotified_behavior_enum,notnull,default:'Bill'"` - AutoSendNotice bool `json:"autoSendNotice" bun:"auto_send_notice,type:BOOLEAN,notnull,default:false"` - AttachNoticePDF bool `json:"attachNoticePdf" bun:"attach_notice_pdf,type:BOOLEAN,notnull,default:false"` - SendDepartureSummary bool `json:"sendDepartureSummary" bun:"send_departure_summary,type:BOOLEAN,notnull,default:false"` + AutoSendNotice bool `json:"autoSendNotice" bun:"auto_send_notice,type:BOOLEAN,notnull"` + AttachNoticePDF bool `json:"attachNoticePdf" bun:"attach_notice_pdf,type:BOOLEAN,notnull"` + SendDepartureSummary bool `json:"sendDepartureSummary" bun:"send_departure_summary,type:BOOLEAN,notnull"` RequireApprovalOverAmount decimal.NullDecimal `json:"requireApprovalOverAmount" bun:"require_approval_over_amount,type:NUMERIC(19,4),nullzero"` AutoApproveUnderAmount decimal.NullDecimal `json:"autoApproveUnderAmount" bun:"auto_approve_under_amount,type:NUMERIC(19,4),nullzero"` Currency string `json:"currency" bun:"currency,type:VARCHAR(3),notnull,default:'USD'"` diff --git a/services/tms/internal/core/domain/detention/tier.go b/services/tms/internal/core/domain/detention/tier.go index c54b3f3f2..f5bca10f2 100644 --- a/services/tms/internal/core/domain/detention/tier.go +++ b/services/tms/internal/core/domain/detention/tier.go @@ -26,12 +26,12 @@ type DetentionPolicyTier struct { BusinessUnitID pulid.ID `json:"businessUnitId" bun:"business_unit_id,pk,type:VARCHAR(100),notnull"` OrganizationID pulid.ID `json:"organizationId" bun:"organization_id,pk,type:VARCHAR(100),notnull"` DetentionPolicyID pulid.ID `json:"detentionPolicyId" bun:"detention_policy_id,type:VARCHAR(100),notnull"` - FromMinute int32 `json:"fromMinute" bun:"from_minute,type:INTEGER,notnull,default:0"` + FromMinute int32 `json:"fromMinute" bun:"from_minute,type:INTEGER,notnull"` ToMinute *int32 `json:"toMinute" bun:"to_minute,type:INTEGER,nullzero"` Rate decimal.Decimal `json:"rate" bun:"rate,type:NUMERIC(19,4),notnull,default:0"` RateUnit TierRateUnit `json:"rateUnit" bun:"rate_unit,type:detention_tier_rate_unit_enum,notnull,default:'Hour'"` Label string `json:"label" bun:"label,type:VARCHAR(100),nullzero"` - SortOrder int32 `json:"sortOrder" bun:"sort_order,type:INTEGER,notnull,default:0"` + SortOrder int32 `json:"sortOrder" bun:"sort_order,type:INTEGER,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` } diff --git a/services/tms/internal/core/domain/dispatchcontrol/dispatchcontrol.go b/services/tms/internal/core/domain/dispatchcontrol/dispatchcontrol.go index f901b74ed..8f82f4da0 100644 --- a/services/tms/internal/core/domain/dispatchcontrol/dispatchcontrol.go +++ b/services/tms/internal/core/domain/dispatchcontrol/dispatchcontrol.go @@ -34,19 +34,19 @@ type DispatchControl struct { ID pulid.ID `json:"id" bun:"id,pk,type:VARCHAR(100)"` BusinessUnitID pulid.ID `json:"businessUnitId" bun:"business_unit_id,type:VARCHAR(100),notnull,pk"` OrganizationID pulid.ID `json:"organizationId" bun:"organization_id,type:VARCHAR(100),notnull,pk"` - EnableAutoAssignment bool `json:"enableAutoAssignment" bun:"enable_auto_assignment,type:BOOLEAN,notnull,default:false"` + EnableAutoAssignment bool `json:"enableAutoAssignment" bun:"enable_auto_assignment,type:BOOLEAN,notnull"` AutoAssignmentStrategy AutoAssignmentStrategy `json:"autoAssignmentStrategy" bun:"auto_assignment_strategy,type:auto_assignment_strategy_enum,notnull,default:'Proximity'"` - EnforceWorkerAssign bool `json:"enforceWorkerAssign" bun:"enforce_worker_assign,type:BOOLEAN,notnull,default:false"` - EnforceTrailerContinuity bool `json:"enforceTrailerContinuity" bun:"enforce_trailer_continuity,type:BOOLEAN,notnull,default:false"` - EnforceHOSCompliance bool `json:"enforceHosCompliance" bun:"enforce_hos_compliance,type:BOOLEAN,notnull,default:false"` - EnforceWorkerPTARestrictions bool `json:"enforceWorkerPtaRestrictions" bun:"enforce_worker_pta_restrictions,type:BOOLEAN,notnull,default:false"` - EnforceWorkerTractorFleetContinuity bool `json:"enforceWorkerTractorFleetContinuity" bun:"enforce_worker_tractor_fleet_continuity,type:BOOLEAN,notnull,default:false"` - EnforceDriverQualificationCompliance bool `json:"enforceDriverQualificationCompliance" bun:"enforce_driver_qualification_compliance,type:BOOLEAN,notnull,default:false"` - EnforceMedicalCertCompliance bool `json:"enforceMedicalCertCompliance" bun:"enforce_medical_cert_compliance,type:BOOLEAN,notnull,default:false"` - EnforceHazmatCompliance bool `json:"enforceHazmatCompliance" bun:"enforce_hazmat_compliance,type:BOOLEAN,notnull,default:false"` - EnforceDrugAndAlcoholCompliance bool `json:"enforceDrugAndAlcoholCompliance" bun:"enforce_drug_and_alcohol_compliance,type:BOOLEAN,notnull,default:false"` - EnableAutoStopActuals bool `json:"enableAutoStopActuals" bun:"enable_auto_stop_actuals,type:BOOLEAN,notnull,default:false"` - ScoringWeights ScoringWeights `json:"scoringWeights" bun:"scoring_weights,type:JSONB,notnull,default:'{}'::jsonb"` + EnforceWorkerAssign bool `json:"enforceWorkerAssign" bun:"enforce_worker_assign,type:BOOLEAN,notnull"` + EnforceTrailerContinuity bool `json:"enforceTrailerContinuity" bun:"enforce_trailer_continuity,type:BOOLEAN,notnull"` + EnforceHOSCompliance bool `json:"enforceHosCompliance" bun:"enforce_hos_compliance,type:BOOLEAN,notnull"` + EnforceWorkerPTARestrictions bool `json:"enforceWorkerPtaRestrictions" bun:"enforce_worker_pta_restrictions,type:BOOLEAN,notnull"` + EnforceWorkerTractorFleetContinuity bool `json:"enforceWorkerTractorFleetContinuity" bun:"enforce_worker_tractor_fleet_continuity,type:BOOLEAN,notnull"` + EnforceDriverQualificationCompliance bool `json:"enforceDriverQualificationCompliance" bun:"enforce_driver_qualification_compliance,type:BOOLEAN,notnull"` + EnforceMedicalCertCompliance bool `json:"enforceMedicalCertCompliance" bun:"enforce_medical_cert_compliance,type:BOOLEAN,notnull"` + EnforceHazmatCompliance bool `json:"enforceHazmatCompliance" bun:"enforce_hazmat_compliance,type:BOOLEAN,notnull"` + EnforceDrugAndAlcoholCompliance bool `json:"enforceDrugAndAlcoholCompliance" bun:"enforce_drug_and_alcohol_compliance,type:BOOLEAN,notnull"` + EnableAutoStopActuals bool `json:"enableAutoStopActuals" bun:"enable_auto_stop_actuals,type:BOOLEAN,notnull"` + ScoringWeights ScoringWeights `json:"scoringWeights" bun:"scoring_weights,type:JSONB,notnull,default:'{}'"` AutoAssignConfidenceThreshold decimal.Decimal `json:"autoAssignConfidenceThreshold" bun:"auto_assign_confidence_threshold,type:NUMERIC(5,4),notnull,default:0.85"` AutoAssignMaxDeadheadMiles *int32 `json:"autoAssignMaxDeadheadMiles" bun:"auto_assign_max_deadhead_miles,type:INTEGER,nullzero"` AutoAssignPlanningHorizonHours int16 `json:"autoAssignPlanningHorizonHours" bun:"auto_assign_planning_horizon_hours,type:SMALLINT,notnull,default:48"` diff --git a/services/tms/internal/core/domain/distancecalculation/distancecalculationrun.go b/services/tms/internal/core/domain/distancecalculation/distancecalculationrun.go index 3bbc537f1..d7d38b877 100644 --- a/services/tms/internal/core/domain/distancecalculation/distancecalculationrun.go +++ b/services/tms/internal/core/domain/distancecalculation/distancecalculationrun.go @@ -32,7 +32,7 @@ type Run struct { Status string `json:"status" bun:"status,type:VARCHAR(50),notnull"` ErrorCode string `json:"errorCode" bun:"error_code,type:VARCHAR(100),nullzero"` ErrorMessage string `json:"errorMessage" bun:"error_message,type:TEXT,nullzero"` - LatencyMillis int64 `json:"latencyMillis" bun:"latency_millis,type:BIGINT,notnull,default:0"` + LatencyMillis int64 `json:"latencyMillis" bun:"latency_millis,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` } diff --git a/services/tms/internal/core/domain/distancecontrol/distancecontrol.go b/services/tms/internal/core/domain/distancecontrol/distancecontrol.go index ed4d695ec..005735464 100644 --- a/services/tms/internal/core/domain/distancecontrol/distancecontrol.go +++ b/services/tms/internal/core/domain/distancecontrol/distancecontrol.go @@ -50,7 +50,7 @@ type DistanceControl struct { EtaOutOfRouteDistanceProfileID pulid.ID `json:"etaOutOfRouteDistanceProfileId" bun:"eta_out_of_route_distance_profile_id,type:VARCHAR(100),notnull"` DistanceCalculatorShortestDistanceProfileID pulid.ID `json:"distanceCalculatorShortestDistanceProfileId" bun:"distance_calculator_shortest_distance_profile_id,type:VARCHAR(100),notnull"` DistanceCalculatorPracticalDistanceProfileID pulid.ID `json:"distanceCalculatorPracticalDistanceProfileId" bun:"distance_calculator_practical_distance_profile_id,type:VARCHAR(100),notnull"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` SearchVector string `json:"-" bun:"search_vector,type:TSVECTOR,scanonly"` diff --git a/services/tms/internal/core/domain/distanceprofile/distanceprofile.go b/services/tms/internal/core/domain/distanceprofile/distanceprofile.go index 995a2125e..af4ad5e3b 100644 --- a/services/tms/internal/core/domain/distanceprofile/distanceprofile.go +++ b/services/tms/internal/core/domain/distanceprofile/distanceprofile.go @@ -60,7 +60,7 @@ type DistanceProfile struct { TollRoads bool `json:"tollRoads" bun:"toll_roads,type:BOOLEAN,notnull"` BordersOpen bool `json:"bordersOpen" bun:"borders_open,type:BOOLEAN,notnull"` IncludeTollData bool `json:"includeTollData" bun:"include_toll_data,type:BOOLEAN,notnull"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` SearchVector string `json:"-" bun:"search_vector,type:TSVECTOR,scanonly"` diff --git a/services/tms/internal/core/domain/document/document.go b/services/tms/internal/core/domain/document/document.go index 94bd13e38..1978b06fb 100644 --- a/services/tms/internal/core/domain/document/document.go +++ b/services/tms/internal/core/domain/document/document.go @@ -161,7 +161,7 @@ type Document struct { StorageVersionID string `json:"storageVersionId" bun:"storage_version_id,type:VARCHAR(255),nullzero"` StorageRetentionMode string `json:"storageRetentionMode" bun:"storage_retention_mode,type:VARCHAR(50),nullzero"` StorageRetentionUntil *int64 `json:"storageRetentionUntil" bun:"storage_retention_until,type:BIGINT,nullzero"` - StorageLegalHold bool `json:"storageLegalHold" bun:"storage_legal_hold,type:BOOLEAN,notnull,default:false"` + StorageLegalHold bool `json:"storageLegalHold" bun:"storage_legal_hold,type:BOOLEAN,notnull"` CryptoMode string `json:"cryptoMode" bun:"crypto_mode,type:VARCHAR(32),notnull,default:'envelope_v1'"` CryptoVersion int16 `json:"cryptoVersion" bun:"crypto_version,type:SMALLINT,notnull,default:1"` Status Status `json:"status" bun:"status,type:document_status_enum,notnull,default:'Active'"` @@ -171,7 +171,7 @@ type Document struct { ProcessingProfile ProcessingProfile `json:"processingProfile" bun:"processing_profile,type:VARCHAR(64),notnull,default:'none'"` ExpirationDate *int64 `json:"expirationDate" bun:"expiration_date,type:BIGINT,nullzero"` Tags []string `json:"tags" bun:"tags,type:VARCHAR(100)[],default:'{}'"` - IsPublic bool `json:"isPublic" bun:"is_public,type:BOOLEAN,notnull,default:false"` + IsPublic bool `json:"isPublic" bun:"is_public,type:BOOLEAN,notnull"` UploadedByID pulid.ID `json:"uploadedById" bun:"uploaded_by_id,type:VARCHAR(100),notnull"` ApprovedByID pulid.ID `json:"approvedById" bun:"approved_by_id,type:VARCHAR(100),nullzero"` ApprovedAt *int64 `json:"approvedAt" bun:"approved_at,type:BIGINT,nullzero"` @@ -180,7 +180,7 @@ type Document struct { ContentStatus ContentStatus `json:"contentStatus" bun:"content_status,type:document_content_status_enum,notnull,nullzero,default:'Pending'"` ContentError string `json:"contentError" bun:"content_error,type:TEXT,nullzero"` DetectedKind string `json:"detectedKind" bun:"detected_kind,type:VARCHAR(100),nullzero"` - HasExtractedText bool `json:"hasExtractedText" bun:"has_extracted_text,type:BOOLEAN,notnull,default:false"` + HasExtractedText bool `json:"hasExtractedText" bun:"has_extracted_text,type:BOOLEAN,notnull"` ShipmentDraftStatus ShipmentDraftStatus `json:"shipmentDraftStatus" bun:"shipment_draft_status,type:document_shipment_draft_status_enum,notnull,nullzero,default:'Unavailable'"` DocumentTypeID *pulid.ID `json:"documentTypeId" bun:"document_type_id,type:VARCHAR(100),nullzero"` SearchVector string `json:"-" bun:"search_vector,type:TSVECTOR,scanonly"` diff --git a/services/tms/internal/core/domain/documentaiextraction/extraction.go b/services/tms/internal/core/domain/documentaiextraction/extraction.go index 7a7068395..4f13f9e8c 100644 --- a/services/tms/internal/core/domain/documentaiextraction/extraction.go +++ b/services/tms/internal/core/domain/documentaiextraction/extraction.go @@ -42,7 +42,7 @@ type Extraction struct { SubmittedAt *int64 `json:"submittedAt" bun:"submitted_at,type:BIGINT,nullzero"` LastPolledAt *int64 `json:"lastPolledAt" bun:"last_polled_at,type:BIGINT,nullzero"` CompletedAt *int64 `json:"completedAt" bun:"completed_at,type:BIGINT,nullzero"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` } diff --git a/services/tms/internal/core/domain/documentcontent/content.go b/services/tms/internal/core/domain/documentcontent/content.go index 146b32025..72b1a5325 100644 --- a/services/tms/internal/core/domain/documentcontent/content.go +++ b/services/tms/internal/core/domain/documentcontent/content.go @@ -36,16 +36,16 @@ type Content struct { BusinessUnitID pulid.ID `json:"businessUnitId" bun:"business_unit_id,type:VARCHAR(100),notnull,pk"` Status Status `json:"status" bun:"status,type:document_content_status_enum,notnull,default:'Pending'"` ContentText string `json:"contentText" bun:"content_text,type:TEXT,nullzero"` - PageCount int `json:"pageCount" bun:"page_count,type:INTEGER,notnull,default:0"` + PageCount int `json:"pageCount" bun:"page_count,type:INTEGER,notnull"` SourceKind SourceKind `json:"sourceKind" bun:"source_kind,type:VARCHAR(20),nullzero"` DetectedLanguage string `json:"detectedLanguage" bun:"detected_language,type:VARCHAR(20),nullzero"` DetectedDocumentKind string `json:"detectedDocumentKind" bun:"detected_document_kind,type:VARCHAR(100),nullzero"` - ClassificationConfidence float64 `json:"classificationConfidence" bun:"classification_confidence,type:DOUBLE PRECISION,notnull,default:0"` - StructuredData map[string]any `json:"structuredData" bun:"structured_data,type:JSONB,notnull,default:'{}'::jsonb"` + ClassificationConfidence float64 `json:"classificationConfidence" bun:"classification_confidence,type:DOUBLE PRECISION,notnull"` + StructuredData map[string]any `json:"structuredData" bun:"structured_data,type:JSONB,notnull,default:'{}'"` FailureCode string `json:"failureCode" bun:"failure_code,type:VARCHAR(100),nullzero"` FailureMessage string `json:"failureMessage" bun:"failure_message,type:TEXT,nullzero"` SearchVector string `json:"-" bun:"search_vector,type:TSVECTOR,scanonly"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` LastExtractedAt *int64 `json:"lastExtractedAt" bun:"last_extracted_at,type:BIGINT,nullzero"` diff --git a/services/tms/internal/core/domain/documentcontent/page.go b/services/tms/internal/core/domain/documentcontent/page.go index f391e3db9..568e2d6e6 100644 --- a/services/tms/internal/core/domain/documentcontent/page.go +++ b/services/tms/internal/core/domain/documentcontent/page.go @@ -21,12 +21,12 @@ type Page struct { PageNumber int `json:"pageNumber" bun:"page_number,type:INTEGER,notnull"` SourceKind SourceKind `json:"sourceKind" bun:"source_kind,type:VARCHAR(20),notnull"` ExtractedText string `json:"extractedText" bun:"extracted_text,type:TEXT,nullzero"` - OCRConfidence float64 `json:"ocrConfidence" bun:"ocr_confidence,type:DOUBLE PRECISION,notnull,default:0"` - PreprocessingApplied bool `json:"preprocessingApplied" bun:"preprocessing_applied,type:BOOLEAN,notnull,default:false"` - Width int `json:"width" bun:"width,type:INTEGER,notnull,default:0"` - Height int `json:"height" bun:"height,type:INTEGER,notnull,default:0"` - Metadata map[string]any `json:"metadata" bun:"metadata,type:JSONB,notnull,default:'{}'::jsonb"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + OCRConfidence float64 `json:"ocrConfidence" bun:"ocr_confidence,type:DOUBLE PRECISION,notnull"` + PreprocessingApplied bool `json:"preprocessingApplied" bun:"preprocessing_applied,type:BOOLEAN,notnull"` + Width int `json:"width" bun:"width,type:INTEGER,notnull"` + Height int `json:"height" bun:"height,type:INTEGER,notnull"` + Metadata map[string]any `json:"metadata" bun:"metadata,type:JSONB,notnull,default:'{}'"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` } diff --git a/services/tms/internal/core/domain/documentpacketrule/rule.go b/services/tms/internal/core/domain/documentpacketrule/rule.go index 5f4c25d39..e76f6371c 100644 --- a/services/tms/internal/core/domain/documentpacketrule/rule.go +++ b/services/tms/internal/core/domain/documentpacketrule/rule.go @@ -58,10 +58,10 @@ type DocumentPacketRule struct { BusinessUnitID pulid.ID `json:"businessUnitId" bun:"business_unit_id,type:VARCHAR(100),pk,notnull"` ResourceType string `json:"resourceType" bun:"resource_type,type:VARCHAR(100),notnull"` DocumentTypeID pulid.ID `json:"documentTypeId" bun:"document_type_id,type:VARCHAR(100),notnull"` - Required bool `json:"required" bun:"required,type:BOOLEAN,notnull,default:false"` - AllowMultiple bool `json:"allowMultiple" bun:"allow_multiple,type:BOOLEAN,notnull,default:false"` - DisplayOrder int `json:"displayOrder" bun:"display_order,type:INTEGER,notnull,default:0"` - ExpirationRequired bool `json:"expirationRequired" bun:"expiration_required,type:BOOLEAN,notnull,default:false"` + Required bool `json:"required" bun:"required,type:BOOLEAN,notnull"` + AllowMultiple bool `json:"allowMultiple" bun:"allow_multiple,type:BOOLEAN,notnull"` + DisplayOrder int `json:"displayOrder" bun:"display_order,type:INTEGER,notnull"` + ExpirationRequired bool `json:"expirationRequired" bun:"expiration_required,type:BOOLEAN,notnull"` ExpirationWarningDays int `json:"expirationWarningDays" bun:"expiration_warning_days,type:INTEGER,notnull,default:30"` Version int64 `json:"version" bun:"version,type:BIGINT"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` diff --git a/services/tms/internal/core/domain/documentparsingrule/model.go b/services/tms/internal/core/domain/documentparsingrule/model.go index 1bd4d25c7..b642cb598 100644 --- a/services/tms/internal/core/domain/documentparsingrule/model.go +++ b/services/tms/internal/core/domain/documentparsingrule/model.go @@ -37,7 +37,7 @@ type RuleSet struct { DocumentKind DocumentKind `json:"documentKind" bun:"document_kind,type:VARCHAR(100),notnull"` Priority int `json:"priority" bun:"priority,type:INTEGER,notnull,default:100"` PublishedVersionID *pulid.ID `json:"publishedVersionId" bun:"published_version_id,type:VARCHAR(100),nullzero"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` } @@ -96,12 +96,12 @@ type RuleVersion struct { Status VersionStatus `json:"status" bun:"status,type:VARCHAR(20),notnull,default:'Draft'"` Label string `json:"label" bun:"label,type:VARCHAR(255),nullzero"` ParserMode ParserMode `json:"parserMode" bun:"parser_mode,type:VARCHAR(50),notnull,default:'merge_with_base'"` - MatchConfig MatchConfig `json:"matchConfig" bun:"match_config,type:JSONB,notnull,default:'{}'::jsonb"` - RuleDocument RuleDocument `json:"ruleDocument" bun:"rule_document,type:JSONB,notnull,default:'{}'::jsonb"` - ValidationSummary map[string]any `json:"validationSummary" bun:"validation_summary,type:JSONB,notnull,default:'{}'::jsonb"` + MatchConfig MatchConfig `json:"matchConfig" bun:"match_config,type:JSONB,notnull,default:'{}'"` + RuleDocument RuleDocument `json:"ruleDocument" bun:"rule_document,type:JSONB,notnull,default:'{}'"` + ValidationSummary map[string]any `json:"validationSummary" bun:"validation_summary,type:JSONB,notnull,default:'{}'"` PublishedAt *int64 `json:"publishedAt" bun:"published_at,type:BIGINT,nullzero"` PublishedByID *pulid.ID `json:"publishedById" bun:"published_by_id,type:VARCHAR(100),nullzero"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` RuleSet *RuleSet `json:"ruleSet,omitempty" bun:"rel:belongs-to,join:rule_set_id=id"` @@ -189,9 +189,9 @@ type Fixture struct { FileName string `json:"fileName" bun:"file_name,type:VARCHAR(255),nullzero"` ProviderFingerprint string `json:"providerFingerprint" bun:"provider_fingerprint,type:VARCHAR(100),nullzero"` TextSnapshot string `json:"textSnapshot" bun:"text_snapshot,type:TEXT,notnull"` - PageSnapshots []PageSnapshot `json:"pageSnapshots" bun:"page_snapshots,type:JSONB,notnull,default:'[]'::jsonb"` - Assertions FixtureAssertions `json:"assertions" bun:"assertions,type:JSONB,notnull,default:'{}'::jsonb"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + PageSnapshots []PageSnapshot `json:"pageSnapshots" bun:"page_snapshots,type:JSONB,notnull,default:'[]'"` + Assertions FixtureAssertions `json:"assertions" bun:"assertions,type:JSONB,notnull,default:'{}'"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` } diff --git a/services/tms/internal/core/domain/documentshipmentdraft/draft.go b/services/tms/internal/core/domain/documentshipmentdraft/draft.go index 528a832ab..cc7a81723 100644 --- a/services/tms/internal/core/domain/documentshipmentdraft/draft.go +++ b/services/tms/internal/core/domain/documentshipmentdraft/draft.go @@ -28,14 +28,14 @@ type DocumentShipmentDraft struct { BusinessUnitID pulid.ID `json:"businessUnitId" bun:"business_unit_id,type:VARCHAR(100),notnull,pk"` Status Status `json:"status" bun:"status,type:document_shipment_draft_status_enum,notnull,default:'Unavailable'"` DocumentKind string `json:"documentKind" bun:"document_kind,type:VARCHAR(100),nullzero"` - Confidence float64 `json:"confidence" bun:"confidence,type:DOUBLE PRECISION,notnull,default:0"` - DraftData map[string]any `json:"draftData" bun:"draft_data,type:JSONB,notnull,default:'{}'::jsonb"` + Confidence float64 `json:"confidence" bun:"confidence,type:DOUBLE PRECISION,notnull"` + DraftData map[string]any `json:"draftData" bun:"draft_data,type:JSONB,notnull,default:'{}'"` FailureCode string `json:"failureCode" bun:"failure_code,type:VARCHAR(100),nullzero"` FailureMessage string `json:"failureMessage" bun:"failure_message,type:TEXT,nullzero"` AttachedShipmentID *pulid.ID `json:"attachedShipmentId" bun:"attached_shipment_id,type:VARCHAR(100),nullzero"` AttachedAt *int64 `json:"attachedAt" bun:"attached_at,type:BIGINT,nullzero"` AttachedByID *pulid.ID `json:"attachedById" bun:"attached_by_id,type:VARCHAR(100),nullzero"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` } diff --git a/services/tms/internal/core/domain/documenttemplate/assignment.go b/services/tms/internal/core/domain/documenttemplate/assignment.go index 074ead568..d2f46acad 100644 --- a/services/tms/internal/core/domain/documenttemplate/assignment.go +++ b/services/tms/internal/core/domain/documenttemplate/assignment.go @@ -46,7 +46,7 @@ type DocumentTemplateAssignment struct { AssignedByID *pulid.ID `json:"assignedById" bun:"assigned_by_id,type:VARCHAR(100),nullzero"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` diff --git a/services/tms/internal/core/domain/documenttemplate/generated.go b/services/tms/internal/core/domain/documenttemplate/generated.go index 26a89291f..ed9764ad6 100644 --- a/services/tms/internal/core/domain/documenttemplate/generated.go +++ b/services/tms/internal/core/domain/documenttemplate/generated.go @@ -133,7 +133,7 @@ type GeneratedDocument struct { FileName string `json:"fileName" bun:"file_name,type:VARCHAR(255),notnull"` FilePath string `json:"filePath" bun:"file_path,type:VARCHAR(500),nullzero"` - FileSize int64 `json:"fileSize" bun:"file_size,type:BIGINT,notnull,default:0"` + FileSize int64 `json:"fileSize" bun:"file_size,type:BIGINT,notnull"` MimeType string `json:"mimeType" bun:"mime_type,type:VARCHAR(100),notnull,default:'application/pdf'"` Checksum string `json:"checksum" bun:"checksum,type:VARCHAR(64),nullzero"` @@ -154,7 +154,7 @@ type GeneratedDocument struct { DeliveredAt *int64 `json:"deliveredAt" bun:"delivered_at,type:BIGINT,nullzero"` DeliveredTo string `json:"deliveredTo" bun:"delivered_to,type:VARCHAR(255),nullzero"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` diff --git a/services/tms/internal/core/domain/documenttemplate/template.go b/services/tms/internal/core/domain/documenttemplate/template.go index 070ecccc2..1c3e6db6e 100644 --- a/services/tms/internal/core/domain/documenttemplate/template.go +++ b/services/tms/internal/core/domain/documenttemplate/template.go @@ -61,13 +61,13 @@ type DocumentTemplate struct { // IsOrgDefault marks the template every customer without an assignment gets. // A partial unique index enforces one per kind. - IsOrgDefault bool `json:"isOrgDefault" bun:"is_org_default,type:BOOLEAN,notnull,default:false"` + IsOrgDefault bool `json:"isOrgDefault" bun:"is_org_default,type:BOOLEAN,notnull"` // ActiveVersionID is what renders. Nil means the template has only drafts and // resolution therefore falls through to the built-in. ActiveVersionID *pulid.ID `json:"activeVersionId" bun:"active_version_id,type:VARCHAR(100),nullzero"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` CreatedByID *pulid.ID `json:"createdById" bun:"created_by_id,type:VARCHAR(100),nullzero"` diff --git a/services/tms/internal/core/domain/documenttemplate/version.go b/services/tms/internal/core/domain/documenttemplate/version.go index 08002cf16..a5ad6c312 100644 --- a/services/tms/internal/core/domain/documenttemplate/version.go +++ b/services/tms/internal/core/domain/documenttemplate/version.go @@ -107,7 +107,7 @@ type DocumentTemplateVersion struct { ArchivedByID *pulid.ID `json:"archivedById" bun:"archived_by_id,type:VARCHAR(100),nullzero"` ArchivedAt *int64 `json:"archivedAt" bun:"archived_at,type:BIGINT,nullzero"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` CreatedByID *pulid.ID `json:"createdById" bun:"created_by_id,type:VARCHAR(100),nullzero"` diff --git a/services/tms/internal/core/domain/documenttype/documenttype.go b/services/tms/internal/core/domain/documenttype/documenttype.go index 8d35fb5f3..1712df43b 100644 --- a/services/tms/internal/core/domain/documenttype/documenttype.go +++ b/services/tms/internal/core/domain/documenttype/documenttype.go @@ -35,7 +35,7 @@ type DocumentType struct { Color string `json:"color" bun:"color,type:VARCHAR(10),nullzero"` DocumentClassification DocumentClassification `json:"documentClassification" bun:"document_classification,type:document_classification_enum,notnull,default:'Public'"` DocumentCategory DocumentCategory `json:"documentCategory" bun:"document_category,type:document_category_enum,notnull,default:'Other'"` - IsSystem bool `json:"isSystem" bun:"is_system,type:BOOLEAN,default:false"` + IsSystem bool `json:"isSystem" bun:"is_system,type:BOOLEAN"` Version int64 `json:"version" bun:"version,type:BIGINT"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` diff --git a/services/tms/internal/core/domain/documentupload/session.go b/services/tms/internal/core/domain/documentupload/session.go index a2652d29a..9db8e6838 100644 --- a/services/tms/internal/core/domain/documentupload/session.go +++ b/services/tms/internal/core/domain/documentupload/session.go @@ -39,8 +39,8 @@ type DocumentUploadSession struct { Status Status `json:"status" bun:"status,type:document_upload_session_status_enum,notnull,default:'Initiated'"` Description string `json:"description" bun:"description,type:TEXT,nullzero"` Tags []string `json:"tags" bun:"tags,type:VARCHAR(100)[],default:'{}'"` - UploadedParts []storage.UploadedPart `json:"uploadedParts" bun:"uploaded_parts,type:JSONB,notnull,default:'[]'::jsonb"` - PartSize int64 `json:"partSize" bun:"part_size,type:BIGINT,notnull,default:0"` + UploadedParts []storage.UploadedPart `json:"uploadedParts" bun:"uploaded_parts,type:JSONB,notnull,default:'[]'"` + PartSize int64 `json:"partSize" bun:"part_size,type:BIGINT,notnull"` FailureCode string `json:"failureCode" bun:"failure_code,type:VARCHAR(100),nullzero"` FailureMessage string `json:"failureMessage" bun:"failure_message,type:TEXT,nullzero"` ExpiresAt int64 `json:"expiresAt" bun:"expires_at,type:BIGINT,notnull"` diff --git a/services/tms/internal/core/domain/driverpay/advance.go b/services/tms/internal/core/domain/driverpay/advance.go index c64b1ae8e..cda98b725 100644 --- a/services/tms/internal/core/domain/driverpay/advance.go +++ b/services/tms/internal/core/domain/driverpay/advance.go @@ -33,15 +33,15 @@ type PayAdvance struct { Reference string `json:"reference" bun:"reference,type:VARCHAR(100),nullzero"` IssuedDate int64 `json:"issuedDate" bun:"issued_date,type:BIGINT,notnull"` AmountMinor int64 `json:"amountMinor" bun:"amount_minor,type:BIGINT,notnull"` - RecoveredMinor int64 `json:"recoveredMinor" bun:"recovered_minor,type:BIGINT,notnull,default:0"` - WrittenOffMinor int64 `json:"writtenOffMinor" bun:"written_off_minor,type:BIGINT,notnull,default:0"` + RecoveredMinor int64 `json:"recoveredMinor" bun:"recovered_minor,type:BIGINT,notnull"` + WrittenOffMinor int64 `json:"writtenOffMinor" bun:"written_off_minor,type:BIGINT,notnull"` WriteOffReason string `json:"writeOffReason" bun:"write_off_reason,type:TEXT,nullzero"` Notes string `json:"notes" bun:"notes,type:TEXT,nullzero"` CurrencyCode string `json:"currencyCode" bun:"currency_code,type:VARCHAR(3),notnull,default:'USD'"` CreatedByID pulid.ID `json:"createdById" bun:"created_by_id,type:VARCHAR(100),nullzero"` WrittenOffByID pulid.ID `json:"writtenOffById" bun:"written_off_by_id,type:VARCHAR(100),nullzero"` WrittenOffAt *int64 `json:"writtenOffAt" bun:"written_off_at,type:BIGINT,nullzero"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` diff --git a/services/tms/internal/core/domain/driverpay/assignment.go b/services/tms/internal/core/domain/driverpay/assignment.go index 61234bb06..1004f3c4f 100644 --- a/services/tms/internal/core/domain/driverpay/assignment.go +++ b/services/tms/internal/core/domain/driverpay/assignment.go @@ -37,7 +37,7 @@ type WorkerPayAssignment struct { RateOverrides []RateOverride `json:"rateOverrides" bun:"rate_overrides,type:JSONB,nullzero"` Notes string `json:"notes" bun:"notes,type:TEXT,nullzero"` CreatedByID pulid.ID `json:"createdById" bun:"created_by_id,type:VARCHAR(100),nullzero"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` diff --git a/services/tms/internal/core/domain/driverpay/escrow.go b/services/tms/internal/core/domain/driverpay/escrow.go index 4f84e6410..cfbc25968 100644 --- a/services/tms/internal/core/domain/driverpay/escrow.go +++ b/services/tms/internal/core/domain/driverpay/escrow.go @@ -31,14 +31,14 @@ type EscrowAccount struct { OrganizationID pulid.ID `json:"organizationId" bun:"organization_id,pk,type:VARCHAR(100),notnull"` WorkerID pulid.ID `json:"workerId" bun:"worker_id,type:VARCHAR(100),notnull"` Status EscrowAccountStatus `json:"status" bun:"status,type:VARCHAR(50),notnull,default:'Active'"` - TargetAmountMinor int64 `json:"targetAmountMinor" bun:"target_amount_minor,type:BIGINT,notnull,default:0"` - BalanceMinor int64 `json:"balanceMinor" bun:"balance_minor,type:BIGINT,notnull,default:0"` + TargetAmountMinor int64 `json:"targetAmountMinor" bun:"target_amount_minor,type:BIGINT,notnull"` + BalanceMinor int64 `json:"balanceMinor" bun:"balance_minor,type:BIGINT,notnull"` AnnualInterestRate decimal.Decimal `json:"annualInterestRate" bun:"annual_interest_rate,type:NUMERIC(7,4),notnull,default:0"` LastInterestAccrualDate *int64 `json:"lastInterestAccrualDate" bun:"last_interest_accrual_date,type:BIGINT,nullzero"` OpenedDate int64 `json:"openedDate" bun:"opened_date,type:BIGINT,notnull"` ClosedDate *int64 `json:"closedDate" bun:"closed_date,type:BIGINT,nullzero"` CurrencyCode string `json:"currencyCode" bun:"currency_code,type:VARCHAR(3),notnull,default:'USD'"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` diff --git a/services/tms/internal/core/domain/driverpay/expense.go b/services/tms/internal/core/domain/driverpay/expense.go index 86a0cf0c6..a3a5d24aa 100644 --- a/services/tms/internal/core/domain/driverpay/expense.go +++ b/services/tms/internal/core/domain/driverpay/expense.go @@ -70,7 +70,7 @@ type Expense struct { ReviewedByID *pulid.ID `json:"reviewedById" bun:"reviewed_by_id,type:VARCHAR(100),nullzero"` ReviewedAt *int64 `json:"reviewedAt" bun:"reviewed_at,type:BIGINT,nullzero"` SettlementLineID *pulid.ID `json:"settlementLineId" bun:"settlement_line_id,type:VARCHAR(100),nullzero"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` diff --git a/services/tms/internal/core/domain/driverpay/paycode.go b/services/tms/internal/core/domain/driverpay/paycode.go index c66f55fad..c310b5643 100644 --- a/services/tms/internal/core/domain/driverpay/paycode.go +++ b/services/tms/internal/core/domain/driverpay/paycode.go @@ -57,8 +57,8 @@ type PayCode struct { CountsTowardGuarantee bool `json:"countsTowardGuarantee" bun:"counts_toward_guarantee,type:BOOLEAN,notnull,default:true"` GLAccountID *pulid.ID `json:"glAccountId" bun:"gl_account_id,type:VARCHAR(100),nullzero"` DefaultAmountMinor *int64 `json:"defaultAmountMinor" bun:"default_amount_minor,type:BIGINT,nullzero"` - IsSystem bool `json:"isSystem" bun:"is_system,type:BOOLEAN,notnull,default:false"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + IsSystem bool `json:"isSystem" bun:"is_system,type:BOOLEAN,notnull"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` diff --git a/services/tms/internal/core/domain/driverpay/payprofile.go b/services/tms/internal/core/domain/driverpay/payprofile.go index 304588866..b28779e6a 100644 --- a/services/tms/internal/core/domain/driverpay/payprofile.go +++ b/services/tms/internal/core/domain/driverpay/payprofile.go @@ -35,10 +35,10 @@ type PayProfile struct { Description string `json:"description" bun:"description,type:TEXT,nullzero"` Classification PayeeClassification `json:"classification" bun:"classification,type:VARCHAR(50),notnull,default:'CompanyDriver'"` CurrencyCode string `json:"currencyCode" bun:"currency_code,type:VARCHAR(3),notnull,default:'USD'"` - GuaranteedPeriodMinimumMinor int64 `json:"guaranteedPeriodMinimumMinor" bun:"guaranteed_period_minimum_minor,type:BIGINT,notnull,default:0"` + GuaranteedPeriodMinimumMinor int64 `json:"guaranteedPeriodMinimumMinor" bun:"guaranteed_period_minimum_minor,type:BIGINT,notnull"` PerDiemRatePerMile decimal.Decimal `json:"perDiemRatePerMile" bun:"per_diem_rate_per_mile,type:NUMERIC(19,4),notnull,default:0"` - PerDiemDailyCapMinor int64 `json:"perDiemDailyCapMinor" bun:"per_diem_daily_cap_minor,type:BIGINT,notnull,default:0"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + PerDiemDailyCapMinor int64 `json:"perDiemDailyCapMinor" bun:"per_diem_daily_cap_minor,type:BIGINT,notnull"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` @@ -66,10 +66,10 @@ type PayProfileComponent struct { Rate decimal.Decimal `json:"rate" bun:"rate,type:NUMERIC(19,4),notnull,default:0"` RevenueBasis RevenueBasis `json:"revenueBasis" bun:"revenue_basis,type:VARCHAR(50),nullzero"` Bands []MileageBand `json:"bands" bun:"bands,type:JSONB,nullzero"` - FreeTimeMinutes int `json:"freeTimeMinutes" bun:"free_time_minutes,type:INTEGER,notnull,default:0"` + FreeTimeMinutes int `json:"freeTimeMinutes" bun:"free_time_minutes,type:INTEGER,notnull"` MinAmountMinor *int64 `json:"minAmountMinor" bun:"min_amount_minor,type:BIGINT,nullzero"` MaxAmountMinor *int64 `json:"maxAmountMinor" bun:"max_amount_minor,type:BIGINT,nullzero"` - Sequence int `json:"sequence" bun:"sequence,type:INTEGER,notnull,default:0"` + Sequence int `json:"sequence" bun:"sequence,type:INTEGER,notnull"` IsActive bool `json:"isActive" bun:"is_active,type:BOOLEAN,notnull,default:true"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` diff --git a/services/tms/internal/core/domain/driverpay/recurringdeduction.go b/services/tms/internal/core/domain/driverpay/recurringdeduction.go index 96042dc22..73dd7c1de 100644 --- a/services/tms/internal/core/domain/driverpay/recurringdeduction.go +++ b/services/tms/internal/core/domain/driverpay/recurringdeduction.go @@ -35,12 +35,12 @@ type RecurringDeduction struct { Description string `json:"description" bun:"description,type:VARCHAR(255),notnull"` AmountMinor int64 `json:"amountMinor" bun:"amount_minor,type:BIGINT,notnull"` TotalCapMinor *int64 `json:"totalCapMinor" bun:"total_cap_minor,type:BIGINT,nullzero"` - DeductedToDateMinor int64 `json:"deductedToDateMinor" bun:"deducted_to_date_minor,type:BIGINT,notnull,default:0"` + DeductedToDateMinor int64 `json:"deductedToDateMinor" bun:"deducted_to_date_minor,type:BIGINT,notnull"` StartDate int64 `json:"startDate" bun:"start_date,type:BIGINT,notnull"` EndDate *int64 `json:"endDate" bun:"end_date,type:BIGINT,nullzero"` CurrencyCode string `json:"currencyCode" bun:"currency_code,type:VARCHAR(3),notnull,default:'USD'"` CreatedByID pulid.ID `json:"createdById" bun:"created_by_id,type:VARCHAR(100),nullzero"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` diff --git a/services/tms/internal/core/domain/driverpay/recurringearning.go b/services/tms/internal/core/domain/driverpay/recurringearning.go index c05f0524f..ded01cf7d 100644 --- a/services/tms/internal/core/domain/driverpay/recurringearning.go +++ b/services/tms/internal/core/domain/driverpay/recurringearning.go @@ -34,12 +34,12 @@ type RecurringEarning struct { Description string `json:"description" bun:"description,type:VARCHAR(255),notnull"` AmountMinor int64 `json:"amountMinor" bun:"amount_minor,type:BIGINT,notnull"` TotalCapMinor *int64 `json:"totalCapMinor" bun:"total_cap_minor,type:BIGINT,nullzero"` - PaidToDateMinor int64 `json:"paidToDateMinor" bun:"paid_to_date_minor,type:BIGINT,notnull,default:0"` + PaidToDateMinor int64 `json:"paidToDateMinor" bun:"paid_to_date_minor,type:BIGINT,notnull"` StartDate int64 `json:"startDate" bun:"start_date,type:BIGINT,notnull"` EndDate *int64 `json:"endDate" bun:"end_date,type:BIGINT,nullzero"` CurrencyCode string `json:"currencyCode" bun:"currency_code,type:VARCHAR(3),notnull,default:'USD'"` CreatedByID pulid.ID `json:"createdById" bun:"created_by_id,type:VARCHAR(100),nullzero"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` diff --git a/services/tms/internal/core/domain/driversettlement/batch.go b/services/tms/internal/core/domain/driversettlement/batch.go index d49fbd819..d3912d236 100644 --- a/services/tms/internal/core/domain/driversettlement/batch.go +++ b/services/tms/internal/core/domain/driversettlement/batch.go @@ -32,10 +32,10 @@ type SettlementBatch struct { PeriodStart int64 `json:"periodStart" bun:"period_start,type:BIGINT,notnull"` PeriodEnd int64 `json:"periodEnd" bun:"period_end,type:BIGINT,notnull"` PayDate int64 `json:"payDate" bun:"pay_date,type:BIGINT,notnull"` - SettlementCount int `json:"settlementCount" bun:"settlement_count,type:INTEGER,notnull,default:0"` - ExceptionCount int `json:"exceptionCount" bun:"exception_count,type:INTEGER,notnull,default:0"` - TotalGrossMinor int64 `json:"totalGrossMinor" bun:"total_gross_minor,type:BIGINT,notnull,default:0"` - TotalNetMinor int64 `json:"totalNetMinor" bun:"total_net_minor,type:BIGINT,notnull,default:0"` + SettlementCount int `json:"settlementCount" bun:"settlement_count,type:INTEGER,notnull"` + ExceptionCount int `json:"exceptionCount" bun:"exception_count,type:INTEGER,notnull"` + TotalGrossMinor int64 `json:"totalGrossMinor" bun:"total_gross_minor,type:BIGINT,notnull"` + TotalNetMinor int64 `json:"totalNetMinor" bun:"total_net_minor,type:BIGINT,notnull"` CurrencyCode string `json:"currencyCode" bun:"currency_code,type:VARCHAR(3),notnull,default:'USD'"` Notes string `json:"notes" bun:"notes,type:TEXT,nullzero"` GeneratedByID pulid.ID `json:"generatedById" bun:"generated_by_id,type:VARCHAR(100),nullzero"` @@ -43,7 +43,7 @@ type SettlementBatch struct { CompletedAt *int64 `json:"completedAt" bun:"completed_at,type:BIGINT,nullzero"` CanceledByID pulid.ID `json:"canceledById" bun:"canceled_by_id,type:VARCHAR(100),nullzero"` CanceledAt *int64 `json:"canceledAt" bun:"canceled_at,type:BIGINT,nullzero"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` diff --git a/services/tms/internal/core/domain/driversettlement/dispute.go b/services/tms/internal/core/domain/driversettlement/dispute.go index 218e8c7f6..1729e76bf 100644 --- a/services/tms/internal/core/domain/driversettlement/dispute.go +++ b/services/tms/internal/core/domain/driversettlement/dispute.go @@ -89,7 +89,7 @@ type Dispute struct { ResolutionLineID *pulid.ID `json:"resolutionLineId" bun:"resolution_line_id,type:VARCHAR(100),nullzero"` ResolvedByID *pulid.ID `json:"resolvedById" bun:"resolved_by_id,type:VARCHAR(100),nullzero"` ResolvedAt *int64 `json:"resolvedAt" bun:"resolved_at,type:BIGINT,nullzero"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` diff --git a/services/tms/internal/core/domain/driversettlement/payevent.go b/services/tms/internal/core/domain/driversettlement/payevent.go index 00a300363..9547a1710 100644 --- a/services/tms/internal/core/domain/driversettlement/payevent.go +++ b/services/tms/internal/core/domain/driversettlement/payevent.go @@ -48,16 +48,16 @@ type PayEvent struct { IdempotencyKey string `json:"idempotencyKey" bun:"idempotency_key,type:VARCHAR(255),notnull"` Status PayEventStatus `json:"status" bun:"status,type:VARCHAR(50),notnull,default:'Accrued'"` EventDate int64 `json:"eventDate" bun:"event_date,type:BIGINT,notnull"` - GrossAmountMinor int64 `json:"grossAmountMinor" bun:"gross_amount_minor,type:BIGINT,notnull,default:0"` + GrossAmountMinor int64 `json:"grossAmountMinor" bun:"gross_amount_minor,type:BIGINT,notnull"` TotalMiles decimal.Decimal `json:"totalMiles" bun:"total_miles,type:NUMERIC(19,4),notnull,default:0"` CurrencyCode string `json:"currencyCode" bun:"currency_code,type:VARCHAR(3),notnull,default:'USD'"` Components []PayEventComponent `json:"components" bun:"components,type:JSONB,nullzero"` ProNumber string `json:"proNumber" bun:"pro_number,type:VARCHAR(100),nullzero"` - OnHold bool `json:"onHold" bun:"on_hold,type:BOOLEAN,notnull,default:false"` + OnHold bool `json:"onHold" bun:"on_hold,type:BOOLEAN,notnull"` HoldReason string `json:"holdReason" bun:"hold_reason,type:TEXT,nullzero"` VoidedAt *int64 `json:"voidedAt" bun:"voided_at,type:BIGINT,nullzero"` VoidReason string `json:"voidReason" bun:"void_reason,type:TEXT,nullzero"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` diff --git a/services/tms/internal/core/domain/driversettlement/settlement.go b/services/tms/internal/core/domain/driversettlement/settlement.go index f8075a619..195d1933f 100644 --- a/services/tms/internal/core/domain/driversettlement/settlement.go +++ b/services/tms/internal/core/domain/driversettlement/settlement.go @@ -48,16 +48,16 @@ type Settlement struct { PeriodStart int64 `json:"periodStart" bun:"period_start,type:BIGINT,notnull"` PeriodEnd int64 `json:"periodEnd" bun:"period_end,type:BIGINT,notnull"` PayDate int64 `json:"payDate" bun:"pay_date,type:BIGINT,notnull"` - GrossEarningsMinor int64 `json:"grossEarningsMinor" bun:"gross_earnings_minor,type:BIGINT,notnull,default:0"` - ReimbursementsMinor int64 `json:"reimbursementsMinor" bun:"reimbursements_minor,type:BIGINT,notnull,default:0"` - DeductionsMinor int64 `json:"deductionsMinor" bun:"deductions_minor,type:BIGINT,notnull,default:0"` - CarryForwardInMinor int64 `json:"carryForwardInMinor" bun:"carry_forward_in_minor,type:BIGINT,notnull,default:0"` - CarryForwardOutMinor int64 `json:"carryForwardOutMinor" bun:"carry_forward_out_minor,type:BIGINT,notnull,default:0"` - NetPayMinor int64 `json:"netPayMinor" bun:"net_pay_minor,type:BIGINT,notnull,default:0"` + GrossEarningsMinor int64 `json:"grossEarningsMinor" bun:"gross_earnings_minor,type:BIGINT,notnull"` + ReimbursementsMinor int64 `json:"reimbursementsMinor" bun:"reimbursements_minor,type:BIGINT,notnull"` + DeductionsMinor int64 `json:"deductionsMinor" bun:"deductions_minor,type:BIGINT,notnull"` + CarryForwardInMinor int64 `json:"carryForwardInMinor" bun:"carry_forward_in_minor,type:BIGINT,notnull"` + CarryForwardOutMinor int64 `json:"carryForwardOutMinor" bun:"carry_forward_out_minor,type:BIGINT,notnull"` + NetPayMinor int64 `json:"netPayMinor" bun:"net_pay_minor,type:BIGINT,notnull"` TotalMiles decimal.Decimal `json:"totalMiles" bun:"total_miles,type:NUMERIC(19,4),notnull,default:0"` - ShipmentCount int `json:"shipmentCount" bun:"shipment_count,type:INTEGER,notnull,default:0"` + ShipmentCount int `json:"shipmentCount" bun:"shipment_count,type:INTEGER,notnull"` CurrencyCode string `json:"currencyCode" bun:"currency_code,type:VARCHAR(3),notnull,default:'USD'"` - HasExceptions bool `json:"hasExceptions" bun:"has_exceptions,type:BOOLEAN,notnull,default:false"` + HasExceptions bool `json:"hasExceptions" bun:"has_exceptions,type:BOOLEAN,notnull"` Exceptions []Exception `json:"exceptions" bun:"exceptions,type:JSONB,nullzero"` Notes string `json:"notes" bun:"notes,type:TEXT,nullzero"` SubmittedByID pulid.ID `json:"submittedById" bun:"submitted_by_id,type:VARCHAR(100),nullzero"` @@ -75,7 +75,7 @@ type Settlement struct { VoidedAt *int64 `json:"voidedAt" bun:"voided_at,type:BIGINT,nullzero"` VoidReason string `json:"voidReason" bun:"void_reason,type:TEXT,nullzero"` VoidJournalBatchID *pulid.ID `json:"voidJournalBatchId" bun:"void_journal_batch_id,type:VARCHAR(100),nullzero"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` diff --git a/services/tms/internal/core/domain/edi/carrierinvoice.go b/services/tms/internal/core/domain/edi/carrierinvoice.go index ba0b19ee1..bd89c3499 100644 --- a/services/tms/internal/core/domain/edi/carrierinvoice.go +++ b/services/tms/internal/core/domain/edi/carrierinvoice.go @@ -61,11 +61,11 @@ type CarrierInvoice struct { TotalAmount decimal.NullDecimal `json:"totalAmount" bun:"total_amount,type:NUMERIC(19,4),nullzero"` ExpectedAmount decimal.NullDecimal `json:"expectedAmount" bun:"expected_amount,type:NUMERIC(19,4),nullzero"` VarianceAmount decimal.NullDecimal `json:"varianceAmount" bun:"variance_amount,type:NUMERIC(19,4),nullzero"` - LineCharges []FreightInvoiceCharge `json:"lineCharges" bun:"line_charges,type:JSONB,notnull,default:'[]'::jsonb"` - ReferenceNumbers map[string]string `json:"referenceNumbers" bun:"reference_numbers,type:JSONB,notnull,default:'{}'::jsonb"` + LineCharges []FreightInvoiceCharge `json:"lineCharges" bun:"line_charges,type:JSONB,notnull,default:'[]'"` + ReferenceNumbers map[string]string `json:"referenceNumbers" bun:"reference_numbers,type:JSONB,notnull,default:'{}'"` ReconciliationStatus CarrierInvoiceReconciliationStatus `json:"reconciliationStatus" bun:"reconciliation_status,type:edi_carrier_invoice_reconciliation_status_enum,notnull,default:'Unmatched'"` ReconciliationNotes string `json:"reconciliationNotes" bun:"reconciliation_notes,type:TEXT,nullzero"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` diff --git a/services/tms/internal/core/domain/edi/communicationprofile.go b/services/tms/internal/core/domain/edi/communicationprofile.go index 4ae03d706..5d6389527 100644 --- a/services/tms/internal/core/domain/edi/communicationprofile.go +++ b/services/tms/internal/core/domain/edi/communicationprofile.go @@ -34,15 +34,15 @@ type EDICommunicationProfile struct { Status domaintypes.Status `json:"status" bun:"status,type:status_enum,notnull,default:'Active'"` Name string `json:"name" bun:"name,type:VARCHAR(200),notnull"` Description string `json:"description" bun:"description,type:TEXT,nullzero"` - Config map[string]any `json:"config" bun:"config,type:JSONB,notnull,default:'{}'::jsonb"` - EncryptedSecrets map[string]string `json:"-" bun:"encrypted_secrets,type:JSONB,notnull,default:'{}'::jsonb"` + Config map[string]any `json:"config" bun:"config,type:JSONB,notnull,default:'{}'"` + EncryptedSecrets map[string]string `json:"-" bun:"encrypted_secrets,type:JSONB,notnull,default:'{}'"` SecretState []CommunicationProfileSecretState `json:"secretState" bun:"-"` LastPollAttemptAt *int64 `json:"lastPollAttemptAt" bun:"last_poll_attempt_at,type:BIGINT,nullzero"` LastPollSuccessAt *int64 `json:"lastPollSuccessAt" bun:"last_poll_success_at,type:BIGINT,nullzero"` LastPollError string `json:"lastPollError" bun:"last_poll_error,type:TEXT,nullzero"` SearchVector string `json:"-" bun:"search_vector,type:TSVECTOR,scanonly"` Rank string `json:"-" bun:"rank,type:VARCHAR(100),scanonly"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` diff --git a/services/tms/internal/core/domain/edi/connection.go b/services/tms/internal/core/domain/edi/connection.go index 7e22b0a20..f074e07c5 100644 --- a/services/tms/internal/core/domain/edi/connection.go +++ b/services/tms/internal/core/domain/edi/connection.go @@ -45,9 +45,9 @@ type EDIConnection struct { TargetPartnerID pulid.ID `json:"targetPartnerId" bun:"target_partner_id,type:VARCHAR(100),nullzero"` Method ConnectionMethod `json:"method" bun:"method,type:edi_connection_method_enum,notnull"` Status ConnectionStatus `json:"status" bun:"status,type:edi_connection_status_enum,notnull,default:'PendingAcceptance'"` - Capabilities ConnectionCapabilities `json:"capabilities" bun:"capabilities,type:JSONB,notnull,default:'{}'::jsonb"` - SourcePartnerConfig ConnectionPartnerConfig `json:"sourcePartnerConfig" bun:"source_partner_config,type:JSONB,notnull,default:'{}'::jsonb"` - TargetPartnerConfig ConnectionPartnerConfig `json:"targetPartnerConfig" bun:"target_partner_config,type:JSONB,notnull,default:'{}'::jsonb"` + Capabilities ConnectionCapabilities `json:"capabilities" bun:"capabilities,type:JSONB,notnull,default:'{}'"` + SourcePartnerConfig ConnectionPartnerConfig `json:"sourcePartnerConfig" bun:"source_partner_config,type:JSONB,notnull,default:'{}'"` + TargetPartnerConfig ConnectionPartnerConfig `json:"targetPartnerConfig" bun:"target_partner_config,type:JSONB,notnull,default:'{}'"` RequestedByID pulid.ID `json:"requestedById" bun:"requested_by_id,type:VARCHAR(100),nullzero"` RequestedAt int64 `json:"requestedAt" bun:"requested_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` AcceptedByID pulid.ID `json:"acceptedById" bun:"accepted_by_id,type:VARCHAR(100),nullzero"` @@ -59,7 +59,7 @@ type EDIConnection struct { SuspendedAt *int64 `json:"suspendedAt" bun:"suspended_at,type:BIGINT,nullzero"` RevokedByID pulid.ID `json:"revokedById" bun:"revoked_by_id,type:VARCHAR(100),nullzero"` RevokedAt *int64 `json:"revokedAt" bun:"revoked_at,type:BIGINT,nullzero"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` diff --git a/services/tms/internal/core/domain/edi/document.go b/services/tms/internal/core/domain/edi/document.go index 44a843bfd..a9c28d0f9 100644 --- a/services/tms/internal/core/domain/edi/document.go +++ b/services/tms/internal/core/domain/edi/document.go @@ -153,7 +153,7 @@ type EDITemplateVersion struct { X12Version string `json:"x12Version" bun:"x12_version,type:VARCHAR(20),notnull"` FunctionalGroupID string `json:"functionalGroupId" bun:"functional_group_id,type:VARCHAR(2),notnull"` Status TemplateStatus `json:"status" bun:"status,type:edi_template_status_enum,notnull"` - IsActive bool `json:"isActive" bun:"is_active,type:BOOLEAN,notnull,default:false"` + IsActive bool `json:"isActive" bun:"is_active,type:BOOLEAN,notnull"` Notes string `json:"notes" bun:"notes,type:TEXT,nullzero"` CertificationNotes string `json:"certificationNotes" bun:"certification_notes,type:TEXT,nullzero"` ActivationNotes string `json:"activationNotes" bun:"activation_notes,type:TEXT,nullzero"` @@ -170,7 +170,7 @@ type EDITemplateVersion struct { ArchivedAt *int64 `json:"archivedAt" bun:"archived_at,type:BIGINT,nullzero"` DeprecatedAt *int64 `json:"deprecatedAt" bun:"deprecated_at,type:BIGINT,nullzero"` SupersededAt *int64 `json:"supersededAt" bun:"superseded_at,type:BIGINT,nullzero"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` @@ -219,9 +219,9 @@ type EDITemplateSegment struct { LoopID string `json:"loopId" bun:"loop_id,type:VARCHAR(50),nullzero"` RepeatPath string `json:"repeatPath" bun:"repeat_path,type:TEXT,nullzero"` Condition string `json:"condition" bun:"condition,type:TEXT,nullzero"` - Required bool `json:"required" bun:"required,type:BOOLEAN,notnull,default:false"` + Required bool `json:"required" bun:"required,type:BOOLEAN,notnull"` MaxUse int64 `json:"maxUse" bun:"max_use,type:BIGINT,notnull,default:1"` - Elements []TemplateElement `json:"elements" bun:"elements,type:JSONB,notnull,default:'[]'::jsonb"` + Elements []TemplateElement `json:"elements" bun:"elements,type:JSONB,notnull,default:'[]'"` UsageNotes string `json:"usageNotes" bun:"usage_notes,type:TEXT,nullzero"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` @@ -256,7 +256,7 @@ type EDITemplateScriptLibrary struct { Language ScriptLanguage `json:"language" bun:"language,type:edi_script_language_enum,notnull"` Script string `json:"script" bun:"script,type:TEXT,notnull"` Status TemplateStatus `json:"status" bun:"status,type:edi_template_status_enum,notnull"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` diff --git a/services/tms/internal/core/domain/edi/documentprofile.go b/services/tms/internal/core/domain/edi/documentprofile.go index f863ec78e..563138d72 100644 --- a/services/tms/internal/core/domain/edi/documentprofile.go +++ b/services/tms/internal/core/domain/edi/documentprofile.go @@ -28,13 +28,13 @@ type EDIPartnerDocumentProfile struct { TransactionSet TransactionSet `json:"transactionSet" bun:"transaction_set,type:edi_transaction_set_enum,notnull"` X12VersionOverride string `json:"x12VersionOverride" bun:"x12_version_override,type:VARCHAR(20),nullzero"` FunctionalGroupID string `json:"functionalGroupId" bun:"functional_group_id,type:VARCHAR(2),notnull"` - Envelope X12EnvelopeSettings `json:"envelope" bun:"envelope,type:JSONB,notnull,default:'{}'::jsonb"` - Acknowledgment AcknowledgmentConfig `json:"acknowledgment" bun:"acknowledgment,type:JSONB,notnull,default:'{}'::jsonb"` + Envelope X12EnvelopeSettings `json:"envelope" bun:"envelope,type:JSONB,notnull,default:'{}'"` + Acknowledgment AcknowledgmentConfig `json:"acknowledgment" bun:"acknowledgment,type:JSONB,notnull,default:'{}'"` ValidationMode ValidationMode `json:"validationMode" bun:"validation_mode,type:edi_validation_mode_enum,notnull"` - PartnerSettings map[string]any `json:"partnerSettings" bun:"partner_settings,type:JSONB,notnull,default:'{}'::jsonb"` + PartnerSettings map[string]any `json:"partnerSettings" bun:"partner_settings,type:JSONB,notnull,default:'{}'"` PartnerSettingsSchemaID pulid.ID `json:"partnerSettingsSchemaId" bun:"partner_settings_schema_id,type:VARCHAR(100),nullzero"` PartnerSettingsSchemaVersion int64 `json:"partnerSettingsSchemaVersion" bun:"partner_settings_schema_version,type:BIGINT,nullzero"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` @@ -112,7 +112,7 @@ type EDIControlNumberSequence struct { NextValue int64 `json:"nextValue" bun:"next_value,type:BIGINT,notnull"` MinValue int64 `json:"minValue" bun:"min_value,type:BIGINT,notnull"` MaxValue int64 `json:"maxValue" bun:"max_value,type:BIGINT,notnull"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` } diff --git a/services/tms/internal/core/domain/edi/inbound_file.go b/services/tms/internal/core/domain/edi/inbound_file.go index 188877999..0d982c76c 100644 --- a/services/tms/internal/core/domain/edi/inbound_file.go +++ b/services/tms/internal/core/domain/edi/inbound_file.go @@ -26,7 +26,7 @@ type EDIInboundFile struct { RemotePath string `json:"remotePath" bun:"remote_path,type:TEXT,notnull"` FileName string `json:"fileName" bun:"file_name,type:VARCHAR(512),notnull"` Checksum string `json:"checksum" bun:"checksum,type:VARCHAR(64),notnull"` - SizeBytes int64 `json:"sizeBytes" bun:"size_bytes,type:BIGINT,notnull,default:0"` + SizeBytes int64 `json:"sizeBytes" bun:"size_bytes,type:BIGINT,notnull"` RawContent string `json:"rawContent" bun:"raw_content,type:TEXT,notnull"` InterchangeControlNumber string `json:"interchangeControlNumber" bun:"interchange_control_number,type:VARCHAR(20),nullzero"` ISASenderQualifier string `json:"isaSenderQualifier" bun:"isa_sender_qualifier,type:VARCHAR(4),nullzero"` @@ -35,11 +35,11 @@ type EDIInboundFile struct { ISAReceiverID string `json:"isaReceiverId" bun:"isa_receiver_id,type:VARCHAR(20),nullzero"` Status InboundFileStatus `json:"status" bun:"status,type:edi_inbound_file_status_enum,notnull,default:'Received'"` FailureReason string `json:"failureReason" bun:"failure_reason,type:TEXT,nullzero"` - TransactionCount int `json:"transactionCount" bun:"transaction_count,type:INTEGER,notnull,default:0"` + TransactionCount int `json:"transactionCount" bun:"transaction_count,type:INTEGER,notnull"` ReceivedAt int64 `json:"receivedAt" bun:"received_at,type:BIGINT,notnull"` ProcessedAt *int64 `json:"processedAt" bun:"processed_at,type:BIGINT,nullzero"` RawPurgedAt *int64 `json:"rawPurgedAt" bun:"raw_purged_at,type:BIGINT,nullzero"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` diff --git a/services/tms/internal/core/domain/edi/message.go b/services/tms/internal/core/domain/edi/message.go index 85fb54050..376d38c25 100644 --- a/services/tms/internal/core/domain/edi/message.go +++ b/services/tms/internal/core/domain/edi/message.go @@ -48,7 +48,7 @@ type EDIMessage struct { RawPurgedAt *int64 `json:"rawPurgedAt" bun:"raw_purged_at,type:BIGINT,nullzero"` DeliveryStatus MessageDeliveryStatus `json:"deliveryStatus" bun:"delivery_status,type:edi_message_delivery_status_enum,nullzero"` DeliveryRemotePath string `json:"deliveryRemotePath" bun:"delivery_remote_path,type:TEXT,nullzero"` - DeliveryAttempts int64 `json:"deliveryAttempts" bun:"delivery_attempts,type:BIGINT,notnull,default:0"` + DeliveryAttempts int64 `json:"deliveryAttempts" bun:"delivery_attempts,type:BIGINT,notnull"` DeliveryLastAttemptAt *int64 `json:"deliveryLastAttemptAt" bun:"delivery_last_attempt_at,type:BIGINT,nullzero"` DeliverySentAt *int64 `json:"deliverySentAt" bun:"delivery_sent_at,type:BIGINT,nullzero"` DeliveryLastError string `json:"deliveryLastError" bun:"delivery_last_error,type:TEXT,nullzero"` @@ -60,7 +60,7 @@ type EDIMessage struct { AckLastError string `json:"ackLastError" bun:"ack_last_error,type:TEXT,nullzero"` GeneratedByID pulid.ID `json:"generatedById" bun:"generated_by_id,type:VARCHAR(100),nullzero"` GeneratedAt int64 `json:"generatedAt" bun:"generated_at,type:BIGINT,notnull"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` @@ -103,7 +103,7 @@ type EDIMessageValidationError struct { Severity ValidationSeverity `json:"severity" bun:"severity,type:edi_validation_severity_enum,notnull"` Code string `json:"code" bun:"code,type:VARCHAR(100),notnull"` SegmentID string `json:"segmentId" bun:"segment_id,type:VARCHAR(10),nullzero"` - ElementPosition int `json:"elementPosition" bun:"element_position,type:INTEGER,notnull,default:0"` + ElementPosition int `json:"elementPosition" bun:"element_position,type:INTEGER,notnull"` Path string `json:"path" bun:"path,type:TEXT,nullzero"` Message string `json:"message" bun:"message,type:TEXT,notnull"` SuggestedFix string `json:"suggestedFix" bun:"suggested_fix,type:TEXT,nullzero"` @@ -131,15 +131,15 @@ type EDITestCase struct { Name string `json:"name" bun:"name,type:VARCHAR(200),notnull"` Description string `json:"description" bun:"description,type:TEXT,nullzero"` Payload DocumentPayload `json:"payload" bun:"payload,type:JSONB,notnull"` - ExpectedWarnings int `json:"expectedWarnings" bun:"expected_warnings,type:INTEGER,notnull,default:0"` - ExpectedErrors int `json:"expectedErrors" bun:"expected_errors,type:INTEGER,notnull,default:0"` - ExpectedWarningCodes []string `json:"expectedWarningCodes" bun:"expected_warning_codes,type:JSONB,notnull,default:'[]'::jsonb"` - ExpectedErrorCodes []string `json:"expectedErrorCodes" bun:"expected_error_codes,type:JSONB,notnull,default:'[]'::jsonb"` + ExpectedWarnings int `json:"expectedWarnings" bun:"expected_warnings,type:INTEGER,notnull"` + ExpectedErrors int `json:"expectedErrors" bun:"expected_errors,type:INTEGER,notnull"` + ExpectedWarningCodes []string `json:"expectedWarningCodes" bun:"expected_warning_codes,type:JSONB,notnull,default:'[]'"` + ExpectedErrorCodes []string `json:"expectedErrorCodes" bun:"expected_error_codes,type:JSONB,notnull,default:'[]'"` LastRunAt *int64 `json:"lastRunAt" bun:"last_run_at,type:BIGINT,nullzero"` LastRunPassed *bool `json:"lastRunPassed" bun:"last_run_passed,type:BOOLEAN"` - LastRunWarnings int `json:"lastRunWarnings" bun:"last_run_warnings,type:INTEGER,notnull,default:0"` - LastRunErrors int `json:"lastRunErrors" bun:"last_run_errors,type:INTEGER,notnull,default:0"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + LastRunWarnings int `json:"lastRunWarnings" bun:"last_run_warnings,type:INTEGER,notnull"` + LastRunErrors int `json:"lastRunErrors" bun:"last_run_errors,type:INTEGER,notnull"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` diff --git a/services/tms/internal/core/domain/edi/partner.go b/services/tms/internal/core/domain/edi/partner.go index f65cae84e..5d0ed3642 100644 --- a/services/tms/internal/core/domain/edi/partner.go +++ b/services/tms/internal/core/domain/edi/partner.go @@ -44,7 +44,7 @@ type EDIPartner struct { ContactPhone string `json:"contactPhone" bun:"contact_phone,type:VARCHAR(30),nullzero"` EnabledForInbound bool `json:"enabledForInbound" bun:"enabled_for_inbound,type:BOOLEAN,notnull,default:true"` EnabledForOutbound bool `json:"enabledForOutbound" bun:"enabled_for_outbound,type:BOOLEAN,notnull,default:true"` - Settings map[string]any `json:"settings" bun:"settings,type:JSONB,notnull,default:'{}'::jsonb"` + Settings map[string]any `json:"settings" bun:"settings,type:JSONB,notnull,default:'{}'"` SearchVector string `json:"-" bun:"search_vector,type:TSVECTOR,scanonly"` Rank string `json:"-" bun:"rank,type:VARCHAR(100),scanonly"` Version int64 `json:"version" bun:"version,type:BIGINT"` diff --git a/services/tms/internal/core/domain/edi/partnersettings.go b/services/tms/internal/core/domain/edi/partnersettings.go index 55f005c17..67cb9ff42 100644 --- a/services/tms/internal/core/domain/edi/partnersettings.go +++ b/services/tms/internal/core/domain/edi/partnersettings.go @@ -57,16 +57,16 @@ type EDIPartnerSettingField struct { Label string `json:"label" bun:"label,type:VARCHAR(200),notnull"` Description string `json:"description" bun:"description,type:TEXT,nullzero"` DataType PartnerSettingDataType `json:"dataType" bun:"data_type,type:edi_partner_setting_data_type_enum,notnull"` - Required bool `json:"required" bun:"required,type:BOOLEAN,notnull,default:false"` - Nullable bool `json:"nullable" bun:"nullable,type:BOOLEAN,notnull,default:false"` + Required bool `json:"required" bun:"required,type:BOOLEAN,notnull"` + Nullable bool `json:"nullable" bun:"nullable,type:BOOLEAN,notnull"` DefaultValue any `json:"defaultValue" bun:"default_value,type:JSONB,nullzero"` - AllowedValues []string `json:"allowedValues" bun:"allowed_values,type:JSONB,notnull,default:'[]'::jsonb"` - Secret bool `json:"secret" bun:"secret,type:BOOLEAN,notnull,default:false"` + AllowedValues []string `json:"allowedValues" bun:"allowed_values,type:JSONB,notnull,default:'[]'"` + Secret bool `json:"secret" bun:"secret,type:BOOLEAN,notnull"` GroupKey string `json:"groupKey" bun:"group_key,type:VARCHAR(100),nullzero"` - DisplayOrder int `json:"displayOrder" bun:"display_order,type:INTEGER,notnull,default:0"` + DisplayOrder int `json:"displayOrder" bun:"display_order,type:INTEGER,notnull"` ValidationPattern string `json:"validationPattern" bun:"validation_pattern,type:TEXT,nullzero"` - MinLength int `json:"minLength" bun:"min_length,type:INTEGER,notnull,default:0"` - MaxLength int `json:"maxLength" bun:"max_length,type:INTEGER,notnull,default:0"` + MinLength int `json:"minLength" bun:"min_length,type:INTEGER,notnull"` + MaxLength int `json:"maxLength" bun:"max_length,type:INTEGER,notnull"` UsageNotes string `json:"usageNotes" bun:"usage_notes,type:TEXT,nullzero"` Status PartnerSettingStatus `json:"status" bun:"status,type:edi_partner_setting_status_enum,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` diff --git a/services/tms/internal/core/domain/edi/sourcecontext.go b/services/tms/internal/core/domain/edi/sourcecontext.go index 574e5d2ea..933ce209e 100644 --- a/services/tms/internal/core/domain/edi/sourcecontext.go +++ b/services/tms/internal/core/domain/edi/sourcecontext.go @@ -54,7 +54,7 @@ type EDISourceContextField struct { Path string `json:"path" bun:"path,type:TEXT,notnull"` SourceKind SourceContextKind `json:"sourceKind" bun:"source_kind,type:edi_source_context_kind_enum,notnull"` DataType SourceContextDataType `json:"dataType" bun:"data_type,type:edi_source_context_data_type_enum,notnull"` - Repeated bool `json:"repeated" bun:"repeated,type:BOOLEAN,notnull,default:false"` + Repeated bool `json:"repeated" bun:"repeated,type:BOOLEAN,notnull"` RepeatPath string `json:"repeatPath" bun:"repeat_path,type:TEXT,nullzero"` ParentPath string `json:"parentPath" bun:"parent_path,type:TEXT,nullzero"` DisplayName string `json:"displayName" bun:"display_name,type:VARCHAR(200),notnull"` diff --git a/services/tms/internal/core/domain/edi/sync.go b/services/tms/internal/core/domain/edi/sync.go index 66ae29192..b0a6e8fe7 100644 --- a/services/tms/internal/core/domain/edi/sync.go +++ b/services/tms/internal/core/domain/edi/sync.go @@ -77,9 +77,9 @@ type ShipmentLink struct { TenderTransferID pulid.ID `json:"tenderTransferId" bun:"tender_transfer_id,type:VARCHAR(100),notnull"` OriginatingMessageID pulid.ID `json:"originatingMessageId" bun:"originating_message_id,type:VARCHAR(100),nullzero"` SyncPolicy ShipmentSyncPolicy `json:"syncPolicy" bun:"sync_policy,type:edi_shipment_sync_policy_enum,notnull,default:'AutoOperational'"` - FieldOwnership map[string]string `json:"fieldOwnership" bun:"field_ownership,type:JSONB,notnull,default:'{}'::jsonb"` + FieldOwnership map[string]string `json:"fieldOwnership" bun:"field_ownership,type:JSONB,notnull,default:'{}'"` Status ShipmentLinkStatus `json:"status" bun:"status,type:edi_shipment_link_status_enum,notnull,default:'Active'"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` } @@ -98,8 +98,8 @@ type TransferChange struct { IdempotencyKey string `json:"idempotencyKey" bun:"idempotency_key,type:VARCHAR(255),notnull"` SourceShipmentVersion int64 `json:"sourceShipmentVersion" bun:"source_shipment_version,type:BIGINT,notnull"` TargetShipmentVersion int64 `json:"targetShipmentVersion" bun:"target_shipment_version,type:BIGINT,notnull"` - Payload map[string]any `json:"payload" bun:"payload,type:JSONB,notnull,default:'{}'::jsonb"` - Diff map[string]any `json:"diff" bun:"diff,type:JSONB,notnull,default:'{}'::jsonb"` + Payload map[string]any `json:"payload" bun:"payload,type:JSONB,notnull,default:'{}'"` + Diff map[string]any `json:"diff" bun:"diff,type:JSONB,notnull,default:'{}'"` ReviewedByID pulid.ID `json:"reviewedById" bun:"reviewed_by_id,type:VARCHAR(100),nullzero"` ReviewedAt *int64 `json:"reviewedAt" bun:"reviewed_at,type:BIGINT,nullzero"` AppliedByID pulid.ID `json:"appliedById" bun:"applied_by_id,type:VARCHAR(100),nullzero"` @@ -107,7 +107,7 @@ type TransferChange struct { FailureReason string `json:"failureReason" bun:"failure_reason,type:TEXT,nullzero"` SearchVector string `json:"-" bun:"search_vector,type:TSVECTOR,scanonly"` Rank string `json:"-" bun:"rank,type:VARCHAR(100),scanonly"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` } diff --git a/services/tms/internal/core/domain/edi/template.go b/services/tms/internal/core/domain/edi/template.go index a5806aecf..0cc9b4aeb 100644 --- a/services/tms/internal/core/domain/edi/template.go +++ b/services/tms/internal/core/domain/edi/template.go @@ -32,7 +32,7 @@ type EDITemplate struct { Standard EDIStandard `json:"standard" bun:"standard,type:edi_standard_enum,notnull"` TransactionSet TransactionSet `json:"transactionSet" bun:"transaction_set,type:edi_transaction_set_enum,notnull"` Status TemplateStatus `json:"status" bun:"status,type:edi_template_status_enum,notnull"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` SearchVector string `json:"-" bun:"search_vector,type:TSVECTOR,scanonly"` diff --git a/services/tms/internal/core/domain/edi/tenderchange.go b/services/tms/internal/core/domain/edi/tenderchange.go index 8a50fcee1..9281b8e52 100644 --- a/services/tms/internal/core/domain/edi/tenderchange.go +++ b/services/tms/internal/core/domain/edi/tenderchange.go @@ -34,7 +34,7 @@ type TenderRecipient struct { BaselineRecordedAt int64 `json:"baselineRecordedAt" bun:"baseline_recorded_at,type:BIGINT,notnull"` BaselineStatus TenderRecipientBaselineStatus `json:"baselineStatus" bun:"baseline_status,type:edi_tender_recipient_baseline_status_enum,notnull"` Status TenderRecipientStatus `json:"status" bun:"status,type:edi_tender_recipient_status_enum,notnull,default:'Active'"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` } @@ -57,8 +57,8 @@ type TenderChange struct { NewTenderPayload LoadTenderPayload `json:"newTenderPayload" bun:"new_tender_payload,type:JSONB,notnull"` PreviousBaselineHash string `json:"previousBaselineHash" bun:"previous_baseline_hash,type:VARCHAR(128),notnull"` NewPayloadHash string `json:"newPayloadHash" bun:"new_payload_hash,type:VARCHAR(128),notnull"` - DiffSummary map[string]any `json:"diffSummary" bun:"diff_summary,type:JSONB,notnull,default:'{}'::jsonb"` - ConflictMetadata map[string]any `json:"conflictMetadata" bun:"conflict_metadata,type:JSONB,notnull,default:'{}'::jsonb"` + DiffSummary map[string]any `json:"diffSummary" bun:"diff_summary,type:JSONB,notnull,default:'{}'"` + ConflictMetadata map[string]any `json:"conflictMetadata" bun:"conflict_metadata,type:JSONB,notnull,default:'{}'"` InternalTransferID pulid.ID `json:"internalTransferId" bun:"internal_transfer_id,type:VARCHAR(100),nullzero"` ShipmentLinkID pulid.ID `json:"shipmentLinkId" bun:"shipment_link_id,type:VARCHAR(100),nullzero"` OutboundMessageID pulid.ID `json:"outboundMessageId" bun:"outbound_message_id,type:VARCHAR(100),nullzero"` @@ -69,7 +69,7 @@ type TenderChange struct { FailureReason string `json:"failureReason" bun:"failure_reason,type:TEXT,nullzero"` SearchVector string `json:"-" bun:"search_vector,type:TSVECTOR,scanonly"` Rank string `json:"-" bun:"rank,type:VARCHAR(100),scanonly"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` diff --git a/services/tms/internal/core/domain/edi/transactionset.go b/services/tms/internal/core/domain/edi/transactionset.go index ed9ad7f69..a52aa1460 100644 --- a/services/tms/internal/core/domain/edi/transactionset.go +++ b/services/tms/internal/core/domain/edi/transactionset.go @@ -81,7 +81,7 @@ type EDITransactionSegmentDefinition struct { Name string `json:"name" bun:"name,type:VARCHAR(200),notnull"` LoopID string `json:"loopId" bun:"loop_id,type:VARCHAR(50),nullzero"` Sequence int64 `json:"sequence" bun:"sequence,type:BIGINT,notnull"` - Required bool `json:"required" bun:"required,type:BOOLEAN,notnull,default:false"` + Required bool `json:"required" bun:"required,type:BOOLEAN,notnull"` MaxUse int64 `json:"maxUse" bun:"max_use,type:BIGINT,notnull,default:1"` RepeatPath string `json:"repeatPath" bun:"repeat_path,type:TEXT,nullzero"` UsageNotes string `json:"usageNotes" bun:"usage_notes,type:TEXT,nullzero"` @@ -117,9 +117,9 @@ type EDITransactionElementDefinition struct { Position int `json:"position" bun:"position,type:INTEGER,notnull"` ElementID string `json:"elementId" bun:"element_id,type:VARCHAR(20),nullzero"` Name string `json:"name" bun:"name,type:VARCHAR(200),notnull"` - Required bool `json:"required" bun:"required,type:BOOLEAN,notnull,default:false"` - MinLength int `json:"minLength" bun:"min_length,type:INTEGER,notnull,default:0"` - MaxLength int `json:"maxLength" bun:"max_length,type:INTEGER,notnull,default:0"` + Required bool `json:"required" bun:"required,type:BOOLEAN,notnull"` + MinLength int `json:"minLength" bun:"min_length,type:INTEGER,notnull"` + MaxLength int `json:"maxLength" bun:"max_length,type:INTEGER,notnull"` CodeListID pulid.ID `json:"codeListId" bun:"code_list_id,type:VARCHAR(100),nullzero"` UsageNotes string `json:"usageNotes" bun:"usage_notes,type:TEXT,nullzero"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` diff --git a/services/tms/internal/core/domain/edi/transfer.go b/services/tms/internal/core/domain/edi/transfer.go index e97655ec4..eb9ddfb5c 100644 --- a/services/tms/internal/core/domain/edi/transfer.go +++ b/services/tms/internal/core/domain/edi/transfer.go @@ -115,7 +115,7 @@ type EDITransfer struct { InboundMessageID pulid.ID `json:"inboundMessageId" bun:"inbound_message_id,type:VARCHAR(100),nullzero"` Status TransferStatus `json:"status" bun:"status,type:edi_load_tender_transfer_status_enum,notnull"` TenderPayload LoadTenderPayload `json:"tenderPayload" bun:"tender_payload,type:JSONB,notnull"` - MappingSnapshot []MappingResolution `json:"mappingSnapshot" bun:"mapping_snapshot,type:JSONB,notnull,default:'[]'::jsonb"` + MappingSnapshot []MappingResolution `json:"mappingSnapshot" bun:"mapping_snapshot,type:JSONB,notnull,default:'[]'"` RejectionReason string `json:"rejectionReason" bun:"rejection_reason,type:TEXT,nullzero"` FailureReason string `json:"failureReason" bun:"failure_reason,type:TEXT,nullzero"` ApprovalWorkflowID string `json:"approvalWorkflowId" bun:"approval_workflow_id,type:VARCHAR(255),nullzero"` diff --git a/services/tms/internal/core/domain/email/email.go b/services/tms/internal/core/domain/email/email.go index 43847e790..27532e445 100644 --- a/services/tms/internal/core/domain/email/email.go +++ b/services/tms/internal/core/domain/email/email.go @@ -39,7 +39,7 @@ type Profile struct { AuthType AuthType `json:"-" bun:"auth_type,type:email_auth_type_enum,notnull"` EncryptionType Encryption `json:"-" bun:"encryption_type,type:email_encryption_type_enum,notnull"` Status ProfileStatus `json:"status" bun:"status,type:status_enum,notnull"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` SearchVector string `json:"-" bun:"search_vector,type:TSVECTOR,scanonly"` diff --git a/services/tms/internal/core/domain/email/message.go b/services/tms/internal/core/domain/email/message.go index 3a869ae0e..b2a3837a8 100644 --- a/services/tms/internal/core/domain/email/message.go +++ b/services/tms/internal/core/domain/email/message.go @@ -27,7 +27,7 @@ type Message struct { IdempotencyKey string `json:"idempotencyKey" bun:"idempotency_key,type:VARCHAR(160),notnull"` ProviderMessageID string `json:"providerMessageId" bun:"provider_message_id,type:VARCHAR(160),nullzero"` Status MessageStatus `json:"status" bun:"status,type:email_message_status_enum,notnull"` - Attempts int32 `json:"attempts" bun:"attempts,type:INTEGER,notnull,default:0"` + Attempts int32 `json:"attempts" bun:"attempts,type:INTEGER,notnull"` FromEmail string `json:"fromEmail" bun:"from_email,type:VARCHAR(320),notnull"` FromName string `json:"fromName" bun:"from_name,type:VARCHAR(100),notnull"` ReplyToEmail string `json:"replyToEmail" bun:"reply_to_email,type:VARCHAR(320),nullzero"` @@ -35,8 +35,8 @@ type Message struct { CCRecipients []string `json:"ccRecipients" bun:"cc_recipients,array,type:text[],nullzero"` BCCRecipients []string `json:"bccRecipients" bun:"bcc_recipients,array,type:text[],nullzero"` Subject string `json:"subject" bun:"subject,type:VARCHAR(998),notnull"` - BodyTextSize int64 `json:"bodyTextSize" bun:"body_text_size,type:BIGINT,notnull,default:0"` - BodyHTMLSize int64 `json:"bodyHtmlSize" bun:"body_html_size,type:BIGINT,notnull,default:0"` + BodyTextSize int64 `json:"bodyTextSize" bun:"body_text_size,type:BIGINT,notnull"` + BodyHTMLSize int64 `json:"bodyHtmlSize" bun:"body_html_size,type:BIGINT,notnull"` LastError string `json:"lastError" bun:"last_error,type:TEXT,nullzero"` SentAt int64 `json:"sentAt" bun:"sent_at,type:BIGINT,nullzero"` DeliveredAt int64 `json:"deliveredAt" bun:"delivered_at,type:BIGINT,nullzero"` diff --git a/services/tms/internal/core/domain/exchangerate/exchangerate.go b/services/tms/internal/core/domain/exchangerate/exchangerate.go index 9e5245eec..2a6090b1c 100644 --- a/services/tms/internal/core/domain/exchangerate/exchangerate.go +++ b/services/tms/internal/core/domain/exchangerate/exchangerate.go @@ -49,7 +49,7 @@ type ExchangeRate struct { Date string `json:"date" bun:"date,type:DATE,notnull"` SourceTimestamp time.Time `json:"sourceTimestamp" bun:"source_timestamp,type:TIMESTAMPTZ,notnull"` FetchedAt time.Time `json:"fetchedAt" bun:"fetched_at,type:TIMESTAMPTZ,notnull,default:current_timestamp"` - SettlementEligible bool `json:"settlementEligible" bun:"settlement_eligible,type:BOOLEAN,notnull,default:false"` + SettlementEligible bool `json:"settlementEligible" bun:"settlement_eligible,type:BOOLEAN,notnull"` BusinessUnit *tenant.BusinessUnit `json:"businessUnit,omitempty" bun:"rel:belongs-to,join:business_unit_id=id"` Organization *tenant.Organization `json:"organization,omitempty" bun:"rel:belongs-to,join:organization_id=id"` diff --git a/services/tms/internal/core/domain/fiscalperiod/fiscalperiod.go b/services/tms/internal/core/domain/fiscalperiod/fiscalperiod.go index e9a6e6d64..04977a5c6 100644 --- a/services/tms/internal/core/domain/fiscalperiod/fiscalperiod.go +++ b/services/tms/internal/core/domain/fiscalperiod/fiscalperiod.go @@ -75,7 +75,7 @@ type FiscalPeriod struct { // Oracle's gl_period_statuses table has an adjustment_period_flag column // that serves exactly this purpose. D365 identifies Period 13 as a // "Closing" transaction type. - IsAdjusting bool `json:"isAdjusting" bun:"is_adjusting,type:BOOLEAN,default:false"` + IsAdjusting bool `json:"isAdjusting" bun:"is_adjusting,type:BOOLEAN"` // AllowAdjustingEntries controls whether adjusting journal entries can // be posted to this specific period. During year-end close, the controller @@ -92,7 +92,7 @@ type FiscalPeriod struct { // 3. Controller enables AllowAdjustingEntries on Period 12 (and/or Period 13) // 4. Auditors post their adjustments to the designated period(s) // 5. Once audit is complete, periods are closed and eventually permanently closed - AllowAdjustingEntries bool `json:"allowAdjustingEntries" bun:"allow_adjusting_entries,type:BOOLEAN,default:false"` + AllowAdjustingEntries bool `json:"allowAdjustingEntries" bun:"allow_adjusting_entries,type:BOOLEAN"` // AdjustmentDeadline is the cutoff timestamp for posting adjusting entries // to this period. After this deadline, adjusting entries are rejected even diff --git a/services/tms/internal/core/domain/fiscalyear/fiscalyear.go b/services/tms/internal/core/domain/fiscalyear/fiscalyear.go index 93edf2ff9..9f42ee778 100644 --- a/services/tms/internal/core/domain/fiscalyear/fiscalyear.go +++ b/services/tms/internal/core/domain/fiscalyear/fiscalyear.go @@ -65,12 +65,12 @@ type FiscalYear struct { // IsCurrent indicates this is the active fiscal year for day-to-day operations. // Only one fiscal year per organization+business_unit can be current at a time. // Enforced at the DB level with a partial unique index where is_current = TRUE. - IsCurrent bool `json:"isCurrent" bun:"is_current,type:BOOLEAN,default:false"` + IsCurrent bool `json:"isCurrent" bun:"is_current,type:BOOLEAN"` // IsCalendarYear is a denormalized flag indicating the fiscal year aligns // with Jan 1 – Dec 31. Saves a date comparison on every query that needs // to know whether this is a standard or offset fiscal year. - IsCalendarYear bool `json:"isCalendarYear" bun:"is_calendar_year,type:BOOLEAN,default:false"` + IsCalendarYear bool `json:"isCalendarYear" bun:"is_calendar_year,type:BOOLEAN"` // --------------------------------------------------------------- // Year-End Controls @@ -81,7 +81,7 @@ type FiscalYear struct { // accept adjusting entries regardless of its own per-period setting. If true, // it defers to each period's AllowAdjustingEntries flag. This gives the CFO // a single kill-switch to lock down the entire year. - AllowAdjustingEntries bool `json:"allowAdjustingEntries" bun:"allow_adjusting_entries,type:BOOLEAN,default:false"` + AllowAdjustingEntries bool `json:"allowAdjustingEntries" bun:"allow_adjusting_entries,type:BOOLEAN"` // --------------------------------------------------------------- // Close Tracking diff --git a/services/tms/internal/core/domain/fuelsurcharge/price.go b/services/tms/internal/core/domain/fuelsurcharge/price.go index 1628b36b1..bb399544b 100644 --- a/services/tms/internal/core/domain/fuelsurcharge/price.go +++ b/services/tms/internal/core/domain/fuelsurcharge/price.go @@ -31,7 +31,7 @@ type FuelIndexPrice struct { PriceDate string `json:"priceDate" bun:"price_date,type:DATE,notnull"` Price decimal.Decimal `json:"price" bun:"price,type:NUMERIC(19,4),notnull"` Currency string `json:"currency" bun:"currency,type:VARCHAR(3),notnull,default:'USD'"` - IsManual bool `json:"isManual" bun:"is_manual,type:BOOLEAN,notnull,default:false"` + IsManual bool `json:"isManual" bun:"is_manual,type:BOOLEAN,notnull"` EnteredByID *pulid.ID `json:"enteredById" bun:"entered_by_id,type:VARCHAR(100),nullzero"` SourceRaw string `json:"sourceRaw" bun:"source_raw,type:VARCHAR(64),nullzero"` FetchedAt time.Time `json:"fetchedAt" bun:"fetched_at,type:TIMESTAMPTZ,notnull,default:current_timestamp"` diff --git a/services/tms/internal/core/domain/fuelsurcharge/tablerow.go b/services/tms/internal/core/domain/fuelsurcharge/tablerow.go index f69f8ce37..4992ab4e3 100644 --- a/services/tms/internal/core/domain/fuelsurcharge/tablerow.go +++ b/services/tms/internal/core/domain/fuelsurcharge/tablerow.go @@ -25,7 +25,7 @@ type FuelSurchargeTableRow struct { PriceMin decimal.NullDecimal `json:"priceMin" bun:"price_min,type:NUMERIC(19,4)"` PriceMax decimal.NullDecimal `json:"priceMax" bun:"price_max,type:NUMERIC(19,4)"` Value decimal.Decimal `json:"value" bun:"value,type:NUMERIC(19,4),notnull"` - SortOrder int32 `json:"sortOrder" bun:"sort_order,type:INTEGER,notnull,default:0"` + SortOrder int32 `json:"sortOrder" bun:"sort_order,type:INTEGER,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` } diff --git a/services/tms/internal/core/domain/glaccount/glaccount.go b/services/tms/internal/core/domain/glaccount/glaccount.go index cf6a4e7f1..648cbd27d 100644 --- a/services/tms/internal/core/domain/glaccount/glaccount.go +++ b/services/tms/internal/core/domain/glaccount/glaccount.go @@ -33,12 +33,12 @@ type GLAccount struct { AccountCode string `json:"accountCode" bun:"account_code,type:VARCHAR(20),notnull"` Name string `json:"name" bun:"name,type:VARCHAR(200),notnull"` Description string `json:"description" bun:"description,type:TEXT,nullzero"` - IsSystem bool `json:"isSystem" bun:"is_system,type:BOOLEAN,default:false"` + IsSystem bool `json:"isSystem" bun:"is_system,type:BOOLEAN"` AllowManualJE bool `json:"allowManualJe" bun:"allow_manual_je,type:BOOLEAN,default:true"` - RequireProject bool `json:"requireProject" bun:"require_project,type:BOOLEAN,default:false"` - CurrentBalance int64 `json:"currentBalance" bun:"current_balance,type:BIGINT,default:0"` - DebitBalance int64 `json:"debitBalance" bun:"debit_balance,type:BIGINT,default:0"` - CreditBalance int64 `json:"creditBalance" bun:"credit_balance,type:BIGINT,default:0"` + RequireProject bool `json:"requireProject" bun:"require_project,type:BOOLEAN"` + CurrentBalance int64 `json:"currentBalance" bun:"current_balance,type:BIGINT"` + DebitBalance int64 `json:"debitBalance" bun:"debit_balance,type:BIGINT"` + CreditBalance int64 `json:"creditBalance" bun:"credit_balance,type:BIGINT"` Version int64 `json:"version" bun:"version,type:BIGINT"` CreatedAt int64 `json:"createdAt" bun:"created_at,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,notnull,default:extract(epoch from current_timestamp)::bigint"` diff --git a/services/tms/internal/core/domain/hazardousmaterial/hazardousmaterial.go b/services/tms/internal/core/domain/hazardousmaterial/hazardousmaterial.go index e39986c1e..bbe950eb7 100644 --- a/services/tms/internal/core/domain/hazardousmaterial/hazardousmaterial.go +++ b/services/tms/internal/core/domain/hazardousmaterial/hazardousmaterial.go @@ -46,10 +46,10 @@ type HazardousMaterial struct { QuantityThreshold string `json:"quantityThreshold" bun:"quantity_threshold,type:VARCHAR(20)"` SearchVector string `json:"-" bun:"search_vector,type:TSVECTOR,scanonly"` Rank string `json:"-" bun:"rank,type:VARCHAR(100),scanonly"` - PlacardRequired bool `json:"placardRequired" bun:"placard_required,type:BOOLEAN,default:false"` - IsReportableQuantity bool `json:"isReportableQuantity" bun:"is_reportable_quantity,type:BOOLEAN,default:false"` - MarinePollutant bool `json:"marinePollutant" bun:"marine_pollutant,type:BOOLEAN,default:false"` - InhalationHazard bool `json:"inhalationHazard" bun:"inhalation_hazard,type:BOOLEAN,default:false"` + PlacardRequired bool `json:"placardRequired" bun:"placard_required,type:BOOLEAN"` + IsReportableQuantity bool `json:"isReportableQuantity" bun:"is_reportable_quantity,type:BOOLEAN"` + MarinePollutant bool `json:"marinePollutant" bun:"marine_pollutant,type:BOOLEAN"` + InhalationHazard bool `json:"inhalationHazard" bun:"inhalation_hazard,type:BOOLEAN"` Version int64 `json:"version" bun:"version,type:BIGINT"` CreatedAt int64 `json:"createdAt" bun:"created_at,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,notnull,default:extract(epoch from current_timestamp)::bigint"` diff --git a/services/tms/internal/core/domain/hazmatsegregationrule/hazmatsegregationrule.go b/services/tms/internal/core/domain/hazmatsegregationrule/hazmatsegregationrule.go index 8ef2ffd5c..d30e1d6d1 100644 --- a/services/tms/internal/core/domain/hazmatsegregationrule/hazmatsegregationrule.go +++ b/services/tms/internal/core/domain/hazmatsegregationrule/hazmatsegregationrule.go @@ -41,7 +41,7 @@ type HazmatSegregationRule struct { SearchVector string `json:"-" bun:"search_vector,type:TSVECTOR,scanonly"` Rank string `json:"-" bun:"rank,type:VARCHAR(100),scanonly"` SegregationType SegregationType `json:"segregationType" bun:"segregation_type,type:segregation_type_enum,notnull"` - HasExceptions bool `json:"hasExceptions" bun:"has_exceptions,type:BOOLEAN,default:false"` + HasExceptions bool `json:"hasExceptions" bun:"has_exceptions,type:BOOLEAN"` Version int64 `json:"version" bun:"version,type:BIGINT"` CreatedAt int64 `json:"createdAt" bun:"created_at,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,notnull,default:extract(epoch from current_timestamp)::bigint"` diff --git a/services/tms/internal/core/domain/holdreason/holdreason.go b/services/tms/internal/core/domain/holdreason/holdreason.go index 4e770e8b4..44b21fbdc 100644 --- a/services/tms/internal/core/domain/holdreason/holdreason.go +++ b/services/tms/internal/core/domain/holdreason/holdreason.go @@ -51,10 +51,10 @@ type HoldReason struct { Description string `json:"description" bun:"description,type:TEXT,nullzero"` Active bool `json:"active" bun:"active,type:BOOLEAN,notnull,default:true"` DefaultSeverity HoldSeverity `json:"defaultSeverity" bun:"default_severity,type:hold_severity_enum,notnull"` - DefaultBlocksDispatch bool `json:"defaultBlocksDispatch" bun:"default_blocks_dispatch,type:BOOLEAN,notnull,default:false"` - DefaultBlocksDelivery bool `json:"defaultBlocksDelivery" bun:"default_blocks_delivery,type:BOOLEAN,notnull,default:false"` - DefaultBlocksBilling bool `json:"defaultBlocksBilling" bun:"default_blocks_billing,type:BOOLEAN,notnull,default:false"` - DefaultVisibleToCustomer bool `json:"defaultVisibleToCustomer" bun:"default_visible_to_customer,type:BOOLEAN,notnull,default:false"` + DefaultBlocksDispatch bool `json:"defaultBlocksDispatch" bun:"default_blocks_dispatch,type:BOOLEAN,notnull"` + DefaultBlocksDelivery bool `json:"defaultBlocksDelivery" bun:"default_blocks_delivery,type:BOOLEAN,notnull"` + DefaultBlocksBilling bool `json:"defaultBlocksBilling" bun:"default_blocks_billing,type:BOOLEAN,notnull"` + DefaultVisibleToCustomer bool `json:"defaultVisibleToCustomer" bun:"default_visible_to_customer,type:BOOLEAN,notnull"` SortOrder int32 `json:"sortOrder" bun:"sort_order,type:INTEGER,notnull,default:100"` ExternalMap map[string]any `json:"externalMap" bun:"external_map,type:JSONB,nullzero"` Version int64 `json:"version" bun:"version,type:BIGINT"` diff --git a/services/tms/internal/core/domain/homelayout/preset.go b/services/tms/internal/core/domain/homelayout/preset.go index c8d234599..5459a454d 100644 --- a/services/tms/internal/core/domain/homelayout/preset.go +++ b/services/tms/internal/core/domain/homelayout/preset.go @@ -39,9 +39,9 @@ type Preset struct { Layout *Layout `json:"layout" bun:"layout,type:JSONB,notnull"` RoleIDs []pulid.ID `json:"roleIds" bun:"role_ids,type:TEXT[],array,nullzero"` CoreResponsibility permission.CoreResponsibility `json:"coreResponsibility" bun:"core_responsibility,type:VARCHAR(50),nullzero"` - IsOrgDefault bool `json:"isOrgDefault" bun:"is_org_default,type:BOOLEAN,notnull,default:false"` - Locked bool `json:"locked" bun:"locked,type:BOOLEAN,notnull,default:false"` - Priority int `json:"priority" bun:"priority,type:INTEGER,notnull,default:0"` + IsOrgDefault bool `json:"isOrgDefault" bun:"is_org_default,type:BOOLEAN,notnull"` + Locked bool `json:"locked" bun:"locked,type:BOOLEAN,notnull"` + Priority int `json:"priority" bun:"priority,type:INTEGER,notnull"` CreatedBy pulid.ID `json:"createdBy" bun:"created_by,type:VARCHAR(100),nullzero"` Version int64 `json:"version" bun:"version,type:BIGINT"` CreatedAt int64 `json:"createdAt" bun:"created_at,nullzero,notnull,default:extract(epoch from current_timestamp)::bigint"` diff --git a/services/tms/internal/core/domain/iam/models.go b/services/tms/internal/core/domain/iam/models.go index 0f209cd84..a25a83968 100644 --- a/services/tms/internal/core/domain/iam/models.go +++ b/services/tms/internal/core/domain/iam/models.go @@ -52,7 +52,7 @@ type IdentityProvider struct { SAMLSSOURL string `json:"samlSsoUrl" bun:"saml_sso_url,type:VARCHAR(500)"` SAMLX509Certificate string `json:"-" bun:"saml_x509_certificate,type:TEXT"` SAMLMetadataXML string `json:"-" bun:"saml_metadata_xml,type:TEXT"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,notnull,default:extract(epoch from current_timestamp)::bigint"` } @@ -315,7 +315,7 @@ type AccessPolicy struct { Resource string `json:"resource" bun:"resource,type:VARCHAR(120),notnull"` Operation string `json:"operation" bun:"operation,type:VARCHAR(80),notnull"` Effect PolicyEffect `json:"effect" bun:"effect,type:iam_policy_effect_enum,notnull"` - Priority int `json:"priority" bun:"priority,notnull,default:0"` + Priority int `json:"priority" bun:"priority,notnull"` Conditions map[string]string `json:"conditions" bun:"conditions,type:JSONB,notnull"` Enabled bool `json:"enabled" bun:"enabled,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,notnull,default:extract(epoch from current_timestamp)::bigint"` diff --git a/services/tms/internal/core/domain/integration/integration.go b/services/tms/internal/core/domain/integration/integration.go index 759d81172..1f192b1f1 100644 --- a/services/tms/internal/core/domain/integration/integration.go +++ b/services/tms/internal/core/domain/integration/integration.go @@ -22,16 +22,16 @@ type Integration struct { Type Type `json:"type" bun:"type,type:integration_type,notnull"` Name string `json:"name" bun:"name,type:VARCHAR(100),notnull"` Description string `json:"description" bun:"description,type:TEXT,nullzero"` - Enabled bool `json:"enabled" bun:"enabled,type:BOOLEAN,notnull,default:false"` + Enabled bool `json:"enabled" bun:"enabled,type:BOOLEAN,notnull"` BuiltBy string `json:"builtBy" bun:"built_by,type:VARCHAR(100),nullzero"` Category Category `json:"category" bun:"category,type:integration_category,notnull"` Configuration map[string]any `json:"configuration" bun:"configuration,type:jsonb,nullzero"` DocsURL string `json:"docsUrl" bun:"docs_url,type:TEXT,nullzero"` - Featured bool `json:"featured" bun:"featured,type:BOOLEAN,notnull,default:false"` + Featured bool `json:"featured" bun:"featured,type:BOOLEAN,notnull"` LogoURL string `json:"logoUrl" bun:"logo_url,type:TEXT,nullzero"` WebsiteURL string `json:"websiteUrl" bun:"website_url,type:TEXT,nullzero"` EnabledByID pulid.ID `json:"enabledById" bun:"enabled_by_id,type:VARCHAR(100),nullzero"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,notnull,default:extract(epoch from current_timestamp)::bigint"` diff --git a/services/tms/internal/core/domain/invoice/invoice.go b/services/tms/internal/core/domain/invoice/invoice.go index 2754aed89..74f77460c 100644 --- a/services/tms/internal/core/domain/invoice/invoice.go +++ b/services/tms/internal/core/domain/invoice/invoice.go @@ -70,13 +70,13 @@ type Invoice struct { BillToPostalCode string `json:"billToPostalCode" bun:"bill_to_postal_code,type:VARCHAR(20),nullzero"` BillToCountry string `json:"billToCountry" bun:"bill_to_country,type:VARCHAR(100),nullzero"` SubtotalAmount decimal.Decimal `json:"subtotalAmount" bun:"subtotal_amount,type:NUMERIC(19,4),notnull,default:0"` - SubtotalAmountMinor int64 `json:"subtotalAmountMinor" bun:"subtotal_amount_minor,type:BIGINT,notnull,default:0"` + SubtotalAmountMinor int64 `json:"subtotalAmountMinor" bun:"subtotal_amount_minor,type:BIGINT,notnull"` OtherAmount decimal.Decimal `json:"otherAmount" bun:"other_amount,type:NUMERIC(19,4),notnull,default:0"` - OtherAmountMinor int64 `json:"otherAmountMinor" bun:"other_amount_minor,type:BIGINT,notnull,default:0"` + OtherAmountMinor int64 `json:"otherAmountMinor" bun:"other_amount_minor,type:BIGINT,notnull"` TotalAmount decimal.Decimal `json:"totalAmount" bun:"total_amount,type:NUMERIC(19,4),notnull,default:0"` - TotalAmountMinor int64 `json:"totalAmountMinor" bun:"total_amount_minor,type:BIGINT,notnull,default:0"` + TotalAmountMinor int64 `json:"totalAmountMinor" bun:"total_amount_minor,type:BIGINT,notnull"` AppliedAmount decimal.Decimal `json:"appliedAmount" bun:"applied_amount,type:NUMERIC(19,4),notnull,default:0"` - AppliedAmountMinor int64 `json:"appliedAmountMinor" bun:"applied_amount_minor,type:BIGINT,notnull,default:0"` + AppliedAmountMinor int64 `json:"appliedAmountMinor" bun:"applied_amount_minor,type:BIGINT,notnull"` SettlementStatus SettlementStatus `json:"settlementStatus" bun:"settlement_status,type:VARCHAR(50),notnull,default:'Unpaid'"` DisputeStatus DisputeStatus `json:"disputeStatus" bun:"dispute_status,type:VARCHAR(50),notnull,default:'None'"` PDFDocumentID pulid.ID `json:"pdfDocumentId" bun:"pdf_document_id,type:VARCHAR(100),nullzero"` @@ -96,8 +96,8 @@ type Invoice struct { SupersedesInvoiceID pulid.ID `json:"supersedesInvoiceId" bun:"supersedes_invoice_id,type:VARCHAR(100),nullzero"` SupersededByInvoiceID pulid.ID `json:"supersededByInvoiceId" bun:"superseded_by_invoice_id,type:VARCHAR(100),nullzero"` SourceInvoiceAdjustmentID pulid.ID `json:"sourceInvoiceAdjustmentId" bun:"source_invoice_adjustment_id,type:VARCHAR(100),nullzero"` - IsAdjustmentArtifact bool `json:"isAdjustmentArtifact" bun:"is_adjustment_artifact,type:BOOLEAN,notnull,default:false"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + IsAdjustmentArtifact bool `json:"isAdjustmentArtifact" bun:"is_adjustment_artifact,type:BOOLEAN,notnull"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` @@ -127,8 +127,8 @@ type InoviceLine struct { Quantity decimal.Decimal `json:"quantity" bun:"quantity,type:NUMERIC(19,4),notnull,default:0"` UnitPrice decimal.Decimal `json:"unitPrice" bun:"unit_price,type:NUMERIC(19,4),notnull,default:0"` Amount decimal.Decimal `json:"amount" bun:"amount,type:NUMERIC(19,4),notnull,default:0"` - AmountMinor int64 `json:"amountMinor" bun:"amount_minor,type:BIGINT,notnull,default:0"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + AmountMinor int64 `json:"amountMinor" bun:"amount_minor,type:BIGINT,notnull"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` @@ -144,7 +144,7 @@ type Attachment struct { InvoiceID pulid.ID `json:"invoiceId" bun:"invoice_id,type:VARCHAR(100),notnull"` DocumentID pulid.ID `json:"documentId" bun:"document_id,type:VARCHAR(100),notnull"` Selected bool `json:"selected" bun:"selected,type:BOOLEAN,notnull,default:true"` - SortOrder int `json:"sortOrder" bun:"sort_order,type:INTEGER,notnull,default:0"` + SortOrder int `json:"sortOrder" bun:"sort_order,type:INTEGER,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` @@ -171,7 +171,7 @@ type EmailAttempt struct { BCCRecipients []string `json:"bccRecipients" bun:"bcc_recipients,array,type:text[],nullzero"` Subject string `json:"subject" bun:"subject,type:VARCHAR(998),notnull"` Body string `json:"body" bun:"body,type:TEXT,nullzero"` - EstimatedSize int64 `json:"estimatedSize" bun:"estimated_size,type:BIGINT,notnull,default:0"` + EstimatedSize int64 `json:"estimatedSize" bun:"estimated_size,type:BIGINT,notnull"` Warnings []string `json:"warnings" bun:"warnings,array,type:text[],nullzero"` Error string `json:"error" bun:"error,type:TEXT,nullzero"` SentAt *int64 `json:"sentAt" bun:"sent_at,type:BIGINT,nullzero"` diff --git a/services/tms/internal/core/domain/invoiceadjustment/batch.go b/services/tms/internal/core/domain/invoiceadjustment/batch.go index 709e47fd0..198089e13 100644 --- a/services/tms/internal/core/domain/invoiceadjustment/batch.go +++ b/services/tms/internal/core/domain/invoiceadjustment/batch.go @@ -16,18 +16,18 @@ type InvoiceAdjustmentBatch struct { BusinessUnitID pulid.ID `json:"businessUnitId" bun:"business_unit_id,pk,type:VARCHAR(100),notnull"` IdempotencyKey string `json:"idempotencyKey" bun:"idempotency_key,type:VARCHAR(200),notnull"` Status BatchStatus `json:"status" bun:"status,type:VARCHAR(50),notnull,default:'Pending'"` - TotalCount int `json:"totalCount" bun:"total_count,type:INTEGER,notnull,default:0"` - ProcessedCount int `json:"processedCount" bun:"processed_count,type:INTEGER,notnull,default:0"` - SucceededCount int `json:"succeededCount" bun:"succeeded_count,type:INTEGER,notnull,default:0"` - FailedCount int `json:"failedCount" bun:"failed_count,type:INTEGER,notnull,default:0"` + TotalCount int `json:"totalCount" bun:"total_count,type:INTEGER,notnull"` + ProcessedCount int `json:"processedCount" bun:"processed_count,type:INTEGER,notnull"` + SucceededCount int `json:"succeededCount" bun:"succeeded_count,type:INTEGER,notnull"` + FailedCount int `json:"failedCount" bun:"failed_count,type:INTEGER,notnull"` SubmittedByID pulid.ID `json:"submittedById" bun:"submitted_by_id,type:VARCHAR(100),nullzero"` SubmittedAt *int64 `json:"submittedAt" bun:"submitted_at,type:BIGINT,nullzero"` SubmittedByName string `json:"submittedByName" bun:"submitted_by_name,scanonly"` PendingCount int `json:"pendingCount" bun:"pending_count,scanonly"` LastFailure string `json:"lastFailure" bun:"last_failure,scanonly"` LastFailureCount int `json:"lastFailureCount" bun:"last_failure_count,scanonly"` - Metadata map[string]any `json:"metadata" bun:"metadata,type:JSONB,notnull,default:'{}'::jsonb"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Metadata map[string]any `json:"metadata" bun:"metadata,type:JSONB,notnull,default:'{}'"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` @@ -46,8 +46,8 @@ type InvoiceAdjustmentBatchItem struct { IdempotencyKey string `json:"idempotencyKey" bun:"idempotency_key,type:VARCHAR(200),notnull"` Status BatchItemStatus `json:"status" bun:"status,type:VARCHAR(50),notnull,default:'Pending'"` ErrorMessage string `json:"errorMessage" bun:"error_message,type:TEXT,nullzero"` - RequestPayload map[string]any `json:"requestPayload" bun:"request_payload,type:JSONB,notnull,default:'{}'::jsonb"` - ResultPayload map[string]any `json:"resultPayload" bun:"result_payload,type:JSONB,notnull,default:'{}'::jsonb"` + RequestPayload map[string]any `json:"requestPayload" bun:"request_payload,type:JSONB,notnull,default:'{}'"` + ResultPayload map[string]any `json:"resultPayload" bun:"result_payload,type:JSONB,notnull,default:'{}'"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` } diff --git a/services/tms/internal/core/domain/invoiceadjustment/invoiceadjustment.go b/services/tms/internal/core/domain/invoiceadjustment/invoiceadjustment.go index 08478e4b9..af235ae9c 100644 --- a/services/tms/internal/core/domain/invoiceadjustment/invoiceadjustment.go +++ b/services/tms/internal/core/domain/invoiceadjustment/invoiceadjustment.go @@ -51,15 +51,15 @@ type InvoiceAdjustment struct { IdempotencyKey string `json:"idempotencyKey" bun:"idempotency_key,type:VARCHAR(200),notnull"` AccountingDate int64 `json:"accountingDate" bun:"accounting_date,type:BIGINT,notnull"` CreditTotalAmount decimal.Decimal `json:"creditTotalAmount" bun:"credit_total_amount,type:NUMERIC(19,4),notnull,default:0"` - CreditTotalAmountMinor int64 `json:"creditTotalAmountMinor" bun:"credit_total_amount_minor,type:BIGINT,notnull,default:0"` + CreditTotalAmountMinor int64 `json:"creditTotalAmountMinor" bun:"credit_total_amount_minor,type:BIGINT,notnull"` RebillTotalAmount decimal.Decimal `json:"rebillTotalAmount" bun:"rebill_total_amount,type:NUMERIC(19,4),notnull,default:0"` - RebillTotalAmountMinor int64 `json:"rebillTotalAmountMinor" bun:"rebill_total_amount_minor,type:BIGINT,notnull,default:0"` + RebillTotalAmountMinor int64 `json:"rebillTotalAmountMinor" bun:"rebill_total_amount_minor,type:BIGINT,notnull"` NetDeltaAmount decimal.Decimal `json:"netDeltaAmount" bun:"net_delta_amount,type:NUMERIC(19,4),notnull,default:0"` - NetDeltaAmountMinor int64 `json:"netDeltaAmountMinor" bun:"net_delta_amount_minor,type:BIGINT,notnull,default:0"` + NetDeltaAmountMinor int64 `json:"netDeltaAmountMinor" bun:"net_delta_amount_minor,type:BIGINT,notnull"` RerateVariancePercent decimal.Decimal `json:"rerateVariancePercent" bun:"rerate_variance_percent,type:NUMERIC(9,6),notnull,default:0"` - WouldCreateUnappliedCredit bool `json:"wouldCreateUnappliedCredit" bun:"would_create_unapplied_credit,type:BOOLEAN,notnull,default:false"` - RequiresReconciliationException bool `json:"requiresReconciliationException" bun:"requires_reconciliation_exception,type:BOOLEAN,notnull,default:false"` - ApprovalRequired bool `json:"approvalRequired" bun:"approval_required,type:BOOLEAN,notnull,default:false"` + WouldCreateUnappliedCredit bool `json:"wouldCreateUnappliedCredit" bun:"would_create_unapplied_credit,type:BOOLEAN,notnull"` + RequiresReconciliationException bool `json:"requiresReconciliationException" bun:"requires_reconciliation_exception,type:BOOLEAN,notnull"` + ApprovalRequired bool `json:"approvalRequired" bun:"approval_required,type:BOOLEAN,notnull"` SubmittedByID pulid.ID `json:"submittedById" bun:"submitted_by_id,type:VARCHAR(100),nullzero"` SubmittedAt *int64 `json:"submittedAt" bun:"submitted_at,type:BIGINT,nullzero"` ApprovedByID pulid.ID `json:"approvedById" bun:"approved_by_id,type:VARCHAR(100),nullzero"` @@ -68,11 +68,11 @@ type InvoiceAdjustment struct { RejectedAt *int64 `json:"rejectedAt" bun:"rejected_at,type:BIGINT,nullzero"` RejectionReason string `json:"rejectionReason" bun:"rejection_reason,type:TEXT,nullzero"` ExecutionError string `json:"executionError" bun:"execution_error,type:TEXT,nullzero"` - Metadata map[string]any `json:"metadata" bun:"metadata,type:JSONB,notnull,default:'{}'::jsonb"` + Metadata map[string]any `json:"metadata" bun:"metadata,type:JSONB,notnull,default:'{}'"` CustomerSupportingDocumentPolicy customer.InvoiceAdjustmentSupportingDocumentPolicy `json:"customerSupportingDocumentPolicy" bun:"-"` SupportingDocumentsRequired bool `json:"supportingDocumentsRequired" bun:"-"` SupportingDocumentPolicySource string `json:"supportingDocumentPolicySource" bun:"-"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` @@ -98,7 +98,7 @@ type InvoiceAdjustmentDocumentReference struct { SnapshotFileType string `json:"snapshotFileType" bun:"snapshot_file_type,type:VARCHAR(100),notnull"` SnapshotResourceType string `json:"snapshotResourceType" bun:"snapshot_resource_type,type:VARCHAR(100),notnull"` SnapshotResourceID string `json:"snapshotResourceId" bun:"snapshot_resource_id,type:VARCHAR(100),notnull"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` @@ -120,12 +120,12 @@ type InvoiceAdjustmentLine struct { Description string `json:"description" bun:"description,type:TEXT,notnull"` CreditQuantity decimal.Decimal `json:"creditQuantity" bun:"credit_quantity,type:NUMERIC(19,4),notnull,default:0"` CreditAmount decimal.Decimal `json:"creditAmount" bun:"credit_amount,type:NUMERIC(19,4),notnull,default:0"` - CreditAmountMinor int64 `json:"creditAmountMinor" bun:"credit_amount_minor,type:BIGINT,notnull,default:0"` + CreditAmountMinor int64 `json:"creditAmountMinor" bun:"credit_amount_minor,type:BIGINT,notnull"` RemainingEligibleAmount decimal.Decimal `json:"remainingEligibleAmount" bun:"remaining_eligible_amount,type:NUMERIC(19,4),notnull,default:0"` RebillQuantity decimal.Decimal `json:"rebillQuantity" bun:"rebill_quantity,type:NUMERIC(19,4),notnull,default:0"` RebillAmount decimal.Decimal `json:"rebillAmount" bun:"rebill_amount,type:NUMERIC(19,4),notnull,default:0"` - RebillAmountMinor int64 `json:"rebillAmountMinor" bun:"rebill_amount_minor,type:BIGINT,notnull,default:0"` - ReplacementPayload map[string]any `json:"replacementPayload" bun:"replacement_payload,type:JSONB,notnull,default:'{}'::jsonb"` + RebillAmountMinor int64 `json:"rebillAmountMinor" bun:"rebill_amount_minor,type:BIGINT,notnull"` + ReplacementPayload map[string]any `json:"replacementPayload" bun:"replacement_payload,type:JSONB,notnull,default:'{}'"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` } @@ -139,7 +139,7 @@ type InvoiceAdjustmentSnapshot struct { AdjustmentID pulid.ID `json:"adjustmentId" bun:"adjustment_id,type:VARCHAR(100),notnull"` InvoiceID pulid.ID `json:"invoiceId" bun:"invoice_id,type:VARCHAR(100),notnull"` Kind SnapshotKind `json:"kind" bun:"kind,type:VARCHAR(50),notnull"` - Payload map[string]any `json:"payload" bun:"payload,type:JSONB,notnull,default:'{}'::jsonb"` + Payload map[string]any `json:"payload" bun:"payload,type:JSONB,notnull,default:'{}'"` CreatedByID pulid.ID `json:"createdById" bun:"created_by_id,type:VARCHAR(100),nullzero"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` } @@ -152,7 +152,7 @@ type InvoiceAdjustmentCorrectionGroup struct { BusinessUnitID pulid.ID `json:"businessUnitId" bun:"business_unit_id,pk,type:VARCHAR(100),notnull"` RootInvoiceID pulid.ID `json:"rootInvoiceId" bun:"root_invoice_id,type:VARCHAR(100),notnull"` CurrentInvoiceID pulid.ID `json:"currentInvoiceId" bun:"current_invoice_id,type:VARCHAR(100),nullzero"` - Metadata map[string]any `json:"metadata" bun:"metadata,type:JSONB,notnull,default:'{}'::jsonb"` + Metadata map[string]any `json:"metadata" bun:"metadata,type:JSONB,notnull,default:'{}'"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` } @@ -169,7 +169,7 @@ type InvoiceAdjustmentReconciliationException struct { Status ExceptionStatus `json:"status" bun:"status,type:VARCHAR(50),notnull,default:'Open'"` Reason string `json:"reason" bun:"reason,type:TEXT,notnull"` Amount decimal.Decimal `json:"amount" bun:"amount,type:NUMERIC(19,4),notnull,default:0"` - Metadata map[string]any `json:"metadata" bun:"metadata,type:JSONB,notnull,default:'{}'::jsonb"` + Metadata map[string]any `json:"metadata" bun:"metadata,type:JSONB,notnull,default:'{}'"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` } diff --git a/services/tms/internal/core/domain/journalreversal/journalreversal.go b/services/tms/internal/core/domain/journalreversal/journalreversal.go index 4d5d6ab44..9787c97c5 100644 --- a/services/tms/internal/core/domain/journalreversal/journalreversal.go +++ b/services/tms/internal/core/domain/journalreversal/journalreversal.go @@ -45,7 +45,7 @@ type Reversal struct { PostedAt *int64 `json:"postedAt" bun:"posted_at,type:BIGINT,nullzero"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` } func (r *Reversal) GetID() pulid.ID { diff --git a/services/tms/internal/core/domain/location/location.go b/services/tms/internal/core/domain/location/location.go index f1851bbb0..266d03e01 100644 --- a/services/tms/internal/core/domain/location/location.go +++ b/services/tms/internal/core/domain/location/location.go @@ -44,7 +44,7 @@ type Location struct { City string `json:"city" bun:"city,type:VARCHAR(100),notnull"` PostalCode string `json:"postalCode" bun:"postal_code,type:us_postal_code,notnull"` PlaceID string `json:"placeId" bun:"place_id,type:TEXT,nullzero"` - IsGeocoded bool `json:"isGeocoded" bun:"is_geocoded,type:BOOLEAN,default:false"` + IsGeocoded bool `json:"isGeocoded" bun:"is_geocoded,type:BOOLEAN"` Longitude *float64 `json:"longitude" bun:"longitude,type:FLOAT,nullzero"` Latitude *float64 `json:"latitude" bun:"latitude,type:FLOAT,nullzero"` Geom *postgis.Point `json:"-" bun:"geom,type:geography,scanonly"` diff --git a/services/tms/internal/core/domain/locationcategory/locationcategory.go b/services/tms/internal/core/domain/locationcategory/locationcategory.go index 0192726fb..fa9f3d7d1 100644 --- a/services/tms/internal/core/domain/locationcategory/locationcategory.go +++ b/services/tms/internal/core/domain/locationcategory/locationcategory.go @@ -35,10 +35,10 @@ type LocationCategory struct { Type Category `json:"type" bun:"type,type:location_category_type,notnull"` FacilityType FacilityType `json:"facilityType" bun:"facility_type,type:facility_type,nullzero"` Color string `json:"color" bun:"color,type:VARCHAR(10),nullzero"` - HasSecureParking bool `json:"hasSecureParking" bun:"has_secure_parking,type:BOOLEAN,default:false"` - RequiresAppointment bool `json:"requiresAppointment" bun:"requires_appointment,type:BOOLEAN,default:false"` - AllowsOvernight bool `json:"allowsOvernight" bun:"allows_overnight,type:BOOLEAN,default:false"` - HasRestroom bool `json:"hasRestroom" bun:"has_restroom,type:BOOLEAN,default:false"` + HasSecureParking bool `json:"hasSecureParking" bun:"has_secure_parking,type:BOOLEAN"` + RequiresAppointment bool `json:"requiresAppointment" bun:"requires_appointment,type:BOOLEAN"` + AllowsOvernight bool `json:"allowsOvernight" bun:"allows_overnight,type:BOOLEAN"` + HasRestroom bool `json:"hasRestroom" bun:"has_restroom,type:BOOLEAN"` Version int64 `json:"version" bun:"version,type:BIGINT"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` diff --git a/services/tms/internal/core/domain/manualjournal/manualjournal.go b/services/tms/internal/core/domain/manualjournal/manualjournal.go index 6e4b06ddd..c807a491f 100644 --- a/services/tms/internal/core/domain/manualjournal/manualjournal.go +++ b/services/tms/internal/core/domain/manualjournal/manualjournal.go @@ -31,8 +31,8 @@ type Request struct { RequestedFiscalYearID pulid.ID `json:"requestedFiscalYearId" bun:"requested_fiscal_year_id,type:VARCHAR(100),notnull"` RequestedFiscalPeriodID pulid.ID `json:"requestedFiscalPeriodId" bun:"requested_fiscal_period_id,type:VARCHAR(100),notnull"` CurrencyCode string `json:"currencyCode" bun:"currency_code,type:VARCHAR(3),notnull,default:'USD'"` - TotalDebit int64 `json:"totalDebit" bun:"total_debit_minor,type:BIGINT,notnull,default:0"` - TotalCredit int64 `json:"totalCredit" bun:"total_credit_minor,type:BIGINT,notnull,default:0"` + TotalDebit int64 `json:"totalDebit" bun:"total_debit_minor,type:BIGINT,notnull"` + TotalCredit int64 `json:"totalCredit" bun:"total_credit_minor,type:BIGINT,notnull"` ApprovedAt *int64 `json:"approvedAt" bun:"approved_at,type:BIGINT,nullzero"` ApprovedByID pulid.ID `json:"approvedById" bun:"approved_by_id,type:VARCHAR(100),nullzero"` RejectedAt *int64 `json:"rejectedAt" bun:"rejected_at,type:BIGINT,nullzero"` @@ -44,7 +44,7 @@ type Request struct { PostedBatchID pulid.ID `json:"postedBatchId" bun:"posted_batch_id,type:VARCHAR(100),nullzero"` CreatedByID pulid.ID `json:"createdById" bun:"created_by_id,type:VARCHAR(100),notnull"` UpdatedByID pulid.ID `json:"updatedById" bun:"updated_by_id,type:VARCHAR(100),nullzero"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` @@ -61,8 +61,8 @@ type Line struct { LineNumber int `json:"lineNumber" bun:"line_number,type:INTEGER,notnull"` GLAccountID pulid.ID `json:"glAccountId" bun:"gl_account_id,type:VARCHAR(100),notnull"` Description string `json:"description" bun:"description,type:TEXT,notnull"` - DebitAmount int64 `json:"debitAmount" bun:"debit_amount_minor,type:BIGINT,notnull,default:0"` - CreditAmount int64 `json:"creditAmount" bun:"credit_amount_minor,type:BIGINT,notnull,default:0"` + DebitAmount int64 `json:"debitAmount" bun:"debit_amount_minor,type:BIGINT,notnull"` + CreditAmount int64 `json:"creditAmount" bun:"credit_amount_minor,type:BIGINT,notnull"` CustomerID pulid.ID `json:"customerId" bun:"customer_id,type:VARCHAR(100),nullzero"` LocationID pulid.ID `json:"locationId" bun:"location_id,type:VARCHAR(100),nullzero"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` diff --git a/services/tms/internal/core/domain/notification/notification.go b/services/tms/internal/core/domain/notification/notification.go index 002a1d40b..77bc544b7 100644 --- a/services/tms/internal/core/domain/notification/notification.go +++ b/services/tms/internal/core/domain/notification/notification.go @@ -42,13 +42,13 @@ type Notification struct { CreatedAt int64 `json:"createdAt" bun:"created_at,nullzero,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,nullzero,notnull,default:extract(epoch from current_timestamp)::bigint"` DeliveryStatus DeliveryStatus `json:"deliveryStatus" bun:"delivery_status,type:VARCHAR(20),notnull,default:'pending'"` - RetryCount int `json:"retryCount" bun:"retry_count,type:INT,notnull,default:0"` + RetryCount int `json:"retryCount" bun:"retry_count,type:INT,notnull"` MaxRetries int `json:"maxRetries" bun:"max_retries,type:INT,notnull,default:3"` Source string `json:"source" bun:"source,type:VARCHAR(100),notnull"` JobID *string `json:"jobId" bun:"job_id,type:VARCHAR(255)"` CorrelationID *string `json:"correlationId" bun:"correlation_id,type:VARCHAR(255)"` Tags []string `json:"tags" bun:"tags,type:text[],array"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` } func (n *Notification) BeforeAppendModel(_ context.Context, query bun.Query) error { diff --git a/services/tms/internal/core/domain/permission/role.go b/services/tms/internal/core/domain/permission/role.go index f572ea98e..93c5be238 100644 --- a/services/tms/internal/core/domain/permission/role.go +++ b/services/tms/internal/core/domain/permission/role.go @@ -39,7 +39,7 @@ type Role struct { CoreResponsibility CoreResponsibility `json:"coreResponsibility" bun:"core_responsibility,type:VARCHAR(50),nullzero"` ParentRoleIDs []pulid.ID `json:"parentRoleIds" bun:"parent_role_ids,type:TEXT[],array"` MaxSensitivity FieldSensitivity `json:"maxSensitivity" bun:"max_sensitivity,type:VARCHAR(20),notnull,default:'internal'"` - IsSystem bool `json:"isSystem" bun:"is_system,default:false"` + IsSystem bool `json:"isSystem" bun:"is_system"` CreatedBy pulid.ID `json:"createdBy" bun:"created_by,type:VARCHAR(100)"` CreatedAt int64 `json:"createdAt" bun:"created_at,notnull"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,notnull"` diff --git a/services/tms/internal/core/domain/ratetable/entry.go b/services/tms/internal/core/domain/ratetable/entry.go index 5bdbe556d..912398ccf 100644 --- a/services/tms/internal/core/domain/ratetable/entry.go +++ b/services/tms/internal/core/domain/ratetable/entry.go @@ -26,7 +26,7 @@ type RateTableEntry struct { RangeMin decimal.NullDecimal `json:"rangeMin" bun:"range_min,type:NUMERIC(19,4)"` RangeMax decimal.NullDecimal `json:"rangeMax" bun:"range_max,type:NUMERIC(19,4)"` Value decimal.Decimal `json:"value" bun:"value,type:NUMERIC(19,4),notnull"` - SortOrder int32 `json:"sortOrder" bun:"sort_order,type:INTEGER,notnull,default:0"` + SortOrder int32 `json:"sortOrder" bun:"sort_order,type:INTEGER,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` } diff --git a/services/tms/internal/core/domain/recurringshipment/recurringshipment.go b/services/tms/internal/core/domain/recurringshipment/recurringshipment.go index 2facc37cb..aa3ba5852 100644 --- a/services/tms/internal/core/domain/recurringshipment/recurringshipment.go +++ b/services/tms/internal/core/domain/recurringshipment/recurringshipment.go @@ -55,7 +55,7 @@ type RecurringShipment struct { EndDate *int64 `json:"endDate" bun:"end_date,type:BIGINT,nullzero"` MaxOccurrences *int32 `json:"maxOccurrences" bun:"max_occurrences,type:INTEGER,nullzero"` LeadTimeDays int16 `json:"leadTimeDays" bun:"lead_time_days,type:SMALLINT,notnull,default:1"` - SkipWeekends bool `json:"skipWeekends" bun:"skip_weekends,type:BOOLEAN,notnull,default:false"` + SkipWeekends bool `json:"skipWeekends" bun:"skip_weekends,type:BOOLEAN,notnull"` ExceptionPolicy ExceptionPolicy `json:"exceptionPolicy" bun:"exception_policy,type:recurring_shipment_exception_policy_enum,notnull,default:'Skip'"` BlackoutDates []string `json:"blackoutDates" bun:"blackout_dates,type:TEXT[],array,nullzero"` AutoGenerate bool `json:"autoGenerate" bun:"auto_generate,type:BOOLEAN,notnull,default:true"` @@ -63,8 +63,8 @@ type RecurringShipment struct { NextOccurrenceSourceAt *int64 `json:"nextOccurrenceSourceAt" bun:"next_occurrence_source_at,type:BIGINT,nullzero"` LastOccurrenceAt *int64 `json:"lastOccurrenceAt" bun:"last_occurrence_at,type:BIGINT,nullzero"` LastRunAt *int64 `json:"lastRunAt" bun:"last_run_at,type:BIGINT,nullzero"` - GenerationCount int64 `json:"generationCount" bun:"generation_count,type:BIGINT,notnull,default:0"` - ConsecutiveFailures int32 `json:"consecutiveFailures" bun:"consecutive_failures,type:INTEGER,notnull,default:0"` + GenerationCount int64 `json:"generationCount" bun:"generation_count,type:BIGINT,notnull"` + ConsecutiveFailures int32 `json:"consecutiveFailures" bun:"consecutive_failures,type:INTEGER,notnull"` Version int64 `json:"version" bun:"version,type:BIGINT"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` diff --git a/services/tms/internal/core/domain/report/run.go b/services/tms/internal/core/domain/report/run.go index 7dd8787cb..1b6e48b04 100644 --- a/services/tms/internal/core/domain/report/run.go +++ b/services/tms/internal/core/domain/report/run.go @@ -42,11 +42,11 @@ type ReportRun struct { RowCount int64 `json:"rowCount" bun:"row_count,type:BIGINT,nullzero"` ByteSize int64 `json:"byteSize" bun:"byte_size,type:BIGINT,nullzero"` DurationMs int64 `json:"durationMs" bun:"duration_ms,type:BIGINT,nullzero"` - Truncated bool `json:"truncated" bun:"truncated,type:BOOLEAN,notnull,default:false"` + Truncated bool `json:"truncated" bun:"truncated,type:BOOLEAN,notnull"` Error *RunError `json:"error" bun:"error,type:JSONB,nullzero"` ArtifactKey string `json:"artifactKey" bun:"artifact_key,type:VARCHAR(512),nullzero"` ArtifactExpiresAt int64 `json:"artifactExpiresAt" bun:"artifact_expires_at,type:BIGINT,nullzero"` - CacheHit bool `json:"cacheHit" bun:"cache_hit,type:BOOLEAN,notnull,default:false"` + CacheHit bool `json:"cacheHit" bun:"cache_hit,type:BOOLEAN,notnull"` TemporalWorkflowID string `json:"temporalWorkflowId" bun:"temporal_workflow_id,type:VARCHAR(255),nullzero"` TemporalRunID string `json:"temporalRunId" bun:"temporal_run_id,type:VARCHAR(255),nullzero"` QueuedAt int64 `json:"queuedAt" bun:"queued_at,type:BIGINT,nullzero"` diff --git a/services/tms/internal/core/domain/report/schedule.go b/services/tms/internal/core/domain/report/schedule.go index 7fc0cbe9c..26468885d 100644 --- a/services/tms/internal/core/domain/report/schedule.go +++ b/services/tms/internal/core/domain/report/schedule.go @@ -210,12 +210,12 @@ type ReportSchedule struct { Formats []string `json:"formats" bun:"formats,type:TEXT[],array,notnull"` Delivery *ScheduleDelivery `json:"delivery" bun:"delivery,type:JSONB,nullzero"` Alert *ScheduleAlert `json:"alert" bun:"alert,type:JSONB,nullzero"` - AlertFiring bool `json:"alertFiring" bun:"alert_firing,type:BOOLEAN,notnull,default:false"` + AlertFiring bool `json:"alertFiring" bun:"alert_firing,type:BOOLEAN,notnull"` Enabled bool `json:"enabled" bun:"enabled,type:BOOLEAN,notnull,default:true"` RunAsID pulid.ID `json:"runAsId" bun:"run_as_id,type:VARCHAR(100),notnull"` LastRunID pulid.ID `json:"lastRunId" bun:"last_run_id,type:VARCHAR(100),nullzero"` NextRunAt int64 `json:"nextRunAt" bun:"next_run_at,type:BIGINT,nullzero"` - ConsecutiveFailures int `json:"consecutiveFailures" bun:"consecutive_failures,type:INTEGER,notnull,default:0"` + ConsecutiveFailures int `json:"consecutiveFailures" bun:"consecutive_failures,type:INTEGER,notnull"` Version int64 `json:"version" bun:"version,type:BIGINT"` CreatedAt int64 `json:"createdAt" bun:"created_at,nullzero,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,nullzero,notnull,default:extract(epoch from current_timestamp)::bigint"` diff --git a/services/tms/internal/core/domain/report/view.go b/services/tms/internal/core/domain/report/view.go index aa5f4f587..9c7ae4886 100644 --- a/services/tms/internal/core/domain/report/view.go +++ b/services/tms/internal/core/domain/report/view.go @@ -40,13 +40,13 @@ type ReportView struct { // Shared publishes the view to everyone who can read the report. A private // view stays with its owner, which is what keeps one person's working set // out of everybody else's list. - Shared bool `json:"shared" bun:"shared,type:BOOLEAN,notnull,default:false"` + Shared bool `json:"shared" bun:"shared,type:BOOLEAN,notnull"` // Pinned is per-owner ordering intent: a pinned view sorts to the front of // the picker so the one someone opens daily is never buried. - Pinned bool `json:"pinned" bun:"pinned,type:BOOLEAN,notnull,default:false"` + Pinned bool `json:"pinned" bun:"pinned,type:BOOLEAN,notnull"` Format Format `json:"format" bun:"format,type:VARCHAR(10),nullzero"` LastRunAt int64 `json:"lastRunAt" bun:"last_run_at,type:BIGINT,nullzero"` - RunCount int64 `json:"runCount" bun:"run_count,type:BIGINT,notnull,default:0"` + RunCount int64 `json:"runCount" bun:"run_count,type:BIGINT,notnull"` Version int64 `json:"version" bun:"version,type:BIGINT"` CreatedAt int64 `json:"createdAt" bun:"created_at,nullzero,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,nullzero,notnull,default:extract(epoch from current_timestamp)::bigint"` diff --git a/services/tms/internal/core/domain/servicefailure/reason_code.go b/services/tms/internal/core/domain/servicefailure/reason_code.go index c1e33ba18..ca5d5a7c6 100644 --- a/services/tms/internal/core/domain/servicefailure/reason_code.go +++ b/services/tms/internal/core/domain/servicefailure/reason_code.go @@ -46,7 +46,7 @@ type ReasonCode struct { ArchivedByID *pulid.ID `json:"archivedById" bun:"archived_by_id,type:VARCHAR(100),nullzero"` ActivatedAt *int64 `json:"activatedAt" bun:"activated_at,type:BIGINT,nullzero"` ActivatedByID *pulid.ID `json:"activatedById" bun:"activated_by_id,type:VARCHAR(100),nullzero"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` SearchVector string `json:"-" bun:"search_vector,type:TSVECTOR,scanonly"` diff --git a/services/tms/internal/core/domain/servicefailure/service_failure.go b/services/tms/internal/core/domain/servicefailure/service_failure.go index 2b993ba6e..a01f0cccc 100644 --- a/services/tms/internal/core/domain/servicefailure/service_failure.go +++ b/services/tms/internal/core/domain/servicefailure/service_failure.go @@ -57,7 +57,7 @@ type ServiceFailure struct { VoidedByID *pulid.ID `json:"voidedById" bun:"voided_by_id,type:VARCHAR(100),nullzero"` VoidReason string `json:"voidReason" bun:"void_reason,type:TEXT,nullzero"` CreatedByID *pulid.ID `json:"createdById" bun:"created_by_id,type:VARCHAR(100),nullzero"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` SearchVector string `json:"-" bun:"search_vector,type:TSVECTOR,scanonly"` diff --git a/services/tms/internal/core/domain/shipment/additionalcharge.go b/services/tms/internal/core/domain/shipment/additionalcharge.go index 8d1b4fcd2..d3312114c 100644 --- a/services/tms/internal/core/domain/shipment/additionalcharge.go +++ b/services/tms/internal/core/domain/shipment/additionalcharge.go @@ -22,7 +22,7 @@ type AdditionalCharge struct { OrganizationID pulid.ID `json:"organizationId" bun:"organization_id,pk,notnull,type:VARCHAR(100)"` ShipmentID pulid.ID `json:"shipmentId" bun:"shipment_id,type:VARCHAR(100),notnull"` AccessorialChargeID pulid.ID `json:"accessorialChargeId" bun:"accessorial_charge_id,type:VARCHAR(100),notnull"` - IsSystemGenerated bool `json:"isSystemGenerated" bun:"is_system_generated,type:BOOLEAN,notnull,default:false"` + IsSystemGenerated bool `json:"isSystemGenerated" bun:"is_system_generated,type:BOOLEAN,notnull"` Method accessorialcharge.Method `json:"method" bun:"method,type:accessorial_method_enum,notnull"` Amount decimal.Decimal `json:"amount" bun:"amount,type:NUMERIC(19,4),notnull"` Unit int16 `json:"unit" bun:"unit,type:INTEGER,notnull"` diff --git a/services/tms/internal/core/domain/shipment/comment.go b/services/tms/internal/core/domain/shipment/comment.go index 10262a07c..c4acf7704 100644 --- a/services/tms/internal/core/domain/shipment/comment.go +++ b/services/tms/internal/core/domain/shipment/comment.go @@ -44,18 +44,18 @@ type ShipmentComment struct { Visibility CommentVisibility `json:"visibility" bun:"visibility,type:VARCHAR(50),notnull,default:'Internal'"` Priority CommentPriority `json:"priority" bun:"priority,type:VARCHAR(20),notnull,default:'Normal'"` Source CommentSource `json:"source" bun:"source,type:VARCHAR(20),notnull,default:'User'"` - Metadata map[string]any `json:"metadata,omitempty" bun:"metadata,type:JSONB,default:'{}'::jsonb"` + Metadata map[string]any `json:"metadata,omitempty" bun:"metadata,type:JSONB,default:'{}'"` EditedAt *int64 `json:"editedAt" bun:"edited_at,type:BIGINT,nullzero"` PinnedAt *int64 `json:"pinnedAt" bun:"pinned_at,type:BIGINT,nullzero"` PinnedByID *pulid.ID `json:"pinnedById" bun:"pinned_by_id,type:VARCHAR(100),nullzero"` ResolvedAt *int64 `json:"resolvedAt" bun:"resolved_at,type:BIGINT,nullzero"` ResolvedByID *pulid.ID `json:"resolvedById" bun:"resolved_by_id,type:VARCHAR(100),nullzero"` - RequiresAcknowledgment bool `json:"requiresAcknowledgment" bun:"requires_acknowledgment,type:BOOLEAN,notnull,default:false"` + RequiresAcknowledgment bool `json:"requiresAcknowledgment" bun:"requires_acknowledgment,type:BOOLEAN,notnull"` DeletedAt *int64 `json:"deletedAt" bun:"deleted_at,type:BIGINT,nullzero"` DeletedByID *pulid.ID `json:"deletedById" bun:"deleted_by_id,type:VARCHAR(100),nullzero"` SearchVector string `json:"-" bun:"search_vector,type:TSVECTOR,scanonly"` ReplyCount int64 `json:"replyCount" bun:"reply_count,scanonly"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` MentionedUserIDs []pulid.ID `json:"mentionedUserIds,omitempty" bun:"-"` diff --git a/services/tms/internal/core/domain/shipment/hold.go b/services/tms/internal/core/domain/shipment/hold.go index eaf3fc701..333004cb1 100644 --- a/services/tms/internal/core/domain/shipment/hold.go +++ b/services/tms/internal/core/domain/shipment/hold.go @@ -36,14 +36,14 @@ type ShipmentHold struct { ReasonCode string `json:"reasonCode" bun:"reason_code,type:VARCHAR(100),nullzero"` Notes string `json:"notes" bun:"notes,type:TEXT,nullzero"` Source HoldSource `json:"source" bun:"source,type:hold_source_enum,notnull,default:'User'"` - BlocksDispatch bool `json:"blocksDispatch" bun:"blocks_dispatch,type:BOOLEAN,notnull,default:false"` - BlocksDelivery bool `json:"blocksDelivery" bun:"blocks_delivery,type:BOOLEAN,notnull,default:false"` - BlocksBilling bool `json:"blocksBilling" bun:"blocks_billing,type:BOOLEAN,notnull,default:false"` - VisibleToCustomer bool `json:"visibleToCustomer" bun:"visible_to_customer,type:BOOLEAN,notnull,default:false"` + BlocksDispatch bool `json:"blocksDispatch" bun:"blocks_dispatch,type:BOOLEAN,notnull"` + BlocksDelivery bool `json:"blocksDelivery" bun:"blocks_delivery,type:BOOLEAN,notnull"` + BlocksBilling bool `json:"blocksBilling" bun:"blocks_billing,type:BOOLEAN,notnull"` + VisibleToCustomer bool `json:"visibleToCustomer" bun:"visible_to_customer,type:BOOLEAN,notnull"` StartedAt int64 `json:"startedAt" bun:"started_at,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` ReleasedAt *int64 `json:"releasedAt" bun:"released_at,type:BIGINT,nullzero"` CreatedByID *pulid.ID `json:"createdById" bun:"created_by_id,type:VARCHAR(100),nullzero"` ReleasedByID *pulid.ID `json:"releasedById" bun:"released_by_id,type:VARCHAR(100),nullzero"` diff --git a/services/tms/internal/core/domain/shipment/shipment.go b/services/tms/internal/core/domain/shipment/shipment.go index c39697232..64ff33039 100644 --- a/services/tms/internal/core/domain/shipment/shipment.go +++ b/services/tms/internal/core/domain/shipment/shipment.go @@ -90,7 +90,7 @@ type Shipment struct { MarkedReadyToBillAt *int64 `json:"markedReadyToBillAt" bun:"marked_ready_to_bill_at,type:BIGINT,nullzero"` BilledAt *int64 `json:"billedAt" bun:"billed_at,type:BIGINT,nullzero"` RatingUnit int64 `json:"ratingUnit" bun:"rating_unit,type:INTEGER,notnull,default:1"` - FuelSurchargeLocked bool `json:"fuelSurchargeLocked" bun:"fuel_surcharge_locked,type:BOOLEAN,notnull,default:false"` + FuelSurchargeLocked bool `json:"fuelSurchargeLocked" bun:"fuel_surcharge_locked,type:BOOLEAN,notnull"` RatingDetail *RatingDetail `json:"ratingDetail" bun:"rating_detail,type:JSONB,nullzero"` SourceDocumentID string `json:"sourceDocumentId,omitempty" bun:"-"` SearchVector string `json:"-" bun:"search_vector,type:TSVECTOR,scanonly"` diff --git a/services/tms/internal/core/domain/shipment/shipmentmove.go b/services/tms/internal/core/domain/shipment/shipmentmove.go index 9d97f375b..301d19ba6 100644 --- a/services/tms/internal/core/domain/shipment/shipmentmove.go +++ b/services/tms/internal/core/domain/shipment/shipmentmove.go @@ -20,7 +20,7 @@ type ShipmentMove struct { ShipmentID pulid.ID `json:"shipmentId" bun:"shipment_id,type:VARCHAR(100),notnull"` Status MoveStatus `json:"status" bun:"status,type:move_status_enum,notnull,default:'New'"` Loaded bool `json:"loaded" bun:"loaded,type:BOOLEAN,notnull,default:true"` - Sequence int64 `json:"sequence" bun:"sequence,type:INTEGER,notnull,default:0"` + Sequence int64 `json:"sequence" bun:"sequence,type:INTEGER,notnull"` Distance *float64 `json:"distance" bun:"distance,type:FLOAT,nullzero"` DistanceSource string `json:"distanceSource" bun:"distance_source,type:VARCHAR(50),nullzero"` DistanceProvider string `json:"distanceProvider" bun:"distance_provider,type:VARCHAR(50),nullzero"` diff --git a/services/tms/internal/core/domain/shipment/stop.go b/services/tms/internal/core/domain/shipment/stop.go index 9247022ec..c7226fb27 100644 --- a/services/tms/internal/core/domain/shipment/stop.go +++ b/services/tms/internal/core/domain/shipment/stop.go @@ -23,7 +23,7 @@ type Stop struct { Status StopStatus `json:"status" bun:"status,type:stop_status_enum,notnull,default:'New'"` Type StopType `json:"type" bun:"type,type:stop_type_enum,notnull,default:'Pickup'"` ScheduleType StopScheduleType `json:"scheduleType" bun:"schedule_type,type:stop_schedule_type_enum,notnull,default:'Open'"` - Sequence int64 `json:"sequence" bun:"sequence,type:INTEGER,notnull,default:0"` + Sequence int64 `json:"sequence" bun:"sequence,type:INTEGER,notnull"` Pieces *int64 `json:"pieces" bun:"pieces,type:INTEGER,nullzero"` Weight *int64 `json:"weight" bun:"weight,type:INTEGER,nullzero"` ScheduledWindowStart int64 `json:"scheduledWindowStart" bun:"scheduled_window_start,type:BIGINT,notnull"` diff --git a/services/tms/internal/core/domain/shipmentevent/event.go b/services/tms/internal/core/domain/shipmentevent/event.go index ffbcdcc23..1e94706f3 100644 --- a/services/tms/internal/core/domain/shipmentevent/event.go +++ b/services/tms/internal/core/domain/shipmentevent/event.go @@ -35,7 +35,7 @@ type Event struct { ActorLabel string `json:"actorLabel" bun:"actor_label,type:VARCHAR(100)"` Summary string `json:"summary" bun:"summary,type:TEXT,notnull"` - Metadata map[string]any `json:"metadata,omitempty" bun:"metadata,type:JSONB,default:'{}'::jsonb"` + Metadata map[string]any `json:"metadata,omitempty" bun:"metadata,type:JSONB,default:'{}'"` OccurredAt int64 `json:"occurredAt" bun:"occurred_at,type:BIGINT,notnull"` CorrelationID string `json:"correlationId,omitempty" bun:"correlation_id,type:VARCHAR(100)"` diff --git a/services/tms/internal/core/domain/shipmentimportchat/chat.go b/services/tms/internal/core/domain/shipmentimportchat/chat.go index 9a06f42ab..c53c517ba 100644 --- a/services/tms/internal/core/domain/shipmentimportchat/chat.go +++ b/services/tms/internal/core/domain/shipmentimportchat/chat.go @@ -47,9 +47,9 @@ type Conversation struct { ExternalConversationID string `json:"externalConversationId" bun:"external_conversation_id,type:VARCHAR(255),nullzero"` Status ConversationStatus `json:"status" bun:"status,type:VARCHAR(32),notnull,default:'Active'"` StatusReason ConversationStatusReason `json:"statusReason" bun:"status_reason,type:VARCHAR(64),nullzero"` - TurnCount int `json:"turnCount" bun:"turn_count,type:INTEGER,notnull,default:0"` + TurnCount int `json:"turnCount" bun:"turn_count,type:INTEGER,notnull"` LastMessageAt *int64 `json:"lastMessageAt" bun:"last_message_at,type:BIGINT,nullzero"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` } @@ -71,10 +71,10 @@ type Turn struct { Model string `json:"model" bun:"model,type:VARCHAR(100),nullzero"` ResultStatus TurnResultStatus `json:"resultStatus" bun:"result_status,type:VARCHAR(32),notnull,default:'Completed'"` ErrorMessage string `json:"errorMessage" bun:"error_message,type:TEXT,nullzero"` - ContextJSON rawJSON `json:"contextJson" bun:"context_json,type:JSONB,notnull,default:'{}'::jsonb"` - SuggestionsJSON rawJSON `json:"suggestionsJson" bun:"suggestions_json,type:JSONB,notnull,default:'[]'::jsonb"` - ToolCallsJSON rawJSON `json:"toolCallsJson" bun:"tool_calls_json,type:JSONB,notnull,default:'[]'::jsonb"` - ActionsJSON rawJSON `json:"actionsJson" bun:"actions_json,type:JSONB,notnull,default:'[]'::jsonb"` + ContextJSON rawJSON `json:"contextJson" bun:"context_json,type:JSONB,notnull,default:'{}'"` + SuggestionsJSON rawJSON `json:"suggestionsJson" bun:"suggestions_json,type:JSONB,notnull,default:'[]'"` + ToolCallsJSON rawJSON `json:"toolCallsJson" bun:"tool_calls_json,type:JSONB,notnull,default:'[]'"` + ActionsJSON rawJSON `json:"actionsJson" bun:"actions_json,type:JSONB,notnull,default:'[]'"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` } diff --git a/services/tms/internal/core/domain/storedmileage/storedmileage.go b/services/tms/internal/core/domain/storedmileage/storedmileage.go index d42773092..435587a31 100644 --- a/services/tms/internal/core/domain/storedmileage/storedmileage.go +++ b/services/tms/internal/core/domain/storedmileage/storedmileage.go @@ -71,10 +71,10 @@ type StoredMileage struct { HazmatTypes []string `json:"hazmatTypes" bun:"hazmat_types,array,type:TEXT[],nullzero"` HazmatSignature string `json:"hazmatSignature" bun:"hazmat_signature,type:TEXT,notnull"` ProviderMetadata map[string]any `json:"providerMetadata" bun:"provider_metadata,type:JSONB,nullzero"` - HitCount int64 `json:"hitCount" bun:"hit_count,type:BIGINT,notnull,default:0"` + HitCount int64 `json:"hitCount" bun:"hit_count,type:BIGINT,notnull"` LastUsedAt *int64 `json:"lastUsedAt" bun:"last_used_at,type:BIGINT,nullzero"` LastCalculatedAt int64 `json:"lastCalculatedAt" bun:"last_calculated_at,type:BIGINT,notnull"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` SearchVector string `json:"-" bun:"search_vector,type:TSVECTOR,scanonly"` diff --git a/services/tms/internal/core/domain/tableconfiguration/tableconfiguration.go b/services/tms/internal/core/domain/tableconfiguration/tableconfiguration.go index 653822db0..75ba8f9ab 100644 --- a/services/tms/internal/core/domain/tableconfiguration/tableconfiguration.go +++ b/services/tms/internal/core/domain/tableconfiguration/tableconfiguration.go @@ -62,8 +62,8 @@ type TableConfiguration struct { Visibility Visibility `json:"visibility" bun:"visibility,type:configuration_visibility_enum,notnull,default:'Private'"` SearchVector string `json:"-" bun:"search_vector,type:TSVECTOR,scanonly"` Rank string `json:"-" bun:"rank,type:VARCHAR(100),scanonly"` - IsDefault bool `json:"isDefault" bun:"is_default,type:BOOLEAN,notnull,default:false"` - IsOrgDefault bool `json:"isOrgDefault" bun:"is_org_default,type:BOOLEAN,notnull,default:false"` + IsDefault bool `json:"isDefault" bun:"is_default,type:BOOLEAN,notnull"` + IsOrgDefault bool `json:"isOrgDefault" bun:"is_org_default,type:BOOLEAN,notnull"` Version int64 `json:"version" bun:"version,type:BIGINT"` CreatedAt int64 `json:"createdAt" bun:"created_at,nullzero,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,nullzero,notnull,default:extract(epoch from current_timestamp)::bigint"` diff --git a/services/tms/internal/core/domain/telematics/feedstate.go b/services/tms/internal/core/domain/telematics/feedstate.go index 686b87f86..92e1191ee 100644 --- a/services/tms/internal/core/domain/telematics/feedstate.go +++ b/services/tms/internal/core/domain/telematics/feedstate.go @@ -18,7 +18,7 @@ type FeedState struct { Cursor string `json:"cursor" bun:"cursor,type:TEXT,nullzero"` LastPolledAt int64 `json:"lastPolledAt" bun:"last_polled_at,type:BIGINT,nullzero"` LastSuccessAt int64 `json:"lastSuccessAt" bun:"last_success_at,type:BIGINT,nullzero"` - FailureCount int `json:"failureCount" bun:"failure_count,type:INT,notnull,default:0"` + FailureCount int `json:"failureCount" bun:"failure_count,type:INT,notnull"` LastError string `json:"lastError" bun:"last_error,type:TEXT,nullzero"` } diff --git a/services/tms/internal/core/domain/telematics/formsubmission.go b/services/tms/internal/core/domain/telematics/formsubmission.go index 04f6fcf1b..20535229e 100644 --- a/services/tms/internal/core/domain/telematics/formsubmission.go +++ b/services/tms/internal/core/domain/telematics/formsubmission.go @@ -29,8 +29,8 @@ type FormSubmission struct { StopID pulid.ID `json:"stopId" bun:"stop_id,type:VARCHAR(100),nullzero"` SubmittedAt int64 `json:"submittedAt" bun:"submitted_at,type:BIGINT,notnull"` Fields []FormFieldValue `json:"fields" bun:"fields,type:JSONB,nullzero"` - Applied bool `json:"applied" bun:"applied,type:BOOLEAN,notnull,default:false"` - AppliedFields int `json:"appliedFields" bun:"applied_fields,type:INT,notnull,default:0"` + Applied bool `json:"applied" bun:"applied,type:BOOLEAN,notnull"` + AppliedFields int `json:"appliedFields" bun:"applied_fields,type:INT,notnull"` AppliedAt *int64 `json:"appliedAt" bun:"applied_at,type:BIGINT,nullzero"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull"` } diff --git a/services/tms/internal/core/domain/telematics/hosstate.go b/services/tms/internal/core/domain/telematics/hosstate.go index 26b46c058..afd1654cf 100644 --- a/services/tms/internal/core/domain/telematics/hosstate.go +++ b/services/tms/internal/core/domain/telematics/hosstate.go @@ -18,14 +18,14 @@ type WorkerHOSState struct { Provider string `json:"provider" bun:"provider,type:VARCHAR(32),notnull,default:'Samsara'"` ProviderDriverID string `json:"providerDriverId" bun:"provider_driver_id,type:TEXT,notnull"` DutyStatus DutyStatus `json:"dutyStatus" bun:"duty_status,type:VARCHAR(32),nullzero"` - DriveRemainingMs int64 `json:"driveRemainingMs" bun:"drive_remaining_ms,type:BIGINT,notnull,default:0"` - ShiftRemainingMs int64 `json:"shiftRemainingMs" bun:"shift_remaining_ms,type:BIGINT,notnull,default:0"` - CycleRemainingMs int64 `json:"cycleRemainingMs" bun:"cycle_remaining_ms,type:BIGINT,notnull,default:0"` - CycleTomorrowMs int64 `json:"cycleTomorrowMs" bun:"cycle_tomorrow_ms,type:BIGINT,notnull,default:0"` - BreakRemainingMs int64 `json:"breakRemainingMs" bun:"break_remaining_ms,type:BIGINT,notnull,default:0"` + DriveRemainingMs int64 `json:"driveRemainingMs" bun:"drive_remaining_ms,type:BIGINT,notnull"` + ShiftRemainingMs int64 `json:"shiftRemainingMs" bun:"shift_remaining_ms,type:BIGINT,notnull"` + CycleRemainingMs int64 `json:"cycleRemainingMs" bun:"cycle_remaining_ms,type:BIGINT,notnull"` + CycleTomorrowMs int64 `json:"cycleTomorrowMs" bun:"cycle_tomorrow_ms,type:BIGINT,notnull"` + BreakRemainingMs int64 `json:"breakRemainingMs" bun:"break_remaining_ms,type:BIGINT,notnull"` CycleStartedAt *int64 `json:"cycleStartedAt" bun:"cycle_started_at,type:BIGINT,nullzero"` - ShiftDrivingViolationMs int64 `json:"shiftDrivingViolationMs" bun:"shift_driving_violation_ms,type:BIGINT,notnull,default:0"` - CycleViolationMs int64 `json:"cycleViolationMs" bun:"cycle_violation_ms,type:BIGINT,notnull,default:0"` + ShiftDrivingViolationMs int64 `json:"shiftDrivingViolationMs" bun:"shift_driving_violation_ms,type:BIGINT,notnull"` + CycleViolationMs int64 `json:"cycleViolationMs" bun:"cycle_violation_ms,type:BIGINT,notnull"` CurrentVehicleID string `json:"currentVehicleId" bun:"current_vehicle_id,type:TEXT,nullzero"` RulesetCycle string `json:"rulesetCycle" bun:"ruleset_cycle,type:VARCHAR(64),nullzero"` RulesetShift string `json:"rulesetShift" bun:"ruleset_shift,type:VARCHAR(64),nullzero"` diff --git a/services/tms/internal/core/domain/telematics/hosviolation.go b/services/tms/internal/core/domain/telematics/hosviolation.go index a1cf752b7..5091e4cb0 100644 --- a/services/tms/internal/core/domain/telematics/hosviolation.go +++ b/services/tms/internal/core/domain/telematics/hosviolation.go @@ -17,7 +17,7 @@ type WorkerHOSViolation struct { ViolationType string `json:"violationType" bun:"violation_type,pk,type:VARCHAR(64),notnull"` ViolationStartAt int64 `json:"violationStartAt" bun:"violation_start_at,pk,type:BIGINT,notnull"` Description string `json:"description" bun:"description,type:TEXT,nullzero"` - DurationMs int64 `json:"durationMs" bun:"duration_ms,type:BIGINT,notnull,default:0"` + DurationMs int64 `json:"durationMs" bun:"duration_ms,type:BIGINT,notnull"` DayStartAt *int64 `json:"dayStartAt" bun:"day_start_at,type:BIGINT,nullzero"` DayEndAt *int64 `json:"dayEndAt" bun:"day_end_at,type:BIGINT,nullzero"` DetectedAt int64 `json:"detectedAt" bun:"detected_at,type:BIGINT,notnull"` diff --git a/services/tms/internal/core/domain/telematics/vehicleinspection.go b/services/tms/internal/core/domain/telematics/vehicleinspection.go index 6a780821d..2c3756a9b 100644 --- a/services/tms/internal/core/domain/telematics/vehicleinspection.go +++ b/services/tms/internal/core/domain/telematics/vehicleinspection.go @@ -31,9 +31,9 @@ type VehicleInspection struct { EndedAt int64 `json:"endedAt" bun:"ended_at,type:BIGINT,notnull"` OdometerMeters *int64 `json:"odometerMeters" bun:"odometer_meters,type:BIGINT,nullzero"` Location string `json:"location" bun:"location,type:TEXT,nullzero"` - Signed bool `json:"signed" bun:"signed,type:BOOLEAN,notnull,default:false"` - DefectCount int `json:"defectCount" bun:"defect_count,type:INT,notnull,default:0"` - UnresolvedDefectCount int `json:"unresolvedDefectCount" bun:"unresolved_defect_count,type:INT,notnull,default:0"` + Signed bool `json:"signed" bun:"signed,type:BOOLEAN,notnull"` + DefectCount int `json:"defectCount" bun:"defect_count,type:INT,notnull"` + UnresolvedDefectCount int `json:"unresolvedDefectCount" bun:"unresolved_defect_count,type:INT,notnull"` Defects []VehicleInspectionDefect `json:"defects" bun:"defects,type:JSONB,nullzero"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull"` } diff --git a/services/tms/internal/core/domain/telematics/vehicleposition.go b/services/tms/internal/core/domain/telematics/vehicleposition.go index a7e6e3791..4fe544dd1 100644 --- a/services/tms/internal/core/domain/telematics/vehicleposition.go +++ b/services/tms/internal/core/domain/telematics/vehicleposition.go @@ -19,8 +19,8 @@ type VehiclePosition struct { ProviderVehicleID string `json:"providerVehicleId" bun:"provider_vehicle_id,type:TEXT,notnull"` Latitude float64 `json:"latitude" bun:"latitude,type:DOUBLE PRECISION,notnull"` Longitude float64 `json:"longitude" bun:"longitude,type:DOUBLE PRECISION,notnull"` - HeadingDegrees float64 `json:"headingDegrees" bun:"heading_degrees,type:DOUBLE PRECISION,notnull,default:0"` - SpeedMph float64 `json:"speedMph" bun:"speed_mph,type:DOUBLE PRECISION,notnull,default:0"` + HeadingDegrees float64 `json:"headingDegrees" bun:"heading_degrees,type:DOUBLE PRECISION,notnull"` + SpeedMph float64 `json:"speedMph" bun:"speed_mph,type:DOUBLE PRECISION,notnull"` EngineState EngineState `json:"engineState" bun:"engine_state,type:VARCHAR(16),nullzero"` FuelPercent *float64 `json:"fuelPercent" bun:"fuel_percent,type:DOUBLE PRECISION,nullzero"` OdometerMeters *int64 `json:"odometerMeters" bun:"odometer_meters,type:BIGINT,nullzero"` diff --git a/services/tms/internal/core/domain/tenant/accountingcontrol.go b/services/tms/internal/core/domain/tenant/accountingcontrol.go index 26999801f..fb9610f57 100644 --- a/services/tms/internal/core/domain/tenant/accountingcontrol.go +++ b/services/tms/internal/core/domain/tenant/accountingcontrol.go @@ -38,7 +38,7 @@ type AccountingControl struct { RequirePeriodCloseApproval bool `json:"requirePeriodCloseApproval" bun:"require_period_close_approval,type:BOOLEAN,notnull,default:true"` LockedPeriodPostingPolicy LockedPeriodPostingPolicy `json:"lockedPeriodPostingPolicy" bun:"locked_period_posting_policy,type:locked_period_posting_policy_enum,notnull,default:'BlockSubledgerAllowManualJe'"` ClosedPeriodPostingPolicy ClosedPeriodPostingPolicy `json:"closedPeriodPostingPolicy" bun:"closed_period_posting_policy,type:closed_period_posting_policy_enum,notnull,default:'RequireReopen'"` - RequireReconciliationToClose bool `json:"requireReconciliationToClose" bun:"require_reconciliation_to_close,type:BOOLEAN,notnull,default:false"` + RequireReconciliationToClose bool `json:"requireReconciliationToClose" bun:"require_reconciliation_to_close,type:BOOLEAN,notnull"` ReconciliationMode ReconciliationModeType `json:"reconciliationMode" bun:"reconciliation_mode,type:reconciliation_mode_enum,notnull,default:'Disabled'"` ReconciliationToleranceAmount decimal.Decimal `json:"reconciliationToleranceAmount" bun:"reconciliation_tolerance_amount,type:NUMERIC(19,4),notnull,default:0.0000"` @@ -69,7 +69,7 @@ type AccountingControl struct { DefaultDriverReimbursementAccountID pulid.ID `json:"defaultDriverReimbursementAccountId" bun:"default_driver_reimbursement_account_id,type:VARCHAR(100),nullzero"` DefaultEscrowInterestExpenseAccountID pulid.ID `json:"defaultEscrowInterestExpenseAccountId" bun:"default_escrow_interest_expense_account_id,type:VARCHAR(100),nullzero"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,notnull,default:extract(epoch from current_timestamp)::bigint"` diff --git a/services/tms/internal/core/domain/tenant/agentcontrol.go b/services/tms/internal/core/domain/tenant/agentcontrol.go index a1a057390..4cf70a667 100644 --- a/services/tms/internal/core/domain/tenant/agentcontrol.go +++ b/services/tms/internal/core/domain/tenant/agentcontrol.go @@ -24,16 +24,16 @@ type AgentControl struct { OrganizationID pulid.ID `json:"organizationId" bun:"organization_id,type:VARCHAR(100),pk,notnull"` ShadowMode bool `json:"shadowMode" bun:"shadow_mode,type:BOOLEAN,notnull,default:true"` - BillingAgentEnabled bool `json:"billingAgentEnabled" bun:"billing_agent_enabled,type:BOOLEAN,notnull,default:false"` + BillingAgentEnabled bool `json:"billingAgentEnabled" bun:"billing_agent_enabled,type:BOOLEAN,notnull"` // DispatchAgentEnabled gates the auto-assign agent separately from the billing agent, // so enabling one never enables the other. - DispatchAgentEnabled bool `json:"dispatchAgentEnabled" bun:"dispatch_agent_enabled,type:BOOLEAN,notnull,default:false"` + DispatchAgentEnabled bool `json:"dispatchAgentEnabled" bun:"dispatch_agent_enabled,type:BOOLEAN,notnull"` // DispatchAutonomyTier is an agent.AutonomyTier. It is held as a string because the // agent domain already depends on this package, and importing it back would cycle. DispatchAutonomyTier string `json:"dispatchAutonomyTier" bun:"dispatch_autonomy_tier,type:agent_autonomy_tier_enum,notnull,default:'Propose'"` DecisionTimeoutSeconds int `json:"decisionTimeoutSeconds" bun:"decision_timeout_seconds,type:INTEGER,notnull,default:86400"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,notnull,default:extract(epoch from current_timestamp)::bigint"` diff --git a/services/tms/internal/core/domain/tenant/billingcontrol.go b/services/tms/internal/core/domain/tenant/billingcontrol.go index 3105c885c..e695edd1d 100644 --- a/services/tms/internal/core/domain/tenant/billingcontrol.go +++ b/services/tms/internal/core/domain/tenant/billingcontrol.go @@ -36,7 +36,7 @@ type BillingControl struct { InvoiceDraftCreationMode InvoiceDraftCreationMode `json:"invoiceDraftCreationMode" bun:"invoice_draft_creation_mode,type:invoice_draft_creation_mode_enum,notnull,default:'ManualOnly'"` InvoicePostingMode InvoicePostingMode `json:"invoicePostingMode" bun:"invoice_posting_mode,type:invoice_posting_mode_enum,notnull,default:'ManualReviewRequired'"` AutoInvoiceBatchSize int `json:"autoInvoiceBatchSize" bun:"auto_invoice_batch_size,type:INTEGER,nullzero"` - NotifyOnAutoInvoiceCreation bool `json:"notifyOnAutoInvoiceCreation" bun:"notify_on_auto_invoice_creation,type:BOOLEAN,notnull,default:false"` + NotifyOnAutoInvoiceCreation bool `json:"notifyOnAutoInvoiceCreation" bun:"notify_on_auto_invoice_creation,type:BOOLEAN,notnull"` ShipmentBillingRequirementEnforcement EnforcementLevel `json:"shipmentBillingRequirementEnforcement" bun:"shipment_billing_requirement_enforcement,type:enforcement_level_enum,notnull,default:'Block'"` RateValidationEnforcement EnforcementLevel `json:"rateValidationEnforcement" bun:"rate_validation_enforcement,type:enforcement_level_enum,notnull,default:'RequireReview'"` BillingExceptionDisposition BillingExceptionDisposition `json:"billingExceptionDisposition" bun:"billing_exception_disposition,type:billing_exception_disposition_enum,notnull,default:'RouteToBillingReview'"` @@ -44,7 +44,7 @@ type BillingControl struct { RateVarianceTolerancePercent decimal.Decimal `json:"rateVarianceTolerancePercent" bun:"rate_variance_tolerance_percent,type:NUMERIC(9,6),notnull,default:0.000000"` RateVarianceAutoResolutionMode RateVarianceAutoResolutionMode `json:"rateVarianceAutoResolutionMode" bun:"rate_variance_auto_resolution_mode,type:rate_variance_auto_resolution_mode_enum,notnull,default:'Disabled'"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,notnull,default:extract(epoch from current_timestamp)::bigint"` diff --git a/services/tms/internal/core/domain/tenant/businessunit.go b/services/tms/internal/core/domain/tenant/businessunit.go index 6be6af29e..c5e0e73bd 100644 --- a/services/tms/internal/core/domain/tenant/businessunit.go +++ b/services/tms/internal/core/domain/tenant/businessunit.go @@ -19,7 +19,7 @@ type BusinessUnit struct { ID pulid.ID `json:"id" bun:"id,pk,type:VARCHAR(100)"` Name string `json:"name" bun:"name,type:VARCHAR(100),notnull"` Code string `json:"code" bun:"code,type:VARCHAR(10),notnull"` - Metadata map[string]any `json:"-" bun:"metadata,type:JSONB,default:'{}'::jsonb"` + Metadata map[string]any `json:"-" bun:"metadata,type:JSONB,default:'{}'"` Version int64 `json:"version" bun:"version,type:BIGINT"` CreatedAt int64 `json:"createdAt" bun:"created_at,nullzero,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,nullzero,notnull,default:extract(epoch from current_timestamp)::bigint"` diff --git a/services/tms/internal/core/domain/tenant/dashcontrol.go b/services/tms/internal/core/domain/tenant/dashcontrol.go index 379a37620..e08520042 100644 --- a/services/tms/internal/core/domain/tenant/dashcontrol.go +++ b/services/tms/internal/core/domain/tenant/dashcontrol.go @@ -36,7 +36,7 @@ type DashControl struct { ShowLoadPay bool `json:"showLoadPay" bun:"show_load_pay,type:BOOLEAN,notnull,default:true"` ShowPayEstimates bool `json:"showPayEstimates" bun:"show_pay_estimates,type:BOOLEAN,notnull,default:true"` AllowExpenseSubmission bool `json:"allowExpenseSubmission" bun:"allow_expense_submission,type:BOOLEAN,notnull,default:true"` - RequireExpenseReceipt bool `json:"requireExpenseReceipt" bun:"require_expense_receipt,type:BOOLEAN,notnull,default:false"` + RequireExpenseReceipt bool `json:"requireExpenseReceipt" bun:"require_expense_receipt,type:BOOLEAN,notnull"` AllowSettlementDisputes bool `json:"allowSettlementDisputes" bun:"allow_settlement_disputes,type:BOOLEAN,notnull,default:true"` AllowProfileDocumentUpload bool `json:"allowProfileDocumentUpload" bun:"allow_profile_document_upload,type:BOOLEAN,notnull,default:true"` AllowContactInfoEdit bool `json:"allowContactInfoEdit" bun:"allow_contact_info_edit,type:BOOLEAN,notnull,default:true"` @@ -46,7 +46,7 @@ type DashControl struct { EnableDetentionAlerts bool `json:"enableDetentionAlerts" bun:"enable_detention_alerts,type:BOOLEAN,notnull,default:true"` DetentionAlertThresholdMinutes int16 `json:"detentionAlertThresholdMinutes" bun:"detention_alert_threshold_minutes,type:INTEGER,notnull,default:120"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,notnull,default:extract(epoch from current_timestamp)::bigint"` diff --git a/services/tms/internal/core/domain/tenant/dataretention.go b/services/tms/internal/core/domain/tenant/dataretention.go index a97501530..4e1ac5e5a 100644 --- a/services/tms/internal/core/domain/tenant/dataretention.go +++ b/services/tms/internal/core/domain/tenant/dataretention.go @@ -22,9 +22,9 @@ type DataRetention struct { ID pulid.ID `json:"id" bun:"id,type:VARCHAR(100),pk,notnull"` BusinessUnitID pulid.ID `json:"businessUnitId" bun:"business_unit_id,type:VARCHAR(100),pk,notnull"` OrganizationID pulid.ID `json:"organizationId" bun:"organization_id,type:VARCHAR(100),pk,notnull"` - AuditRetentionPeriod int `json:"auditRetentionPeriod" bun:"audit_retention_period,type:INTEGER,notnull,default:120"` // In days - EDIInboundFileRetentionPeriod int `json:"ediInboundFileRetentionPeriod" bun:"edi_inbound_file_retention_period,type:INTEGER,notnull,default:0"` // In days, 0 disables purging - EDIMessageRetentionPeriod int `json:"ediMessageRetentionPeriod" bun:"edi_message_retention_period,type:INTEGER,notnull,default:0"` // In days, 0 disables purging + AuditRetentionPeriod int `json:"auditRetentionPeriod" bun:"audit_retention_period,type:INTEGER,notnull,default:120"` // In days + EDIInboundFileRetentionPeriod int `json:"ediInboundFileRetentionPeriod" bun:"edi_inbound_file_retention_period,type:INTEGER,notnull"` // In days, 0 disables purging + EDIMessageRetentionPeriod int `json:"ediMessageRetentionPeriod" bun:"edi_message_retention_period,type:INTEGER,notnull"` // In days, 0 disables purging Version int64 `json:"version" bun:"version,type:BIGINT"` CreatedAt int64 `json:"createdAt" bun:"created_at,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,notnull,default:extract(epoch from current_timestamp)::bigint"` diff --git a/services/tms/internal/core/domain/tenant/documentcontrol.go b/services/tms/internal/core/domain/tenant/documentcontrol.go index 7bf9d59bc..e5289e8e0 100644 --- a/services/tms/internal/core/domain/tenant/documentcontrol.go +++ b/services/tms/internal/core/domain/tenant/documentcontrol.go @@ -31,8 +31,8 @@ type DocumentControl struct { EnableAutoDocumentTypeAssociate bool `json:"enableAutoDocumentTypeAssociate" bun:"enable_auto_document_type_associate,type:BOOLEAN,notnull,default:true"` EnableAutoCreateDocumentTypes bool `json:"enableAutoCreateDocumentTypes" bun:"enable_auto_create_document_types,type:BOOLEAN,notnull,default:true"` EnableShipmentDraftExtraction bool `json:"enableShipmentDraftExtraction" bun:"enable_shipment_draft_extraction,type:BOOLEAN,notnull,default:true"` - EnableAIAssistedClassification bool `json:"enableAiAssistedClassification" bun:"enable_ai_assisted_classification,type:BOOLEAN,notnull,default:false"` - EnableAIAssistedExtraction bool `json:"enableAiAssistedExtraction" bun:"enable_ai_assisted_extraction,type:BOOLEAN,notnull,default:false"` + EnableAIAssistedClassification bool `json:"enableAiAssistedClassification" bun:"enable_ai_assisted_classification,type:BOOLEAN,notnull"` + EnableAIAssistedExtraction bool `json:"enableAiAssistedExtraction" bun:"enable_ai_assisted_extraction,type:BOOLEAN,notnull"` ShipmentDraftAllowedResources []string `json:"shipmentDraftAllowedResources" bun:"shipment_draft_allowed_resources,type:VARCHAR(100)[],notnull,default:'{}'"` EnableFullTextIndexing bool `json:"enableFullTextIndexing" bun:"enable_full_text_indexing,type:BOOLEAN,notnull,default:true"` Version int64 `json:"version" bun:"version,type:BIGINT"` diff --git a/services/tms/internal/core/domain/tenant/invoiceadjustmentcontrol.go b/services/tms/internal/core/domain/tenant/invoiceadjustmentcontrol.go index a0083d643..d366bca26 100644 --- a/services/tms/internal/core/domain/tenant/invoiceadjustmentcontrol.go +++ b/services/tms/internal/core/domain/tenant/invoiceadjustmentcontrol.go @@ -46,7 +46,7 @@ type InvoiceAdjustmentControl struct { OverCreditPolicy OverCreditPolicy `json:"overCreditPolicy" bun:"over_credit_policy,type:over_credit_policy_enum,notnull,default:'Block'"` SupersededInvoiceVisibilityPolicy SupersededInvoiceVisibilityPolicy `json:"supersededInvoiceVisibilityPolicy" bun:"superseded_invoice_visibility_policy,type:superseded_invoice_visibility_policy_enum,notnull,default:'ShowCurrentOnlyExternally'"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,notnull,default:extract(epoch from current_timestamp)::bigint"` diff --git a/services/tms/internal/core/domain/tenant/settlementcontrol.go b/services/tms/internal/core/domain/tenant/settlementcontrol.go index be745f338..fbf0d7a2e 100644 --- a/services/tms/internal/core/domain/tenant/settlementcontrol.go +++ b/services/tms/internal/core/domain/tenant/settlementcontrol.go @@ -68,17 +68,17 @@ type SettlementControl struct { PeriodEndDayOfWeek int `json:"periodEndDayOfWeek" bun:"period_end_day_of_week,type:INTEGER,notnull,default:6"` PayDelayDays int `json:"payDelayDays" bun:"pay_delay_days,type:INTEGER,notnull,default:5"` PayTrigger PayTrigger `json:"payTrigger" bun:"pay_trigger,type:VARCHAR(50),notnull,default:'ShipmentDelivered'"` - AutoGenerateBatches bool `json:"autoGenerateBatches" bun:"auto_generate_batches,type:BOOLEAN,notnull,default:false"` - AutoApproveClean bool `json:"autoApproveClean" bun:"auto_approve_clean,type:BOOLEAN,notnull,default:false"` + AutoGenerateBatches bool `json:"autoGenerateBatches" bun:"auto_generate_batches,type:BOOLEAN,notnull"` + AutoApproveClean bool `json:"autoApproveClean" bun:"auto_approve_clean,type:BOOLEAN,notnull"` AutoAttachAccruals bool `json:"autoAttachAccruals" bun:"auto_attach_accruals,type:BOOLEAN,notnull,default:true"` - AutoPostOnApprove bool `json:"autoPostOnApprove" bun:"auto_post_on_approve,type:BOOLEAN,notnull,default:false"` + AutoPostOnApprove bool `json:"autoPostOnApprove" bun:"auto_post_on_approve,type:BOOLEAN,notnull"` AllowNegativeNet bool `json:"allowNegativeNet" bun:"allow_negative_net,type:BOOLEAN,notnull,default:true"` VarianceThresholdPct decimal.Decimal `json:"varianceThresholdPct" bun:"variance_threshold_pct,type:NUMERIC(7,4),notnull,default:25"` VarianceLookbackWeeks int `json:"varianceLookbackWeeks" bun:"variance_lookback_weeks,type:INTEGER,notnull,default:8"` DefaultEscrowInterestRate decimal.Decimal `json:"defaultEscrowInterestRate" bun:"default_escrow_interest_rate,type:NUMERIC(7,4),notnull,default:0"` EscrowInterestFrequencyMonths int `json:"escrowInterestFrequencyMonths" bun:"escrow_interest_frequency_months,type:INTEGER,notnull,default:3"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,notnull,default:extract(epoch from current_timestamp)::bigint"` diff --git a/services/tms/internal/core/domain/tenant/shipmentcontrol.go b/services/tms/internal/core/domain/tenant/shipmentcontrol.go index e56554645..368a0d9e1 100644 --- a/services/tms/internal/core/domain/tenant/shipmentcontrol.go +++ b/services/tms/internal/core/domain/tenant/shipmentcontrol.go @@ -27,13 +27,13 @@ type ShipmentControl struct { AutoDelayShipmentsThreshold *int16 `json:"autoDelayShipmentsThreshold" bun:"auto_delay_shipments_threshold,type:INTEGER,default:30,nullzero"` // In minutes DetentionThreshold *int16 `json:"detentionThreshold" bun:"detention_threshold,type:INTEGER,default:30,nullzero"` // In minutes AutoCancelShipmentsThreshold *int8 `json:"autoCancelShipmentsThreshold" bun:"auto_cancel_shipments_threshold,type:auto_cancel_shipments_threshold,notnull,default:30"` // In days - AutoCancelShipments bool `json:"autoCancelShipments" bun:"auto_cancel_shipments,type:BOOLEAN,notnull,default:false"` - TrackDetentionTime bool `json:"trackDetentionTime" bun:"track_detention_time,type:BOOLEAN,notnull,default:false"` - AutoGenerateDetentionCharges bool `json:"autoGenerateDetentionCharges" bun:"auto_generate_detention_charges,type:BOOLEAN,notnull,default:false"` + AutoCancelShipments bool `json:"autoCancelShipments" bun:"auto_cancel_shipments,type:BOOLEAN,notnull"` + TrackDetentionTime bool `json:"trackDetentionTime" bun:"track_detention_time,type:BOOLEAN,notnull"` + AutoGenerateDetentionCharges bool `json:"autoGenerateDetentionCharges" bun:"auto_generate_detention_charges,type:BOOLEAN,notnull"` DetentionChargeID *pulid.ID `json:"detentionChargeId" bun:"detention_charge_id,type:VARCHAR(100),nullzero"` - UseDetentionPolicyEngine bool `json:"useDetentionPolicyEngine" bun:"use_detention_policy_engine,type:BOOLEAN,notnull,default:false"` + UseDetentionPolicyEngine bool `json:"useDetentionPolicyEngine" bun:"use_detention_policy_engine,type:BOOLEAN,notnull"` DefaultDetentionPolicyID *pulid.ID `json:"defaultDetentionPolicyId" bun:"default_detention_policy_id,type:VARCHAR(100),nullzero"` - TrackCustomerRejections bool `json:"trackCustomerRejections" bun:"track_customer_rejections,type:BOOLEAN,notnull,default:false"` + TrackCustomerRejections bool `json:"trackCustomerRejections" bun:"track_customer_rejections,type:BOOLEAN,notnull"` CheckForDuplicateBOLs bool `json:"checkForDuplicateBols" bun:"check_for_duplicate_bols,type:BOOLEAN,notnull,default:true"` AllowMoveRemovals bool `json:"allowMoveRemovals" bun:"allow_move_removals,type:BOOLEAN,notnull,default:true"` CheckHazmatSegregation bool `json:"checkHazmatSegregation" bun:"check_hazmat_segregation,type:BOOLEAN,notnull,default:true"` diff --git a/services/tms/internal/core/domain/tenant/user.go b/services/tms/internal/core/domain/tenant/user.go index 24c2be930..940a7f210 100644 --- a/services/tms/internal/core/domain/tenant/user.go +++ b/services/tms/internal/core/domain/tenant/user.go @@ -23,7 +23,7 @@ type OrganizationMembership struct { bun.BaseModel `bun:"table:user_organization_memberships,alias:uom" json:"-"` ID pulid.ID `json:"id" bun:"id,pk,type:VARCHAR(100)"` - IsDefault bool `json:"isDefault" bun:"is_default,default:false"` + IsDefault bool `json:"isDefault" bun:"is_default"` BusinessUnitID pulid.ID `json:"businessUnitId" bun:"business_unit_id,type:VARCHAR(100),notnull"` UserID pulid.ID `json:"userId" bun:"user_id,type:VARCHAR(100),notnull"` OrganizationID pulid.ID `json:"organizationId" bun:"organization_id,type:VARCHAR(100),notnull"` @@ -74,9 +74,9 @@ type User struct { ProfilePicURL string `json:"profilePicUrl" bun:"profile_pic_url,type:VARCHAR(255)"` ThumbnailURL string `json:"thumbnailUrl" bun:"thumbnail_url,type:VARCHAR(255)"` Timezone string `json:"timezone" bun:"timezone,type:VARCHAR(50),notnull"` - IsLocked bool `json:"isLocked" bun:"is_locked,type:BOOLEAN,notnull,default:false"` - MustChangePassword bool `json:"mustChangePassword" bun:"must_change_password,type:BOOLEAN,notnull,default:false"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + IsLocked bool `json:"isLocked" bun:"is_locked,type:BOOLEAN,notnull"` + MustChangePassword bool `json:"mustChangePassword" bun:"must_change_password,type:BOOLEAN,notnull"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,notnull,default:extract(epoch from current_timestamp)::bigint"` LastLoginAt *int64 `json:"lastLoginAt,omitzero" bun:"last_login_at,nullzero"` diff --git a/services/tms/internal/core/domain/weatheralert/weatheralert.go b/services/tms/internal/core/domain/weatheralert/weatheralert.go index b808ea882..b804506ff 100644 --- a/services/tms/internal/core/domain/weatheralert/weatheralert.go +++ b/services/tms/internal/core/domain/weatheralert/weatheralert.go @@ -41,7 +41,7 @@ type WeatherAlert struct { FirstSeenAt int64 `json:"firstSeenAt" bun:"first_seen_at,type:BIGINT,notnull"` LastUpdatedAt int64 `json:"lastUpdatedAt" bun:"last_updated_at,type:BIGINT,notnull"` ExpiredAt *int64 `json:"expiredAt" bun:"expired_at,type:BIGINT,nullzero"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` } diff --git a/services/tms/internal/core/domain/worker/portalinvitation.go b/services/tms/internal/core/domain/worker/portalinvitation.go index ef7a71f24..0e46f1c65 100644 --- a/services/tms/internal/core/domain/worker/portalinvitation.go +++ b/services/tms/internal/core/domain/worker/portalinvitation.go @@ -55,7 +55,7 @@ type PortalInvitation struct { InvitedByID pulid.ID `json:"invitedById" bun:"invited_by_id,type:VARCHAR(100),notnull"` AcceptedAt *int64 `json:"acceptedAt" bun:"accepted_at,type:BIGINT,nullzero"` AcceptedUserID *pulid.ID `json:"acceptedUserId" bun:"accepted_user_id,type:VARCHAR(100),nullzero"` - Version int64 `json:"version" bun:"version,type:BIGINT,notnull,default:0"` + Version int64 `json:"version" bun:"version,type:BIGINT,notnull"` CreatedAt int64 `json:"createdAt" bun:"created_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,type:BIGINT,notnull,default:extract(epoch from current_timestamp)::bigint"` diff --git a/services/tms/internal/core/domain/worker/worker.go b/services/tms/internal/core/domain/worker/worker.go index fcd1634d8..51e0aeee4 100644 --- a/services/tms/internal/core/domain/worker/worker.go +++ b/services/tms/internal/core/domain/worker/worker.go @@ -62,7 +62,7 @@ type Worker struct { Rank string `json:"-" bun:"rank,type:VARCHAR(100),scanonly"` AssignmentBlocked string `json:"assignmentBlocked,omitempty" bun:"assignment_blocked,type:VARCHAR(255),nullzero"` Gender Gender `json:"gender" bun:"gender,type:gender_enum,notnull"` - CanBeAssigned bool `json:"canBeAssigned" bun:"can_be_assigned,type:BOOLEAN,notnull,default:false"` + CanBeAssigned bool `json:"canBeAssigned" bun:"can_be_assigned,type:BOOLEAN,notnull"` AvailableForDispatch bool `json:"availableForDispatch" bun:"available_for_dispatch,type:BOOLEAN,notnull,default:true"` Version int64 `json:"version" bun:"version,type:BIGINT"` CreatedAt int64 `json:"createdAt" bun:"created_at,notnull,default:extract(epoch from current_timestamp)::bigint"` diff --git a/services/tms/internal/core/domain/worker/workerprofile.go b/services/tms/internal/core/domain/worker/workerprofile.go index f55ebc07c..929e33a6f 100644 --- a/services/tms/internal/core/domain/worker/workerprofile.go +++ b/services/tms/internal/core/domain/worker/workerprofile.go @@ -39,13 +39,13 @@ type WorkerProfile struct { PhysicalDueDate *int64 `json:"physicalDueDate" bun:"physical_due_date,type:BIGINT,nullzero"` MVRDueDate *int64 `json:"mvrDueDate" bun:"mvr_due_date,type:BIGINT,nullzero"` ComplianceStatus ComplianceStatus `json:"complianceStatus" bun:"compliance_status,type:compliance_status_enum,notnull,default:'Pending'"` - IsQualified bool `json:"isQualified" bun:"is_qualified,type:BOOLEAN,notnull,default:false"` + IsQualified bool `json:"isQualified" bun:"is_qualified,type:BOOLEAN,notnull"` DisqualificationReason string `json:"disqualificationReason" bun:"disqualification_reason,type:VARCHAR(255),nullzero"` - LastComplianceCheck int64 `json:"lastComplianceCheck" bun:"last_compliance_check,type:BIGINT,notnull,default:0"` - LastMVRCheck int64 `json:"lastMvrCheck" bun:"last_mvr_check,type:BIGINT,notnull,default:0"` - LastDrugTest int64 `json:"lastDrugTest" bun:"last_drug_test,type:BIGINT,notnull,default:0"` - ELDExempt bool `json:"eldExempt" bun:"eld_exempt,type:BOOLEAN,notnull,default:false"` - ShortHaulExempt bool `json:"shortHaulExempt" bun:"short_haul_exempt,type:BOOLEAN,notnull,default:false"` + LastComplianceCheck int64 `json:"lastComplianceCheck" bun:"last_compliance_check,type:BIGINT,notnull"` + LastMVRCheck int64 `json:"lastMvrCheck" bun:"last_mvr_check,type:BIGINT,notnull"` + LastDrugTest int64 `json:"lastDrugTest" bun:"last_drug_test,type:BIGINT,notnull"` + ELDExempt bool `json:"eldExempt" bun:"eld_exempt,type:BOOLEAN,notnull"` + ShortHaulExempt bool `json:"shortHaulExempt" bun:"short_haul_exempt,type:BOOLEAN,notnull"` Version int64 `json:"version" bun:"version,type:BIGINT"` CreatedAt int64 `json:"createdAt" bun:"created_at,notnull,default:extract(epoch from current_timestamp)::bigint"` UpdatedAt int64 `json:"updatedAt" bun:"updated_at,notnull,default:extract(epoch from current_timestamp)::bigint"` diff --git a/services/tms/internal/infrastructure/database/seeder/rollback_tracker.go b/services/tms/internal/infrastructure/database/seeder/rollback_tracker.go index 07ed7bb78..982f42aad 100644 --- a/services/tms/internal/infrastructure/database/seeder/rollback_tracker.go +++ b/services/tms/internal/infrastructure/database/seeder/rollback_tracker.go @@ -6,6 +6,7 @@ import ( "time" "github.com/emoss08/trenova/internal/infrastructure/database/common" + "github.com/emoss08/trenova/pkg/dbdialect" "github.com/uptrace/bun" ) @@ -18,22 +19,15 @@ func NewRollbackTracker(db *bun.DB) *RollbackTracker { } func (rt *RollbackTracker) Initialize(ctx context.Context) error { - query := ` - CREATE TABLE IF NOT EXISTS seed_rollbacks ( - id SERIAL PRIMARY KEY, - seed_name VARCHAR(255) NOT NULL, - seed_version VARCHAR(50) NOT NULL, - environment VARCHAR(50) NOT NULL, - rolled_back_at TIMESTAMP NOT NULL DEFAULT NOW(), - entities_deleted INT NOT NULL DEFAULT 0, - duration_ms BIGINT NOT NULL DEFAULT 0, - error_message TEXT - ) - ` - - _, err := rt.db.ExecContext(ctx, query) + statements, err := loadSchema(dbdialect.FromBun(rt.db), seedRollbacksSchema) if err != nil { - return fmt.Errorf("create seed_rollbacks table: %w", err) + return err + } + + for _, statement := range statements { + if _, execErr := rt.db.ExecContext(ctx, statement); execErr != nil { + return fmt.Errorf("create seed_rollbacks table: %w", execErr) + } } return nil diff --git a/services/tms/internal/infrastructure/database/seeder/schema.go b/services/tms/internal/infrastructure/database/seeder/schema.go new file mode 100644 index 000000000..e0ef65200 --- /dev/null +++ b/services/tms/internal/infrastructure/database/seeder/schema.go @@ -0,0 +1,54 @@ +package seeder + +import ( + "embed" + "fmt" + "strings" + + "github.com/emoss08/trenova/pkg/dbdialect" +) + +// The seed bookkeeping tables are created by the seeder rather than by a +// migration, so their DDL lives here rather than in the migration corpus. It is +// kept in .sql files per dialect so the SQL stays reviewable and diffable +// instead of being buried in Go string literals. +// +//go:embed schema/*/*.sql +var schemaFS embed.FS + +const schemaSplitMarker = "--bun:split" + +const ( + seedHistorySchema = "seed_history" + seedRollbacksSchema = "seed_rollbacks" +) + +// loadSchema returns the DDL statements for a bookkeeping table in the given +// dialect. Statements are returned individually because SQLite drivers execute +// one statement per call, and because a failure can then name what broke. +func loadSchema(kind dbdialect.Kind, name string) ([]string, error) { + path := fmt.Sprintf("schema/%s/%s.sql", kind, name) + + contents, err := schemaFS.ReadFile(path) + if err != nil { + return nil, fmt.Errorf("failed to read embedded schema %q: %w", path, err) + } + + rawStatements := strings.Split(string(contents), schemaSplitMarker) + statements := make([]string, 0, len(rawStatements)) + + for _, statement := range rawStatements { + trimmed := strings.TrimSpace(statement) + if trimmed == "" { + continue + } + + statements = append(statements, trimmed) + } + + if len(statements) == 0 { + return nil, fmt.Errorf("embedded schema %q contains no statements", path) + } + + return statements, nil +} diff --git a/services/tms/internal/infrastructure/database/seeder/schema/postgres/seed_history.sql b/services/tms/internal/infrastructure/database/seeder/schema/postgres/seed_history.sql new file mode 100644 index 000000000..7fa2e8e8e --- /dev/null +++ b/services/tms/internal/infrastructure/database/seeder/schema/postgres/seed_history.sql @@ -0,0 +1,35 @@ +DO $$ +BEGIN + IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'seed_status_enum') THEN + CREATE TYPE seed_status_enum AS ENUM ('Active', 'Inactive', 'Orphaned'); + END IF; +END $$; + +--bun:split +CREATE TABLE IF NOT EXISTS seed_history ( + id VARCHAR(100) PRIMARY KEY, + name VARCHAR(255) NOT NULL, + version VARCHAR(50) NOT NULL, + environment VARCHAR(50) NOT NULL, + checksum VARCHAR(32) NOT NULL, + applied_at BIGINT NOT NULL, + applied_by VARCHAR(255) NOT NULL, + status seed_status_enum NOT NULL DEFAULT 'Active', + details JSONB, + error TEXT, + notes TEXT, + duration_ms BIGINT, + UNIQUE (name, version, environment) +); + +--bun:split +CREATE INDEX IF NOT EXISTS idx_seed_history_name ON seed_history(name); + +--bun:split +CREATE INDEX IF NOT EXISTS idx_seed_history_environment ON seed_history(environment); + +--bun:split +CREATE INDEX IF NOT EXISTS idx_seed_history_applied_at ON seed_history(applied_at); + +--bun:split +CREATE INDEX IF NOT EXISTS idx_seed_history_status ON seed_history(status); diff --git a/services/tms/internal/infrastructure/database/seeder/schema/postgres/seed_rollbacks.sql b/services/tms/internal/infrastructure/database/seeder/schema/postgres/seed_rollbacks.sql new file mode 100644 index 000000000..270ebcc1c --- /dev/null +++ b/services/tms/internal/infrastructure/database/seeder/schema/postgres/seed_rollbacks.sql @@ -0,0 +1,10 @@ +CREATE TABLE IF NOT EXISTS seed_rollbacks ( + id SERIAL PRIMARY KEY, + seed_name VARCHAR(255) NOT NULL, + seed_version VARCHAR(50) NOT NULL, + environment VARCHAR(50) NOT NULL, + rolled_back_at TIMESTAMP NOT NULL DEFAULT NOW(), + entities_deleted INT NOT NULL DEFAULT 0, + duration_ms BIGINT NOT NULL DEFAULT 0, + error_message TEXT +); diff --git a/services/tms/internal/infrastructure/database/seeder/schema/sqlite/seed_history.sql b/services/tms/internal/infrastructure/database/seeder/schema/sqlite/seed_history.sql new file mode 100644 index 000000000..dc4a1922a --- /dev/null +++ b/services/tms/internal/infrastructure/database/seeder/schema/sqlite/seed_history.sql @@ -0,0 +1,30 @@ +-- SQLite has no enum type, so status is TEXT. It is deliberately left without a +-- CHECK constraint: SQLite cannot alter one, so a new SeedStatus value would +-- otherwise strand existing development databases. +CREATE TABLE IF NOT EXISTS seed_history ( + id VARCHAR(100) PRIMARY KEY, + name VARCHAR(255) NOT NULL, + version VARCHAR(50) NOT NULL, + environment VARCHAR(50) NOT NULL, + checksum VARCHAR(32) NOT NULL, + applied_at BIGINT NOT NULL, + applied_by VARCHAR(255) NOT NULL, + status TEXT NOT NULL DEFAULT 'Active', + details TEXT, + error TEXT, + notes TEXT, + duration_ms BIGINT, + UNIQUE (name, version, environment) +); + +--bun:split +CREATE INDEX IF NOT EXISTS idx_seed_history_name ON seed_history(name); + +--bun:split +CREATE INDEX IF NOT EXISTS idx_seed_history_environment ON seed_history(environment); + +--bun:split +CREATE INDEX IF NOT EXISTS idx_seed_history_applied_at ON seed_history(applied_at); + +--bun:split +CREATE INDEX IF NOT EXISTS idx_seed_history_status ON seed_history(status); diff --git a/services/tms/internal/infrastructure/database/seeder/schema/sqlite/seed_rollbacks.sql b/services/tms/internal/infrastructure/database/seeder/schema/sqlite/seed_rollbacks.sql new file mode 100644 index 000000000..efb38dce4 --- /dev/null +++ b/services/tms/internal/infrastructure/database/seeder/schema/sqlite/seed_rollbacks.sql @@ -0,0 +1,10 @@ +CREATE TABLE IF NOT EXISTS seed_rollbacks ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + seed_name VARCHAR(255) NOT NULL, + seed_version VARCHAR(50) NOT NULL, + environment VARCHAR(50) NOT NULL, + rolled_back_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + entities_deleted INT NOT NULL DEFAULT 0, + duration_ms BIGINT NOT NULL DEFAULT 0, + error_message TEXT +); diff --git a/services/tms/internal/infrastructure/database/seeder/seedrun_sqlite_test.go b/services/tms/internal/infrastructure/database/seeder/seedrun_sqlite_test.go new file mode 100644 index 000000000..044b4502a --- /dev/null +++ b/services/tms/internal/infrastructure/database/seeder/seedrun_sqlite_test.go @@ -0,0 +1,60 @@ +package seeder_test + +import ( + "database/sql" + "path/filepath" + "testing" + + "github.com/emoss08/trenova/internal/infrastructure/config" + "github.com/emoss08/trenova/internal/infrastructure/database/seeder" + "github.com/emoss08/trenova/internal/infrastructure/database/seeds" + sqlitemigrations "github.com/emoss08/trenova/internal/infrastructure/sqlite/migrations" + "github.com/emoss08/trenova/pkg/domainregistry" + "github.com/stretchr/testify/require" + "github.com/uptrace/bun" + "github.com/uptrace/bun/dialect/sqlitedialect" + "github.com/uptrace/bun/migrate" + + _ "modernc.org/sqlite" +) + +// Migrating and then seeding a throwaway SQLite database is the only thing that +// catches dialect problems in the seeds themselves, as opposed to the schema. +func TestFullSeedRunOnSQLite(t *testing.T) { + ctx := t.Context() + path := filepath.Join(t.TempDir(), "seedrun.db") + + // Seeds resolve their YAML data files relative to the module root. + t.Chdir("../../../..") + + sqldb, err := sql.Open("sqlite", "file:"+path+"?_pragma=foreign_keys(0)&_txlock=immediate") + require.NoError(t, err) + + db := bun.NewDB(sqldb, sqlitedialect.New()) + t.Cleanup(func() { _ = db.Close() }) + + db.RegisterModel(domainregistry.RegisterManyToManyEntities()...) + db.RegisterModel(domainregistry.RegisterEntities()...) + + migrator := migrate.NewMigrator(db, sqlitemigrations.Migrations) + require.NoError(t, migrator.Init(ctx)) + _, err = migrator.Migrate(ctx) + require.NoError(t, err) + + cfg := &config.Config{} + cfg.Database.Driver = "sqlite" + cfg.App.Env = "development" + cfg.System.SystemUserPassword = "seed-test-password" + + registry := seeder.NewRegistry() + seeds.Register(registry) + + tracker := seeder.NewTracker(db) + require.NoError(t, tracker.Initialize(ctx)) + + engine := seeder.NewEngine(db, registry, cfg) + engine.SetTracker(tracker) + + _, err = engine.Execute(ctx, seeder.ExecuteOptions{Environment: "development"}) + require.NoError(t, err) +} diff --git a/services/tms/internal/infrastructure/database/seeder/sqlite_test.go b/services/tms/internal/infrastructure/database/seeder/sqlite_test.go new file mode 100644 index 000000000..ad32dd618 --- /dev/null +++ b/services/tms/internal/infrastructure/database/seeder/sqlite_test.go @@ -0,0 +1,177 @@ +package seeder + +import ( + "context" + "database/sql" + "errors" + "path/filepath" + "testing" + "time" + + "github.com/emoss08/trenova/internal/infrastructure/database/common" + "github.com/emoss08/trenova/pkg/dbdialect" + "github.com/stretchr/testify/require" + "github.com/uptrace/bun" + "github.com/uptrace/bun/dialect/sqlitedialect" + + _ "modernc.org/sqlite" +) + +type stubSeed struct { + name string + version string +} + +func (s *stubSeed) Name() string { return s.name } +func (s *stubSeed) Version() string { return s.version } +func (s *stubSeed) Description() string { return "stub seed" } +func (s *stubSeed) Dependencies() []string { return nil } +func (s *stubSeed) Environments() []common.Environment { return nil } +func (s *stubSeed) Run(context.Context, bun.Tx) error { return nil } +func (s *stubSeed) Down(context.Context, bun.Tx) error { return nil } +func (s *stubSeed) CanRollback() bool { return true } + +func TestTrackerInitializeOnSQLite(t *testing.T) { + ctx := t.Context() + db := newSQLiteDB(t) + + tracker := NewTracker(db) + require.NoError(t, tracker.Initialize(ctx), "seed tracking DDL must be valid SQLite") + + require.NoError(t, tracker.Initialize(ctx), "Initialize must be idempotent") + + requireTableExists(t, db, "seed_history") +} + +func TestTrackerRecordsAndReadsOnSQLite(t *testing.T) { + ctx := t.Context() + db := newSQLiteDB(t) + + tracker := NewTracker(db) + require.NoError(t, tracker.Initialize(ctx)) + + seed := &stubSeed{name: "TestSeed", version: "1.0.0"} + env := common.EnvDevelopment + + applied, err := tracker.IsApplied(ctx, seed, env) + require.NoError(t, err) + require.False(t, applied) + + require.NoError(t, tracker.RecordSuccess(ctx, seed, env, 25*time.Millisecond)) + + applied, err = tracker.IsApplied(ctx, seed, env) + require.NoError(t, err) + require.True(t, applied, "a recorded seed must read back as applied") + + require.NoError( + t, + tracker.RecordSuccess(ctx, seed, env, 30*time.Millisecond), + "re-recording must upsert rather than violate the unique constraint", + ) + + statuses, err := tracker.GetStatus(ctx) + require.NoError(t, err) + require.Len(t, statuses, 1) +} + +func TestTrackerRecordFailureKeepsAppliedSeedOnSQLite(t *testing.T) { + ctx := t.Context() + db := newSQLiteDB(t) + + tracker := NewTracker(db) + require.NoError(t, tracker.Initialize(ctx)) + + seed := &stubSeed{name: "TestSeed", version: "1.0.0"} + env := common.EnvDevelopment + + require.NoError(t, tracker.RecordSuccess(ctx, seed, env, time.Millisecond)) + require.NoError(t, tracker.RecordFailure(ctx, seed, env, errors.New("boom"))) + + applied, err := tracker.IsApplied(ctx, seed, env) + require.NoError(t, err) + require.True( + t, + applied, + "a failed re-run must not demote an already applied seed", + ) +} + +func TestTrackerRecordRollbackOnSQLite(t *testing.T) { + ctx := t.Context() + db := newSQLiteDB(t) + + tracker := NewTracker(db) + require.NoError(t, tracker.Initialize(ctx)) + + seed := &stubSeed{name: "TestSeed", version: "1.0.0"} + env := common.EnvDevelopment + + require.NoError(t, tracker.RecordSuccess(ctx, seed, env, time.Millisecond)) + require.NoError(t, tracker.RecordRollback(ctx, seed, env)) + + applied, err := tracker.IsApplied(ctx, seed, env) + require.NoError(t, err) + require.False(t, applied, "a rolled back seed must be re-appliable") +} + +func TestRollbackTrackerOnSQLite(t *testing.T) { + ctx := t.Context() + db := newSQLiteDB(t) + + tracker := NewRollbackTracker(db) + require.NoError(t, tracker.Initialize(ctx), "rollback DDL must be valid SQLite") + require.NoError(t, tracker.Initialize(ctx), "Initialize must be idempotent") + + requireTableExists(t, db, "seed_rollbacks") + + require.NoError(t, tracker.RecordSuccess( + ctx, "TestSeed", "1.0.0", common.EnvDevelopment, 3, time.Second, + )) + require.NoError(t, tracker.RecordFailure( + ctx, "TestSeed", "1.0.0", common.EnvDevelopment, "boom", + )) + + var count int + require.NoError(t, db.NewRaw("SELECT count(*) FROM seed_rollbacks").Scan(ctx, &count)) + require.Equal(t, 2, count) +} + +func TestEverySupportedDialectHasSchemaFiles(t *testing.T) { + for _, kind := range []dbdialect.Kind{dbdialect.Postgres, dbdialect.SQLite} { + for _, name := range []string{seedHistorySchema, seedRollbacksSchema} { + statements, err := loadSchema(kind, name) + require.NoErrorf(t, err, "%s is missing schema %q", kind, name) + require.NotEmptyf(t, statements, "%s schema %q is empty", kind, name) + } + } +} + +func TestLoadSchemaRejectsUnknownName(t *testing.T) { + _, err := loadSchema(dbdialect.SQLite, "not_a_table") + require.Error(t, err) +} + +func requireTableExists(t *testing.T, db *bun.DB, table string) { + t.Helper() + + var count int + require.NoError(t, db.NewRaw( + "SELECT count(*) FROM sqlite_master WHERE type = 'table' AND name = ?", table, + ).Scan(t.Context(), &count)) + + require.Equalf(t, 1, count, "expected table %q to exist", table) +} + +func newSQLiteDB(t *testing.T) *bun.DB { + t.Helper() + + path := filepath.Join(t.TempDir(), "seeder-test.db") + + sqldb, err := sql.Open("sqlite", "file:"+path+"?_txlock=immediate") + require.NoError(t, err) + + db := bun.NewDB(sqldb, sqlitedialect.New()) + t.Cleanup(func() { _ = db.Close() }) + + return db +} diff --git a/services/tms/internal/infrastructure/database/seeder/tracker.go b/services/tms/internal/infrastructure/database/seeder/tracker.go index 08ee2fe80..be4d86dac 100644 --- a/services/tms/internal/infrastructure/database/seeder/tracker.go +++ b/services/tms/internal/infrastructure/database/seeder/tracker.go @@ -7,6 +7,7 @@ import ( "time" "github.com/emoss08/trenova/internal/infrastructure/database/common" + "github.com/emoss08/trenova/pkg/dbdialect" "github.com/emoss08/trenova/shared/pulid" "github.com/emoss08/trenova/shared/timeutils" "github.com/uptrace/bun" @@ -60,39 +61,15 @@ func NewTracker(db *bun.DB) *Tracker { } func (t *Tracker) Initialize(ctx context.Context) error { - query := ` - DO $$ - BEGIN - IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'seed_status_enum') THEN - CREATE TYPE seed_status_enum AS ENUM ('Active', 'Inactive', 'Orphaned'); - END IF; - END $$; - - CREATE TABLE IF NOT EXISTS seed_history ( - id VARCHAR(100) PRIMARY KEY, - name VARCHAR(255) NOT NULL, - version VARCHAR(50) NOT NULL, - environment VARCHAR(50) NOT NULL, - checksum VARCHAR(32) NOT NULL, - applied_at BIGINT NOT NULL, - applied_by VARCHAR(255) NOT NULL, - status seed_status_enum NOT NULL DEFAULT 'Active', - details JSONB, - error TEXT, - notes TEXT, - duration_ms BIGINT, - UNIQUE(name, version, environment) - ); - - CREATE INDEX IF NOT EXISTS idx_seed_history_name ON seed_history(name); - CREATE INDEX IF NOT EXISTS idx_seed_history_environment ON seed_history(environment); - CREATE INDEX IF NOT EXISTS idx_seed_history_applied_at ON seed_history(applied_at); - CREATE INDEX IF NOT EXISTS idx_seed_history_status ON seed_history(status); - ` - - _, err := t.db.ExecContext(ctx, query) + statements, err := loadSchema(dbdialect.FromBun(t.db), seedHistorySchema) if err != nil { - return fmt.Errorf("failed to initialize seed tracking table: %w", err) + return err + } + + for _, statement := range statements { + if _, execErr := t.db.ExecContext(ctx, statement); execErr != nil { + return fmt.Errorf("failed to initialize seed tracking table: %w", execErr) + } } return nil diff --git a/services/tms/internal/infrastructure/sqlite/migrations/20241211015840_shipment.tx.up.sql b/services/tms/internal/infrastructure/sqlite/migrations/20241211015840_shipment.tx.up.sql index e86654392..a0ed44f82 100644 --- a/services/tms/internal/infrastructure/sqlite/migrations/20241211015840_shipment.tx.up.sql +++ b/services/tms/internal/infrastructure/sqlite/migrations/20241211015840_shipment.tx.up.sql @@ -15,9 +15,9 @@ CREATE TABLE IF NOT EXISTS "shipments"( "temperature_min" INTEGER, "temperature_max" INTEGER, "rating_unit" INTEGER NOT NULL DEFAULT 1 CHECK ("rating_unit" > 0), - "freight_charge_amount" NUMERIC NOT NULL DEFAULT 0 CHECK ("freight_charge_amount" >= 0), - "other_charge_amount" NUMERIC NOT NULL DEFAULT 0 CHECK ("other_charge_amount" >= 0), - "total_charge_amount" NUMERIC NOT NULL DEFAULT 0 CHECK ("total_charge_amount" >= 0), + "freight_charge_amount" REAL NOT NULL DEFAULT 0 CHECK ("freight_charge_amount" >= 0), + "other_charge_amount" REAL NOT NULL DEFAULT 0 CHECK ("other_charge_amount" >= 0), + "total_charge_amount" REAL NOT NULL DEFAULT 0 CHECK ("total_charge_amount" >= 0), "pieces" INTEGER, "weight" INTEGER, "canceled_by_id" TEXT, diff --git a/services/tms/internal/infrastructure/sqlite/migrations/20241223200800_fleet_code.tx.up.sql b/services/tms/internal/infrastructure/sqlite/migrations/20241223200800_fleet_code.tx.up.sql index c49305e62..df3ce4894 100644 --- a/services/tms/internal/infrastructure/sqlite/migrations/20241223200800_fleet_code.tx.up.sql +++ b/services/tms/internal/infrastructure/sqlite/migrations/20241223200800_fleet_code.tx.up.sql @@ -11,9 +11,9 @@ CREATE TABLE IF NOT EXISTS "fleet_codes"( "manager_id" TEXT NOT NULL, "status" TEXT NOT NULL DEFAULT 'Active', "description" TEXT, - "revenue_goal" NUMERIC, - "deadhead_goal" NUMERIC, - "mileage_goal" NUMERIC, + "revenue_goal" REAL, + "deadhead_goal" REAL, + "mileage_goal" REAL, "color" TEXT, "version" INTEGER NOT NULL DEFAULT 0, "created_at" INTEGER NOT NULL DEFAULT (unixepoch()), diff --git a/services/tms/internal/infrastructure/sqlite/migrations/20250105193652_document_quality.tx.up.sql b/services/tms/internal/infrastructure/sqlite/migrations/20250105193652_document_quality.tx.up.sql index 2d49f5dd0..b438f89e6 100644 --- a/services/tms/internal/infrastructure/sqlite/migrations/20250105193652_document_quality.tx.up.sql +++ b/services/tms/internal/infrastructure/sqlite/migrations/20250105193652_document_quality.tx.up.sql @@ -40,17 +40,17 @@ CREATE TABLE IF NOT EXISTS "document_quality_configs" ( "organization_id" TEXT NOT NULL, "is_active" INTEGER NOT NULL DEFAULT 1, "min_dpi" INTEGER NOT NULL DEFAULT 200, - "min_brightness" NUMERIC NOT NULL DEFAULT 40, - "max_brightness" NUMERIC NOT NULL DEFAULT 220, - "min_contrast" NUMERIC NOT NULL DEFAULT 40, - "min_sharpness" NUMERIC NOT NULL DEFAULT 50, + "min_brightness" REAL NOT NULL DEFAULT 40, + "max_brightness" REAL NOT NULL DEFAULT 220, + "min_contrast" REAL NOT NULL DEFAULT 40, + "min_sharpness" REAL NOT NULL DEFAULT 50, "min_word_count" INTEGER NOT NULL DEFAULT 50, - "min_text_density" NUMERIC NOT NULL DEFAULT 0.1, + "min_text_density" REAL NOT NULL DEFAULT 0.1, "model_id" TEXT NOT NULL, "allow_training" INTEGER NOT NULL DEFAULT 1, - "auto_reject_score" NUMERIC NOT NULL DEFAULT 0.2, - "manual_review_score" NUMERIC NOT NULL DEFAULT 0.4, - "min_confidence" NUMERIC NOT NULL DEFAULT 0.7, + "auto_reject_score" REAL NOT NULL DEFAULT 0.2, + "manual_review_score" REAL NOT NULL DEFAULT 0.4, + "min_confidence" REAL NOT NULL DEFAULT 0.7, "version" INTEGER NOT NULL DEFAULT 0, "created_at" INTEGER NOT NULL DEFAULT (unixepoch()), "updated_at" INTEGER NOT NULL DEFAULT (unixepoch()), @@ -87,10 +87,10 @@ CREATE TABLE IF NOT EXISTS "document_quality_feedback" ( "document_url" TEXT NOT NULL, "feedback_type" TEXT NOT NULL, "comment" TEXT, - "quality_score" NUMERIC NOT NULL, - "confidence_score" NUMERIC NOT NULL, - "sharpness" NUMERIC NOT NULL, - "text_density" NUMERIC NOT NULL, + "quality_score" REAL NOT NULL, + "confidence_score" REAL NOT NULL, + "sharpness" REAL NOT NULL, + "text_density" REAL NOT NULL, "word_count" INTEGER NOT NULL, "used_for_training" INTEGER NOT NULL DEFAULT 0, "trained_at" INTEGER, diff --git a/services/tms/internal/infrastructure/sqlite/migrations/20250118041547_commodity.tx.up.sql b/services/tms/internal/infrastructure/sqlite/migrations/20250118041547_commodity.tx.up.sql index dd46ed31c..b4029b0dc 100644 --- a/services/tms/internal/infrastructure/sqlite/migrations/20250118041547_commodity.tx.up.sql +++ b/services/tms/internal/infrastructure/sqlite/migrations/20250118041547_commodity.tx.up.sql @@ -13,9 +13,9 @@ CREATE TABLE IF NOT EXISTS "commodities"( "description" TEXT NOT NULL, "min_temperature" INTEGER, "max_temperature" INTEGER, - "max_quantity_per_shipment" NUMERIC, - "weight_per_unit" NUMERIC, - "linear_feet_per_unit" NUMERIC, + "max_quantity_per_shipment" REAL, + "weight_per_unit" REAL, + "linear_feet_per_unit" REAL, "freight_class" TEXT, "loading_instructions" TEXT, "stackable" INTEGER NOT NULL DEFAULT 0, diff --git a/services/tms/internal/infrastructure/sqlite/migrations/20250306161153_accessorial_charge.tx.up.sql b/services/tms/internal/infrastructure/sqlite/migrations/20250306161153_accessorial_charge.tx.up.sql index 8a8289dfe..e0818956f 100644 --- a/services/tms/internal/infrastructure/sqlite/migrations/20250306161153_accessorial_charge.tx.up.sql +++ b/services/tms/internal/infrastructure/sqlite/migrations/20250306161153_accessorial_charge.tx.up.sql @@ -12,7 +12,7 @@ CREATE TABLE IF NOT EXISTS "accessorial_charges"( "description" TEXT NOT NULL, "rate_unit" TEXT, "method" TEXT NOT NULL, - "amount" NUMERIC NOT NULL DEFAULT 0, + "amount" REAL NOT NULL DEFAULT 0, "version" INTEGER NOT NULL DEFAULT 0, "created_at" INTEGER NOT NULL DEFAULT (unixepoch()), "updated_at" INTEGER NOT NULL DEFAULT (unixepoch()), diff --git a/services/tms/internal/infrastructure/sqlite/migrations/20250323174045_billing_control.tx.up.sql b/services/tms/internal/infrastructure/sqlite/migrations/20250323174045_billing_control.tx.up.sql index d21bd9a1a..13b22d9f4 100644 --- a/services/tms/internal/infrastructure/sqlite/migrations/20250323174045_billing_control.tx.up.sql +++ b/services/tms/internal/infrastructure/sqlite/migrations/20250323174045_billing_control.tx.up.sql @@ -24,7 +24,7 @@ CREATE TABLE IF NOT EXISTS "billing_controls"( "send_auto_bill_notifications" INTEGER NOT NULL DEFAULT 1, "auto_bill_batch_size" INTEGER NOT NULL DEFAULT 100 CHECK ("auto_bill_batch_size" >= 1), "billing_exception_handling" TEXT NOT NULL DEFAULT 'Queue', - "rate_discrepancy_threshold" NUMERIC NOT NULL DEFAULT 5.00 CHECK ("rate_discrepancy_threshold" >= 0), + "rate_discrepancy_threshold" REAL NOT NULL DEFAULT 5.00 CHECK ("rate_discrepancy_threshold" >= 0), "auto_resolve_minor_discrepancies" INTEGER NOT NULL DEFAULT 0, "allow_invoice_consolidation" INTEGER NOT NULL DEFAULT 0, "consolidation_period_days" INTEGER NOT NULL DEFAULT 7 CHECK ("consolidation_period_days" >= 1), diff --git a/services/tms/internal/infrastructure/sqlite/migrations/20250326012748_additional_charge.tx.up.sql b/services/tms/internal/infrastructure/sqlite/migrations/20250326012748_additional_charge.tx.up.sql index 03fed8143..54f73fc03 100644 --- a/services/tms/internal/infrastructure/sqlite/migrations/20250326012748_additional_charge.tx.up.sql +++ b/services/tms/internal/infrastructure/sqlite/migrations/20250326012748_additional_charge.tx.up.sql @@ -11,7 +11,7 @@ CREATE TABLE IF NOT EXISTS "additional_charges"( "accessorial_charge_id" TEXT NOT NULL, "unit" INTEGER NOT NULL, "method" TEXT NOT NULL, - "amount" NUMERIC NOT NULL, + "amount" REAL NOT NULL, "version" INTEGER NOT NULL DEFAULT 0, "created_at" INTEGER NOT NULL DEFAULT (unixepoch()), "updated_at" INTEGER NOT NULL DEFAULT (unixepoch()), diff --git a/services/tms/internal/infrastructure/sqlite/migrations/20250401131740_customer_billing_profile.tx.up.sql b/services/tms/internal/infrastructure/sqlite/migrations/20250401131740_customer_billing_profile.tx.up.sql index 733b9db95..c0acf292d 100644 --- a/services/tms/internal/infrastructure/sqlite/migrations/20250401131740_customer_billing_profile.tx.up.sql +++ b/services/tms/internal/infrastructure/sqlite/migrations/20250401131740_customer_billing_profile.tx.up.sql @@ -12,8 +12,8 @@ CREATE TABLE IF NOT EXISTS "customer_billing_profiles"( "billing_cycle_day_of_week" INTEGER, "payment_term" TEXT NOT NULL DEFAULT 'Net30', "has_billing_control_overrides" INTEGER NOT NULL DEFAULT 0, - "credit_limit" NUMERIC, - "credit_balance" NUMERIC NOT NULL DEFAULT 0, + "credit_limit" REAL, + "credit_balance" REAL NOT NULL DEFAULT 0, "credit_status" TEXT NOT NULL DEFAULT 'Active', "enforce_credit_limit" INTEGER NOT NULL DEFAULT 0, "auto_credit_hold" INTEGER NOT NULL DEFAULT 0, @@ -29,7 +29,7 @@ CREATE TABLE IF NOT EXISTS "customer_billing_profiles"( "revenue_account_id" TEXT, "ar_account_id" TEXT, "apply_late_charges" INTEGER NOT NULL DEFAULT 0, - "late_charge_rate" NUMERIC, + "late_charge_rate" REAL, "grace_period_days" INTEGER NOT NULL DEFAULT 0, "tax_exempt" INTEGER NOT NULL DEFAULT 0, "tax_exempt_number" TEXT, @@ -40,7 +40,7 @@ CREATE TABLE IF NOT EXISTS "customer_billing_profiles"( "auto_bill" INTEGER NOT NULL DEFAULT 1, "detention_billing_enabled" INTEGER NOT NULL DEFAULT 0, "detention_free_minutes" INTEGER NOT NULL DEFAULT 120, - "detention_rate_per_hour" NUMERIC, + "detention_rate_per_hour" REAL, "auto_apply_accessorials" INTEGER NOT NULL DEFAULT 1, "billing_currency" TEXT NOT NULL DEFAULT 'USD', "require_po_number" INTEGER NOT NULL DEFAULT 0, diff --git a/services/tms/internal/infrastructure/sqlite/migrations/20250607200055_dedicated_lane_suggestions.tx.up.sql b/services/tms/internal/infrastructure/sqlite/migrations/20250607200055_dedicated_lane_suggestions.tx.up.sql index d9b53d812..e41d19a60 100644 --- a/services/tms/internal/infrastructure/sqlite/migrations/20250607200055_dedicated_lane_suggestions.tx.up.sql +++ b/services/tms/internal/infrastructure/sqlite/migrations/20250607200055_dedicated_lane_suggestions.tx.up.sql @@ -15,10 +15,10 @@ CREATE TABLE IF NOT EXISTS "dedicated_lane_suggestions"( "shipment_type_id" TEXT, "trailer_type_id" TEXT, "tractor_type_id" TEXT, - "confidence_score" NUMERIC NOT NULL, + "confidence_score" REAL NOT NULL, "frequency_count" INTEGER NOT NULL, - "average_freight_charge" NUMERIC, - "total_freight_value" NUMERIC, + "average_freight_charge" REAL, + "total_freight_value" REAL, "last_shipment_date" INTEGER NOT NULL, "first_shipment_date" INTEGER NOT NULL, "suggested_name" TEXT NOT NULL, diff --git a/services/tms/internal/infrastructure/sqlite/migrations/20250608193352_dedicated_lane_config.tx.up.sql b/services/tms/internal/infrastructure/sqlite/migrations/20250608193352_dedicated_lane_config.tx.up.sql index ac17a75bf..3168178a5 100644 --- a/services/tms/internal/infrastructure/sqlite/migrations/20250608193352_dedicated_lane_config.tx.up.sql +++ b/services/tms/internal/infrastructure/sqlite/migrations/20250608193352_dedicated_lane_config.tx.up.sql @@ -10,7 +10,7 @@ CREATE TABLE IF NOT EXISTS "pattern_configs"( "enabled" INTEGER NOT NULL DEFAULT 1, "min_frequency" INTEGER NOT NULL DEFAULT 3, "analysis_window_days" INTEGER NOT NULL DEFAULT 90, - "min_confidence_score" NUMERIC NOT NULL DEFAULT 0.7, + "min_confidence_score" REAL NOT NULL DEFAULT 0.7, "suggestion_ttl_days" INTEGER NOT NULL DEFAULT 30, "require_exact_match" INTEGER NOT NULL DEFAULT 0, "weight_recent_shipments" INTEGER NOT NULL DEFAULT 1, diff --git a/services/tms/internal/infrastructure/sqlite/migrations/20250616062950_notification_preferences.tx.up.sql b/services/tms/internal/infrastructure/sqlite/migrations/20250616062950_notification_preferences.tx.up.sql index f5a9bd118..cb77d43fc 100644 --- a/services/tms/internal/infrastructure/sqlite/migrations/20250616062950_notification_preferences.tx.up.sql +++ b/services/tms/internal/infrastructure/sqlite/migrations/20250616062950_notification_preferences.tx.up.sql @@ -9,7 +9,7 @@ CREATE TABLE IF NOT EXISTS "notification_preferences"( "organization_id" TEXT NOT NULL, "business_unit_id" TEXT NOT NULL, "resource" TEXT NOT NULL, - "update_types" TEXT NOT NULL DEFAULT '{}', + "update_types" TEXT NOT NULL DEFAULT '[]', "notify_on_all_updates" INTEGER NOT NULL DEFAULT 0, "notify_only_owned_records" INTEGER NOT NULL DEFAULT 1, "excluded_user_ids" TEXT, diff --git a/services/tms/internal/infrastructure/sqlite/migrations/20251105034324_add_accounting_control.tx.up.sql b/services/tms/internal/infrastructure/sqlite/migrations/20251105034324_add_accounting_control.tx.up.sql index bdbe9d82b..ea48cbe43 100644 --- a/services/tms/internal/infrastructure/sqlite/migrations/20251105034324_add_accounting_control.tx.up.sql +++ b/services/tms/internal/infrastructure/sqlite/migrations/20251105034324_add_accounting_control.tx.up.sql @@ -25,7 +25,7 @@ CREATE TABLE IF NOT EXISTS "accounting_controls"( "require_period_end_approval" INTEGER NOT NULL DEFAULT 1, "auto_close_periods" INTEGER NOT NULL DEFAULT 0, "enable_reconciliation" INTEGER NOT NULL DEFAULT 0, - "reconciliation_threshold" NUMERIC NOT NULL DEFAULT 0.0050, + "reconciliation_threshold" REAL NOT NULL DEFAULT 0.0050, "reconciliation_threshold_action" TEXT NOT NULL DEFAULT 'Warn', "halt_on_pending_reconciliation" INTEGER NOT NULL DEFAULT 0, "enable_reconciliation_notifications" INTEGER NOT NULL DEFAULT 1, diff --git a/services/tms/internal/infrastructure/sqlite/migrations/20260101054529_rbac_v3.tx.up.sql b/services/tms/internal/infrastructure/sqlite/migrations/20260101054529_rbac_v3.tx.up.sql index 72384fab2..d752e2092 100644 --- a/services/tms/internal/infrastructure/sqlite/migrations/20260101054529_rbac_v3.tx.up.sql +++ b/services/tms/internal/infrastructure/sqlite/migrations/20260101054529_rbac_v3.tx.up.sql @@ -27,6 +27,14 @@ DROP TABLE IF EXISTS policies; --bun:split +ALTER TABLE "user_organization_memberships" DROP COLUMN "role_ids"; + +--bun:split + +ALTER TABLE "user_organization_memberships" DROP COLUMN "direct_policies"; + +--bun:split + CREATE TABLE IF NOT EXISTS roles( "id" TEXT NOT NULL, "business_unit_id" TEXT NOT NULL, diff --git a/services/tms/internal/infrastructure/sqlite/migrations/20260304190000_drop_sequence_config_static_codes.tx.down.sql b/services/tms/internal/infrastructure/sqlite/migrations/20260304190000_drop_sequence_config_static_codes.tx.down.sql new file mode 100644 index 000000000..2ba7cc12b --- /dev/null +++ b/services/tms/internal/infrastructure/sqlite/migrations/20260304190000_drop_sequence_config_static_codes.tx.down.sql @@ -0,0 +1,6 @@ +-- Code generated from the PostgreSQL migrations by +-- scripts/dialect-convert/convert.py. Hand-edits are preserved only if you +-- stop regenerating this file; see docs/databases.md. +-- Source: 20260304190000_drop_sequence_config_static_codes.tx.down.sql + +SELECT 1; diff --git a/services/tms/internal/infrastructure/sqlite/migrations/20260304190000_drop_sequence_config_static_codes.tx.up.sql b/services/tms/internal/infrastructure/sqlite/migrations/20260304190000_drop_sequence_config_static_codes.tx.up.sql new file mode 100644 index 000000000..5f1ebeeaf --- /dev/null +++ b/services/tms/internal/infrastructure/sqlite/migrations/20260304190000_drop_sequence_config_static_codes.tx.up.sql @@ -0,0 +1,10 @@ +-- Code generated from the PostgreSQL migrations by +-- scripts/dialect-convert/convert.py. Hand-edits are preserved only if you +-- stop regenerating this file; see docs/databases.md. +-- Source: 20260304190000_drop_sequence_config_static_codes.tx.up.sql + +ALTER TABLE "sequence_configs" DROP COLUMN "location_code"; + +--bun:split + +ALTER TABLE "sequence_configs" DROP COLUMN "business_unit_code"; diff --git a/services/tms/internal/infrastructure/sqlite/migrations/20260326110000_add_document_upload_sessions.tx.up.sql b/services/tms/internal/infrastructure/sqlite/migrations/20260326110000_add_document_upload_sessions.tx.up.sql index 9f954d886..089f74e80 100644 --- a/services/tms/internal/infrastructure/sqlite/migrations/20260326110000_add_document_upload_sessions.tx.up.sql +++ b/services/tms/internal/infrastructure/sqlite/migrations/20260326110000_add_document_upload_sessions.tx.up.sql @@ -19,7 +19,7 @@ CREATE TABLE IF NOT EXISTS "document_upload_sessions"( "strategy" TEXT NOT NULL, "status" TEXT NOT NULL DEFAULT 'Initiated', "description" TEXT, - "tags" TEXT NOT NULL DEFAULT '{}', + "tags" TEXT NOT NULL DEFAULT '[]', "uploaded_parts" TEXT NOT NULL DEFAULT '[]', "part_size" INTEGER NOT NULL DEFAULT 0, "failure_code" TEXT, diff --git a/services/tms/internal/infrastructure/sqlite/migrations/20260405120000_add_equipment_type_interior_length.tx.up.sql b/services/tms/internal/infrastructure/sqlite/migrations/20260405120000_add_equipment_type_interior_length.tx.up.sql index d649948a1..357df6417 100644 --- a/services/tms/internal/infrastructure/sqlite/migrations/20260405120000_add_equipment_type_interior_length.tx.up.sql +++ b/services/tms/internal/infrastructure/sqlite/migrations/20260405120000_add_equipment_type_interior_length.tx.up.sql @@ -3,4 +3,4 @@ -- stop regenerating this file; see docs/databases.md. -- Source: 20260405120000_add_equipment_type_interior_length.tx.up.sql -ALTER TABLE "equipment_types" ADD COLUMN "interior_length" NUMERIC; +ALTER TABLE "equipment_types" ADD COLUMN "interior_length" REAL; diff --git a/services/tms/internal/infrastructure/sqlite/migrations/20260407100000_shipment_base_rate.tx.up.sql b/services/tms/internal/infrastructure/sqlite/migrations/20260407100000_shipment_base_rate.tx.up.sql index e01415ca4..d0873a36c 100644 --- a/services/tms/internal/infrastructure/sqlite/migrations/20260407100000_shipment_base_rate.tx.up.sql +++ b/services/tms/internal/infrastructure/sqlite/migrations/20260407100000_shipment_base_rate.tx.up.sql @@ -3,7 +3,7 @@ -- stop regenerating this file; see docs/databases.md. -- Source: 20260407100000_shipment_base_rate.tx.up.sql -ALTER TABLE "shipments" ADD COLUMN "base_rate" NUMERIC NOT NULL DEFAULT 0; +ALTER TABLE "shipments" ADD COLUMN "base_rate" REAL NOT NULL DEFAULT 0; --bun:split diff --git a/services/tms/internal/infrastructure/sqlite/migrations/20260407210000_remove_billing_control_prefix_columns.tx.down.sql b/services/tms/internal/infrastructure/sqlite/migrations/20260407210000_remove_billing_control_prefix_columns.tx.down.sql new file mode 100644 index 000000000..d19850e21 --- /dev/null +++ b/services/tms/internal/infrastructure/sqlite/migrations/20260407210000_remove_billing_control_prefix_columns.tx.down.sql @@ -0,0 +1,6 @@ +-- Code generated from the PostgreSQL migrations by +-- scripts/dialect-convert/convert.py. Hand-edits are preserved only if you +-- stop regenerating this file; see docs/databases.md. +-- Source: 20260407210000_remove_billing_control_prefix_columns.tx.down.sql + +SELECT 1; diff --git a/services/tms/internal/infrastructure/sqlite/migrations/20260407210000_remove_billing_control_prefix_columns.tx.up.sql b/services/tms/internal/infrastructure/sqlite/migrations/20260407210000_remove_billing_control_prefix_columns.tx.up.sql new file mode 100644 index 000000000..2e171ea5b --- /dev/null +++ b/services/tms/internal/infrastructure/sqlite/migrations/20260407210000_remove_billing_control_prefix_columns.tx.up.sql @@ -0,0 +1,10 @@ +-- Code generated from the PostgreSQL migrations by +-- scripts/dialect-convert/convert.py. Hand-edits are preserved only if you +-- stop regenerating this file; see docs/databases.md. +-- Source: 20260407210000_remove_billing_control_prefix_columns.tx.up.sql + +ALTER TABLE "billing_controls" DROP COLUMN "invoice_number_prefix"; + +--bun:split + +ALTER TABLE "billing_controls" DROP COLUMN "credit_memo_number_prefix"; diff --git a/services/tms/internal/infrastructure/sqlite/migrations/20260408120000_add_invoices.tx.up.sql b/services/tms/internal/infrastructure/sqlite/migrations/20260408120000_add_invoices.tx.up.sql index 6d197035d..d4a424017 100644 --- a/services/tms/internal/infrastructure/sqlite/migrations/20260408120000_add_invoices.tx.up.sql +++ b/services/tms/internal/infrastructure/sqlite/migrations/20260408120000_add_invoices.tx.up.sql @@ -29,9 +29,9 @@ CREATE TABLE IF NOT EXISTS "invoices"( "bill_to_state" TEXT, "bill_to_postal_code" TEXT, "bill_to_country" TEXT, - "subtotal_amount" NUMERIC NOT NULL DEFAULT 0, - "other_amount" NUMERIC NOT NULL DEFAULT 0, - "total_amount" NUMERIC NOT NULL DEFAULT 0, + "subtotal_amount" REAL NOT NULL DEFAULT 0, + "other_amount" REAL NOT NULL DEFAULT 0, + "total_amount" REAL NOT NULL DEFAULT 0, "version" INTEGER NOT NULL DEFAULT 0, "created_at" INTEGER NOT NULL DEFAULT (unixepoch()), "updated_at" INTEGER NOT NULL DEFAULT (unixepoch()), @@ -55,9 +55,9 @@ CREATE TABLE IF NOT EXISTS "invoice_lines"( "line_number" INTEGER NOT NULL, "type" TEXT NOT NULL, "description" TEXT NOT NULL, - "quantity" NUMERIC NOT NULL DEFAULT 0, - "unit_price" NUMERIC NOT NULL DEFAULT 0, - "amount" NUMERIC NOT NULL DEFAULT 0, + "quantity" REAL NOT NULL DEFAULT 0, + "unit_price" REAL NOT NULL DEFAULT 0, + "amount" REAL NOT NULL DEFAULT 0, "version" INTEGER NOT NULL DEFAULT 0, "created_at" INTEGER NOT NULL DEFAULT (unixepoch()), "updated_at" INTEGER NOT NULL DEFAULT (unixepoch()), diff --git a/services/tms/internal/infrastructure/sqlite/migrations/20260408180000_finalize_finance_controls.tx.up.sql b/services/tms/internal/infrastructure/sqlite/migrations/20260408180000_finalize_finance_controls.tx.up.sql index fc4eec1c8..b3a54dfe6 100644 --- a/services/tms/internal/infrastructure/sqlite/migrations/20260408180000_finalize_finance_controls.tx.up.sql +++ b/services/tms/internal/infrastructure/sqlite/migrations/20260408180000_finalize_finance_controls.tx.up.sql @@ -19,7 +19,7 @@ ALTER TABLE "accounting_controls" ADD COLUMN "journal_posting_mode" TEXT NOT NUL --bun:split -ALTER TABLE "accounting_controls" ADD COLUMN "auto_post_source_events" TEXT NOT NULL DEFAULT '{}'; +ALTER TABLE "accounting_controls" ADD COLUMN "auto_post_source_events" TEXT NOT NULL DEFAULT '[]'; --bun:split @@ -59,7 +59,7 @@ ALTER TABLE "accounting_controls" ADD COLUMN "reconciliation_mode" TEXT NOT NULL --bun:split -ALTER TABLE "accounting_controls" ADD COLUMN "reconciliation_tolerance_amount" NUMERIC NOT NULL DEFAULT 0.0000; +ALTER TABLE "accounting_controls" ADD COLUMN "reconciliation_tolerance_amount" REAL NOT NULL DEFAULT 0.0000; --bun:split @@ -99,6 +99,70 @@ ALTER TABLE "accounting_controls" ADD COLUMN "realized_fx_loss_account_id" TEXT; --bun:split +ALTER TABLE "accounting_controls" DROP COLUMN "auto_create_journal_entries"; + +--bun:split + +ALTER TABLE "accounting_controls" DROP COLUMN "journal_entry_criteria"; + +--bun:split + +ALTER TABLE "accounting_controls" DROP COLUMN "restrict_manual_journal_entries"; + +--bun:split + +ALTER TABLE "accounting_controls" DROP COLUMN "require_journal_entry_approval"; + +--bun:split + +ALTER TABLE "accounting_controls" DROP COLUMN "enable_journal_entry_reversal"; + +--bun:split + +ALTER TABLE "accounting_controls" DROP COLUMN "allow_posting_to_closed_periods"; + +--bun:split + +ALTER TABLE "accounting_controls" DROP COLUMN "require_period_end_approval"; + +--bun:split + +ALTER TABLE "accounting_controls" DROP COLUMN "auto_close_periods"; + +--bun:split + +ALTER TABLE "accounting_controls" DROP COLUMN "enable_reconciliation"; + +--bun:split + +ALTER TABLE "accounting_controls" DROP COLUMN "reconciliation_threshold_action"; + +--bun:split + +ALTER TABLE "accounting_controls" DROP COLUMN "halt_on_pending_reconciliation"; + +--bun:split + +ALTER TABLE "accounting_controls" DROP COLUMN "enable_reconciliation_notifications"; + +--bun:split + +ALTER TABLE "accounting_controls" DROP COLUMN "enable_automatic_tax_calculation"; + +--bun:split + +ALTER TABLE "accounting_controls" DROP COLUMN "require_document_attachment"; + +--bun:split + +ALTER TABLE "accounting_controls" DROP COLUMN "retain_deleted_entries"; + +--bun:split + +ALTER TABLE "accounting_controls" DROP COLUMN "enable_multi_currency"; + +--bun:split + ALTER TABLE "billing_controls" ADD COLUMN "default_payment_term" TEXT NOT NULL DEFAULT 'Net30'; --bun:split @@ -167,7 +231,7 @@ ALTER TABLE "billing_controls" ADD COLUMN "notify_on_billing_exceptions" INTEGER --bun:split -ALTER TABLE "billing_controls" ADD COLUMN "rate_variance_tolerance_percent" NUMERIC NOT NULL DEFAULT 0.000000; +ALTER TABLE "billing_controls" ADD COLUMN "rate_variance_tolerance_percent" REAL NOT NULL DEFAULT 0.000000; --bun:split @@ -175,6 +239,70 @@ ALTER TABLE "billing_controls" ADD COLUMN "rate_variance_auto_resolution_mode" T --bun:split +ALTER TABLE "billing_controls" DROP COLUMN "payment_term"; + +--bun:split + +ALTER TABLE "billing_controls" DROP COLUMN "show_invoice_due_date"; + +--bun:split + +ALTER TABLE "billing_controls" DROP COLUMN "invoice_terms"; + +--bun:split + +ALTER TABLE "billing_controls" DROP COLUMN "invoice_footer"; + +--bun:split + +ALTER TABLE "billing_controls" DROP COLUMN "show_amount_due"; + +--bun:split + +ALTER TABLE "billing_controls" DROP COLUMN "auto_transfer"; + +--bun:split + +ALTER TABLE "billing_controls" DROP COLUMN "transfer_schedule"; + +--bun:split + +ALTER TABLE "billing_controls" DROP COLUMN "auto_mark_ready_to_bill"; + +--bun:split + +ALTER TABLE "billing_controls" DROP COLUMN "enforce_customer_billing_req"; + +--bun:split + +ALTER TABLE "billing_controls" DROP COLUMN "validate_customer_rates"; + +--bun:split + +ALTER TABLE "billing_controls" DROP COLUMN "auto_bill"; + +--bun:split + +ALTER TABLE "billing_controls" DROP COLUMN "send_auto_bill_notifications"; + +--bun:split + +ALTER TABLE "billing_controls" DROP COLUMN "billing_exception_handling"; + +--bun:split + +ALTER TABLE "billing_controls" DROP COLUMN "auto_resolve_minor_discrepancies"; + +--bun:split + +ALTER TABLE "billing_controls" DROP COLUMN "allow_invoice_consolidation"; + +--bun:split + +ALTER TABLE "billing_controls" DROP COLUMN "group_consolidated_invoices"; + +--bun:split + CREATE TABLE IF NOT EXISTS invoice_adjustment_controls ( "id" TEXT NOT NULL, "business_unit_id" TEXT NOT NULL, @@ -187,10 +315,10 @@ CREATE TABLE IF NOT EXISTS invoice_adjustment_controls ( "adjustment_reason_requirement" TEXT NOT NULL DEFAULT 'Required', "adjustment_attachment_requirement" TEXT NOT NULL DEFAULT 'RequiredForAll', "standard_adjustment_approval_policy" TEXT NOT NULL DEFAULT 'AmountThreshold', - "standard_adjustment_approval_threshold" NUMERIC, + "standard_adjustment_approval_threshold" REAL, "write_off_approval_policy" TEXT NOT NULL DEFAULT 'RequireApprovalAboveThreshold', - "write_off_approval_threshold" NUMERIC, - "rerate_variance_tolerance_percent" NUMERIC NOT NULL DEFAULT 0.000000, + "write_off_approval_threshold" REAL, + "rerate_variance_tolerance_percent" REAL NOT NULL DEFAULT 0.000000, "replacement_invoice_review_policy" TEXT NOT NULL DEFAULT 'RequireReviewWhenEconomicTermsChange', "customer_credit_balance_policy" TEXT NOT NULL DEFAULT 'AllowUnappliedCredit', "over_credit_policy" TEXT NOT NULL DEFAULT 'Block', diff --git a/services/tms/internal/infrastructure/sqlite/migrations/20260408210000_invoice_adjustment_engine.tx.up.sql b/services/tms/internal/infrastructure/sqlite/migrations/20260408210000_invoice_adjustment_engine.tx.up.sql index 164864d94..259dc5b9d 100644 --- a/services/tms/internal/infrastructure/sqlite/migrations/20260408210000_invoice_adjustment_engine.tx.up.sql +++ b/services/tms/internal/infrastructure/sqlite/migrations/20260408210000_invoice_adjustment_engine.tx.up.sql @@ -3,7 +3,7 @@ -- stop regenerating this file; see docs/databases.md. -- Source: 20260408210000_invoice_adjustment_engine.tx.up.sql -ALTER TABLE "invoices" ADD COLUMN "applied_amount" NUMERIC NOT NULL DEFAULT 0; +ALTER TABLE "invoices" ADD COLUMN "applied_amount" REAL NOT NULL DEFAULT 0; --bun:split @@ -63,7 +63,7 @@ ALTER TABLE "billing_queue_items" ADD COLUMN "requires_replacement_review" INTEG --bun:split -ALTER TABLE "billing_queue_items" ADD COLUMN "rerate_variance_percent" NUMERIC; +ALTER TABLE "billing_queue_items" ADD COLUMN "rerate_variance_percent" REAL; --bun:split @@ -108,10 +108,10 @@ CREATE TABLE IF NOT EXISTS invoice_adjustments( "policy_reason" TEXT, "idempotency_key" TEXT NOT NULL, "accounting_date" INTEGER NOT NULL, - "credit_total_amount" NUMERIC NOT NULL DEFAULT 0, - "rebill_total_amount" NUMERIC NOT NULL DEFAULT 0, - "net_delta_amount" NUMERIC NOT NULL DEFAULT 0, - "rerate_variance_percent" NUMERIC NOT NULL DEFAULT 0, + "credit_total_amount" REAL NOT NULL DEFAULT 0, + "rebill_total_amount" REAL NOT NULL DEFAULT 0, + "net_delta_amount" REAL NOT NULL DEFAULT 0, + "rerate_variance_percent" REAL NOT NULL DEFAULT 0, "would_create_unapplied_credit" INTEGER NOT NULL DEFAULT 0, "requires_reconciliation_exception" INTEGER NOT NULL DEFAULT 0, "approval_required" INTEGER NOT NULL DEFAULT 0, @@ -154,11 +154,11 @@ CREATE TABLE IF NOT EXISTS invoice_adjustment_lines( "replacement_line_id" TEXT, "line_number" INTEGER NOT NULL, "description" TEXT NOT NULL, - "credit_quantity" NUMERIC NOT NULL DEFAULT 0, - "credit_amount" NUMERIC NOT NULL DEFAULT 0, - "remaining_eligible_amount" NUMERIC NOT NULL DEFAULT 0, - "rebill_quantity" NUMERIC NOT NULL DEFAULT 0, - "rebill_amount" NUMERIC NOT NULL DEFAULT 0, + "credit_quantity" REAL NOT NULL DEFAULT 0, + "credit_amount" REAL NOT NULL DEFAULT 0, + "remaining_eligible_amount" REAL NOT NULL DEFAULT 0, + "rebill_quantity" REAL NOT NULL DEFAULT 0, + "rebill_amount" REAL NOT NULL DEFAULT 0, "replacement_payload" TEXT NOT NULL DEFAULT '{}', "created_at" INTEGER NOT NULL DEFAULT (unixepoch()), "updated_at" INTEGER NOT NULL DEFAULT (unixepoch()), @@ -201,7 +201,7 @@ CREATE TABLE IF NOT EXISTS invoice_reconciliation_exceptions( "credit_memo_invoice_id" TEXT, "status" TEXT NOT NULL DEFAULT 'Open', "reason" TEXT NOT NULL, - "amount" NUMERIC NOT NULL DEFAULT 0, + "amount" REAL NOT NULL DEFAULT 0, "metadata" TEXT NOT NULL DEFAULT '{}', "created_at" INTEGER NOT NULL DEFAULT (unixepoch()), "updated_at" INTEGER NOT NULL DEFAULT (unixepoch()), diff --git a/services/tms/internal/infrastructure/sqlite/migrations/20260511000000_add_oanda_exchange_rates.tx.up.sql b/services/tms/internal/infrastructure/sqlite/migrations/20260511000000_add_oanda_exchange_rates.tx.up.sql index 0e6cd43fa..fd7051ffe 100644 --- a/services/tms/internal/infrastructure/sqlite/migrations/20260511000000_add_oanda_exchange_rates.tx.up.sql +++ b/services/tms/internal/infrastructure/sqlite/migrations/20260511000000_add_oanda_exchange_rates.tx.up.sql @@ -11,10 +11,10 @@ CREATE TABLE IF NOT EXISTS "exchange_rates"( "from_currency" TEXT NOT NULL, "to_currency" TEXT NOT NULL, "rate_type" TEXT NOT NULL DEFAULT 'mid', - "bid" NUMERIC NOT NULL, - "ask" NUMERIC NOT NULL, - "mid" NUMERIC NOT NULL, - "selected_rate" NUMERIC NOT NULL, + "bid" REAL NOT NULL, + "ask" REAL NOT NULL, + "mid" REAL NOT NULL, + "selected_rate" REAL NOT NULL, "date" TEXT NOT NULL, "source_timestamp" TEXT NOT NULL, "fetched_at" TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, @@ -41,9 +41,9 @@ CREATE TABLE IF NOT EXISTS "exchange_rate_settlement_quotes"( "provider" TEXT NOT NULL DEFAULT 'OANDA', "from_currency" TEXT NOT NULL, "to_currency" TEXT NOT NULL, - "amount" NUMERIC NOT NULL, - "rate" NUMERIC NOT NULL, - "converted_amount" NUMERIC NOT NULL, + "amount" REAL NOT NULL, + "rate" REAL NOT NULL, + "converted_amount" REAL NOT NULL, "rate_type" TEXT NOT NULL DEFAULT 'mid', "source_timestamp" TEXT NOT NULL, "fetched_at" TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, diff --git a/services/tms/internal/infrastructure/sqlite/migrations/20260527130000_replace_legacy_fx_with_oanda.tx.up.sql b/services/tms/internal/infrastructure/sqlite/migrations/20260527130000_replace_legacy_fx_with_oanda.tx.up.sql index 6dc9d63cb..7ff406066 100644 --- a/services/tms/internal/infrastructure/sqlite/migrations/20260527130000_replace_legacy_fx_with_oanda.tx.up.sql +++ b/services/tms/internal/infrastructure/sqlite/migrations/20260527130000_replace_legacy_fx_with_oanda.tx.up.sql @@ -22,9 +22,9 @@ CREATE TABLE IF NOT EXISTS "exchange_rate_settlement_quotes"( "provider" TEXT NOT NULL DEFAULT 'OANDA', "from_currency" TEXT NOT NULL, "to_currency" TEXT NOT NULL, - "amount" NUMERIC NOT NULL, - "rate" NUMERIC NOT NULL, - "converted_amount" NUMERIC NOT NULL, + "amount" REAL NOT NULL, + "rate" REAL NOT NULL, + "converted_amount" REAL NOT NULL, "rate_type" TEXT NOT NULL DEFAULT 'mid', "source_timestamp" TEXT NOT NULL, "fetched_at" TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, diff --git a/services/tms/internal/infrastructure/sqlite/migrations/20260531120000_customer_invoice_auto_send_profile.tx.up.sql b/services/tms/internal/infrastructure/sqlite/migrations/20260531120000_customer_invoice_auto_send_profile.tx.up.sql index e870dffdb..d6e38cdd5 100644 --- a/services/tms/internal/infrastructure/sqlite/migrations/20260531120000_customer_invoice_auto_send_profile.tx.up.sql +++ b/services/tms/internal/infrastructure/sqlite/migrations/20260531120000_customer_invoice_auto_send_profile.tx.up.sql @@ -4,3 +4,11 @@ -- Source: 20260531120000_customer_invoice_auto_send_profile.tx.up.sql ALTER TABLE "customer_billing_profiles" ADD COLUMN "auto_send_invoice_on_generation" INTEGER NOT NULL DEFAULT 1; + +--bun:split + +ALTER TABLE "customer_billing_profiles" DROP COLUMN "summary_transmit_on_generation"; + +--bun:split + +ALTER TABLE "customer_email_profiles" DROP COLUMN "send_invoice_on_generation"; diff --git a/services/tms/internal/infrastructure/sqlite/migrations/20260709120000_edi_carrier_invoices.tx.up.sql b/services/tms/internal/infrastructure/sqlite/migrations/20260709120000_edi_carrier_invoices.tx.up.sql index 5186414f7..029f4bf1c 100644 --- a/services/tms/internal/infrastructure/sqlite/migrations/20260709120000_edi_carrier_invoices.tx.up.sql +++ b/services/tms/internal/infrastructure/sqlite/migrations/20260709120000_edi_carrier_invoices.tx.up.sql @@ -21,9 +21,9 @@ CREATE TABLE IF NOT EXISTS "edi_carrier_invoices"( "bill_to_name" TEXT, "bill_to_source_id" TEXT, "currency_code" TEXT, - "total_amount" NUMERIC, - "expected_amount" NUMERIC, - "variance_amount" NUMERIC, + "total_amount" REAL, + "expected_amount" REAL, + "variance_amount" REAL, "line_charges" TEXT NOT NULL DEFAULT '[]', "reference_numbers" TEXT NOT NULL DEFAULT '{}', "reconciliation_status" TEXT NOT NULL DEFAULT 'Unmatched', diff --git a/services/tms/internal/infrastructure/sqlite/migrations/20260711120000_drop_edi_partner_validation_profile.tx.down.sql b/services/tms/internal/infrastructure/sqlite/migrations/20260711120000_drop_edi_partner_validation_profile.tx.down.sql new file mode 100644 index 000000000..5cce40626 --- /dev/null +++ b/services/tms/internal/infrastructure/sqlite/migrations/20260711120000_drop_edi_partner_validation_profile.tx.down.sql @@ -0,0 +1,6 @@ +-- Code generated from the PostgreSQL migrations by +-- scripts/dialect-convert/convert.py. Hand-edits are preserved only if you +-- stop regenerating this file; see docs/databases.md. +-- Source: 20260711120000_drop_edi_partner_validation_profile.tx.down.sql + +SELECT 1; diff --git a/services/tms/internal/infrastructure/sqlite/migrations/20260711120000_drop_edi_partner_validation_profile.tx.up.sql b/services/tms/internal/infrastructure/sqlite/migrations/20260711120000_drop_edi_partner_validation_profile.tx.up.sql new file mode 100644 index 000000000..86af97804 --- /dev/null +++ b/services/tms/internal/infrastructure/sqlite/migrations/20260711120000_drop_edi_partner_validation_profile.tx.up.sql @@ -0,0 +1,6 @@ +-- Code generated from the PostgreSQL migrations by +-- scripts/dialect-convert/convert.py. Hand-edits are preserved only if you +-- stop regenerating this file; see docs/databases.md. +-- Source: 20260711120000_drop_edi_partner_validation_profile.tx.up.sql + +ALTER TABLE "edi_partners" DROP COLUMN "default_validation_profile_id"; diff --git a/services/tms/internal/infrastructure/sqlite/migrations/20260718010000_formula_rating_features.tx.up.sql b/services/tms/internal/infrastructure/sqlite/migrations/20260718010000_formula_rating_features.tx.up.sql index 810cf635a..3a1ea80f9 100644 --- a/services/tms/internal/infrastructure/sqlite/migrations/20260718010000_formula_rating_features.tx.up.sql +++ b/services/tms/internal/infrastructure/sqlite/migrations/20260718010000_formula_rating_features.tx.up.sql @@ -7,11 +7,11 @@ ALTER TABLE "formula_templates" ADD COLUMN "breakdown_definitions" TEXT NOT NULL --bun:split -ALTER TABLE "formula_templates" ADD COLUMN "min_charge" NUMERIC; +ALTER TABLE "formula_templates" ADD COLUMN "min_charge" REAL; --bun:split -ALTER TABLE "formula_templates" ADD COLUMN "max_charge" NUMERIC; +ALTER TABLE "formula_templates" ADD COLUMN "max_charge" REAL; --bun:split @@ -39,11 +39,11 @@ ALTER TABLE "formula_template_versions" ADD COLUMN "breakdown_definitions" TEXT --bun:split -ALTER TABLE "formula_template_versions" ADD COLUMN "min_charge" NUMERIC; +ALTER TABLE "formula_template_versions" ADD COLUMN "min_charge" REAL; --bun:split -ALTER TABLE "formula_template_versions" ADD COLUMN "max_charge" NUMERIC; +ALTER TABLE "formula_template_versions" ADD COLUMN "max_charge" REAL; --bun:split @@ -89,9 +89,9 @@ CREATE TABLE IF NOT EXISTS "rate_table_entries"( "organization_id" TEXT NOT NULL, "rate_table_id" TEXT NOT NULL, "match_key" TEXT, - "range_min" NUMERIC, - "range_max" NUMERIC, - "value" NUMERIC NOT NULL, + "range_min" REAL, + "range_max" REAL, + "value" REAL NOT NULL, "sort_order" INTEGER NOT NULL DEFAULT 0, "created_at" INTEGER NOT NULL DEFAULT (unixepoch()), "updated_at" INTEGER NOT NULL DEFAULT (unixepoch()), diff --git a/services/tms/internal/infrastructure/sqlite/migrations/20260719000000_orders_and_grouped_invoicing.tx.up.sql b/services/tms/internal/infrastructure/sqlite/migrations/20260719000000_orders_and_grouped_invoicing.tx.up.sql index 8b06413e7..56eea7569 100644 --- a/services/tms/internal/infrastructure/sqlite/migrations/20260719000000_orders_and_grouped_invoicing.tx.up.sql +++ b/services/tms/internal/infrastructure/sqlite/migrations/20260719000000_orders_and_grouped_invoicing.tx.up.sql @@ -15,9 +15,9 @@ CREATE TABLE IF NOT EXISTS "orders"( "po_number" TEXT, "bol" TEXT, "currency_code" TEXT NOT NULL DEFAULT 'USD', - "quoted_amount" NUMERIC, - "base_amount" NUMERIC, - "total_amount" NUMERIC NOT NULL DEFAULT 0, + "quoted_amount" REAL, + "base_amount" REAL, + "total_amount" REAL NOT NULL DEFAULT 0, "version" INTEGER NOT NULL DEFAULT 0, "created_at" INTEGER NOT NULL DEFAULT (unixepoch()), "updated_at" INTEGER NOT NULL DEFAULT (unixepoch()), @@ -76,6 +76,10 @@ WHERE --bun:split +ALTER TABLE "orders" DROP COLUMN "backfill_shipment_id"; + +--bun:split + ALTER TABLE "invoices" ADD COLUMN "order_id" TEXT; --bun:split diff --git a/services/tms/internal/infrastructure/sqlite/migrations/20260720000000_order_charges.tx.up.sql b/services/tms/internal/infrastructure/sqlite/migrations/20260720000000_order_charges.tx.up.sql index 9241bde3c..c26dea909 100644 --- a/services/tms/internal/infrastructure/sqlite/migrations/20260720000000_order_charges.tx.up.sql +++ b/services/tms/internal/infrastructure/sqlite/migrations/20260720000000_order_charges.tx.up.sql @@ -9,7 +9,7 @@ CREATE TABLE IF NOT EXISTS "order_charges"( "organization_id" TEXT NOT NULL, "order_id" TEXT NOT NULL, "description" TEXT NOT NULL, - "amount" NUMERIC NOT NULL DEFAULT 0, + "amount" REAL NOT NULL DEFAULT 0, "version" INTEGER NOT NULL DEFAULT 0, "created_at" INTEGER NOT NULL DEFAULT (unixepoch()), "updated_at" INTEGER NOT NULL DEFAULT (unixepoch()), diff --git a/services/tms/internal/infrastructure/sqlite/migrations/20260723000000_fuel_surcharge.tx.up.sql b/services/tms/internal/infrastructure/sqlite/migrations/20260723000000_fuel_surcharge.tx.up.sql index d659d9db9..2e78a882c 100644 --- a/services/tms/internal/infrastructure/sqlite/migrations/20260723000000_fuel_surcharge.tx.up.sql +++ b/services/tms/internal/infrastructure/sqlite/migrations/20260723000000_fuel_surcharge.tx.up.sql @@ -40,7 +40,7 @@ CREATE TABLE IF NOT EXISTS "fuel_index_prices"( "organization_id" TEXT NOT NULL, "fuel_index_id" TEXT NOT NULL, "price_date" TEXT NOT NULL, - "price" NUMERIC NOT NULL, + "price" REAL NOT NULL, "currency" TEXT NOT NULL DEFAULT 'USD', "is_manual" INTEGER NOT NULL DEFAULT 0, "entered_by_id" TEXT, @@ -71,15 +71,15 @@ CREATE TABLE IF NOT EXISTS "fuel_surcharge_programs"( "fuel_index_id" TEXT NOT NULL, "accessorial_charge_id" TEXT NOT NULL, "method" TEXT NOT NULL, - "peg_price" NUMERIC, - "increment" NUMERIC, - "increment_rate" NUMERIC, - "miles_per_gallon" NUMERIC, + "peg_price" REAL, + "increment" REAL, + "increment_rate" REAL, + "miles_per_gallon" REAL, "step_rounding" TEXT NOT NULL DEFAULT 'Up', "rate_rounding" TEXT NOT NULL DEFAULT 'HalfUp', "rate_precision" INTEGER NOT NULL DEFAULT 4, - "min_amount" NUMERIC, - "max_amount" NUMERIC, + "min_amount" REAL, + "max_amount" REAL, "date_basis" TEXT NOT NULL DEFAULT 'PickupDate', "price_effective_day" INTEGER NOT NULL DEFAULT 3, "missing_price_fallback" TEXT NOT NULL DEFAULT 'UseLatestAvailable', @@ -117,9 +117,9 @@ CREATE TABLE IF NOT EXISTS "fuel_surcharge_table_rows"( "business_unit_id" TEXT NOT NULL, "organization_id" TEXT NOT NULL, "fuel_surcharge_program_id" TEXT NOT NULL, - "price_min" NUMERIC, - "price_max" NUMERIC, - "value" NUMERIC NOT NULL, + "price_min" REAL, + "price_max" REAL, + "value" REAL NOT NULL, "sort_order" INTEGER NOT NULL DEFAULT 0, "created_at" INTEGER NOT NULL DEFAULT (unixepoch()), "updated_at" INTEGER NOT NULL DEFAULT (unixepoch()), diff --git a/services/tms/internal/infrastructure/sqlite/migrations/20260726000000_costing.tx.up.sql b/services/tms/internal/infrastructure/sqlite/migrations/20260726000000_costing.tx.up.sql index 1e5d6a564..0b1c2f441 100644 --- a/services/tms/internal/infrastructure/sqlite/migrations/20260726000000_costing.tx.up.sql +++ b/services/tms/internal/infrastructure/sqlite/migrations/20260726000000_costing.tx.up.sql @@ -9,12 +9,12 @@ CREATE TABLE IF NOT EXISTS "costing_controls"( "organization_id" TEXT NOT NULL, "fuel_index_id" TEXT, "use_live_fuel_price" INTEGER NOT NULL DEFAULT 1, - "miles_per_gallon" NUMERIC NOT NULL DEFAULT 6.5, + "miles_per_gallon" REAL NOT NULL DEFAULT 6.5, "include_deadhead_miles" INTEGER NOT NULL DEFAULT 1, "gl_actuals_enabled" INTEGER NOT NULL DEFAULT 0, "gl_rolling_months" INTEGER NOT NULL DEFAULT 3, "planned_monthly_miles" INTEGER, - "target_margin_percent" NUMERIC, + "target_margin_percent" REAL, "version" INTEGER NOT NULL DEFAULT 0, "created_at" INTEGER NOT NULL DEFAULT (unixepoch()), "updated_at" INTEGER NOT NULL DEFAULT (unixepoch()), @@ -44,8 +44,8 @@ CREATE TABLE IF NOT EXISTS "cost_categories"( "name" TEXT NOT NULL, "cost_behavior" TEXT NOT NULL, "rate_source" TEXT NOT NULL DEFAULT 'Benchmark', - "benchmark_rate_per_mile" NUMERIC NOT NULL DEFAULT 0, - "override_rate_per_mile" NUMERIC, + "benchmark_rate_per_mile" REAL NOT NULL DEFAULT 0, + "override_rate_per_mile" REAL, "is_active" INTEGER NOT NULL DEFAULT 1, "sort_order" INTEGER NOT NULL DEFAULT 0, "version" INTEGER NOT NULL DEFAULT 0, diff --git a/services/tms/internal/infrastructure/sqlite/migrations/20260729000000_driver_settlements.tx.up.sql b/services/tms/internal/infrastructure/sqlite/migrations/20260729000000_driver_settlements.tx.up.sql index 3f7d8bede..c5fe6a225 100644 --- a/services/tms/internal/infrastructure/sqlite/migrations/20260729000000_driver_settlements.tx.up.sql +++ b/services/tms/internal/infrastructure/sqlite/migrations/20260729000000_driver_settlements.tx.up.sql @@ -78,9 +78,9 @@ CREATE TABLE IF NOT EXISTS settlement_controls( "auto_generate_batches" INTEGER NOT NULL DEFAULT 0, "auto_approve_clean" INTEGER NOT NULL DEFAULT 0, "allow_negative_net" INTEGER NOT NULL DEFAULT 1, - "variance_threshold_pct" NUMERIC NOT NULL DEFAULT 25, + "variance_threshold_pct" REAL NOT NULL DEFAULT 25, "variance_lookback_weeks" INTEGER NOT NULL DEFAULT 8, - "default_escrow_interest_rate" NUMERIC NOT NULL DEFAULT 0, + "default_escrow_interest_rate" REAL NOT NULL DEFAULT 0, "escrow_interest_frequency_months" INTEGER NOT NULL DEFAULT 3, "version" INTEGER NOT NULL DEFAULT 0, "created_at" INTEGER NOT NULL DEFAULT (unixepoch()), @@ -109,7 +109,7 @@ CREATE TABLE IF NOT EXISTS driver_pay_profiles( "classification" TEXT NOT NULL DEFAULT 'CompanyDriver', "currency_code" TEXT NOT NULL DEFAULT 'USD', "guaranteed_period_minimum_minor" INTEGER NOT NULL DEFAULT 0, - "per_diem_rate_per_mile" NUMERIC NOT NULL DEFAULT 0, + "per_diem_rate_per_mile" REAL NOT NULL DEFAULT 0, "per_diem_daily_cap_minor" INTEGER NOT NULL DEFAULT 0, "version" INTEGER NOT NULL DEFAULT 0, "created_at" INTEGER NOT NULL DEFAULT (unixepoch()), @@ -138,7 +138,7 @@ CREATE TABLE IF NOT EXISTS driver_pay_profile_components( "kind" TEXT NOT NULL, "method" TEXT NOT NULL, "description" TEXT, - "rate" NUMERIC NOT NULL DEFAULT 0, + "rate" REAL NOT NULL DEFAULT 0, "revenue_basis" TEXT, "bands" TEXT, "free_time_minutes" INTEGER NOT NULL DEFAULT 0, @@ -166,7 +166,7 @@ CREATE TABLE IF NOT EXISTS worker_pay_assignments( "pay_profile_id" TEXT NOT NULL, "effective_from" INTEGER NOT NULL, "effective_to" INTEGER, - "split_percent" NUMERIC NOT NULL DEFAULT 100, + "split_percent" REAL NOT NULL DEFAULT 100, "notes" TEXT, "created_by_id" TEXT, "version" INTEGER NOT NULL DEFAULT 0, @@ -194,7 +194,7 @@ CREATE TABLE IF NOT EXISTS escrow_accounts( "status" TEXT NOT NULL DEFAULT 'Active', "target_amount_minor" INTEGER NOT NULL DEFAULT 0, "balance_minor" INTEGER NOT NULL DEFAULT 0, - "annual_interest_rate" NUMERIC NOT NULL DEFAULT 0, + "annual_interest_rate" REAL NOT NULL DEFAULT 0, "last_interest_accrual_date" INTEGER, "opened_date" INTEGER NOT NULL, "closed_date" INTEGER, @@ -362,7 +362,7 @@ CREATE TABLE IF NOT EXISTS driver_settlements( "carry_forward_in_minor" INTEGER NOT NULL DEFAULT 0, "carry_forward_out_minor" INTEGER NOT NULL DEFAULT 0, "net_pay_minor" INTEGER NOT NULL DEFAULT 0, - "total_miles" NUMERIC NOT NULL DEFAULT 0, + "total_miles" REAL NOT NULL DEFAULT 0, "shipment_count" INTEGER NOT NULL DEFAULT 0, "currency_code" TEXT NOT NULL DEFAULT 'USD', "has_exceptions" INTEGER NOT NULL DEFAULT 0, @@ -427,8 +427,8 @@ CREATE TABLE IF NOT EXISTS driver_settlement_lines( "component_kind" TEXT, "method" TEXT, "description" TEXT NOT NULL, - "quantity" NUMERIC NOT NULL DEFAULT 0, - "rate" NUMERIC NOT NULL DEFAULT 0, + "quantity" REAL NOT NULL DEFAULT 0, + "rate" REAL NOT NULL DEFAULT 0, "amount_minor" INTEGER NOT NULL, "shipment_id" TEXT, "move_id" TEXT, @@ -465,7 +465,7 @@ CREATE TABLE IF NOT EXISTS driver_pay_events( "status" TEXT NOT NULL DEFAULT 'Accrued', "event_date" INTEGER NOT NULL, "gross_amount_minor" INTEGER NOT NULL DEFAULT 0, - "total_miles" NUMERIC NOT NULL DEFAULT 0, + "total_miles" REAL NOT NULL DEFAULT 0, "currency_code" TEXT NOT NULL DEFAULT 'USD', "components" TEXT, "pro_number" TEXT, diff --git a/services/tms/internal/infrastructure/sqlite/migrations/20260802000000_pay_codes.tx.up.sql b/services/tms/internal/infrastructure/sqlite/migrations/20260802000000_pay_codes.tx.up.sql index 8eb4b7047..f4c07b415 100644 --- a/services/tms/internal/infrastructure/sqlite/migrations/20260802000000_pay_codes.tx.up.sql +++ b/services/tms/internal/infrastructure/sqlite/migrations/20260802000000_pay_codes.tx.up.sql @@ -36,8 +36,16 @@ ALTER TABLE "recurring_earnings" ADD COLUMN "pay_code_id" TEXT; --bun:split +ALTER TABLE "recurring_earnings" DROP COLUMN "type"; + +--bun:split + ALTER TABLE "recurring_deductions" ADD COLUMN "pay_code_id" TEXT; --bun:split +ALTER TABLE "recurring_deductions" DROP COLUMN "type"; + +--bun:split + ALTER TABLE "driver_settlement_lines" ADD COLUMN "pay_code_id" TEXT; diff --git a/services/tms/internal/infrastructure/sqlite/migrations/20260808000000_agent_execution.tx.up.sql b/services/tms/internal/infrastructure/sqlite/migrations/20260808000000_agent_execution.tx.up.sql index 989573fed..c72d85124 100644 --- a/services/tms/internal/infrastructure/sqlite/migrations/20260808000000_agent_execution.tx.up.sql +++ b/services/tms/internal/infrastructure/sqlite/migrations/20260808000000_agent_execution.tx.up.sql @@ -65,7 +65,7 @@ CREATE TABLE IF NOT EXISTS "agent_proposals"( "run_id" TEXT NOT NULL, "tool_name" TEXT NOT NULL, "tool_params" TEXT NOT NULL DEFAULT '{}', - "confidence" NUMERIC NOT NULL DEFAULT 0, + "confidence" REAL NOT NULL DEFAULT 0, "rationale" TEXT NOT NULL, "evidence" TEXT NOT NULL DEFAULT '[]', "autonomy_tier" TEXT NOT NULL DEFAULT 'Propose', diff --git a/services/tms/internal/infrastructure/sqlite/migrations/20260830000000_detention_policy.tx.up.sql b/services/tms/internal/infrastructure/sqlite/migrations/20260830000000_detention_policy.tx.up.sql index da6b4a6e7..771897cb5 100644 --- a/services/tms/internal/infrastructure/sqlite/migrations/20260830000000_detention_policy.tx.up.sql +++ b/services/tms/internal/infrastructure/sqlite/migrations/20260830000000_detention_policy.tx.up.sql @@ -36,9 +36,9 @@ CREATE TABLE IF NOT EXISTS "detention_policies"( "rate_source" TEXT NOT NULL DEFAULT 'Accessorial', "accessorial_charge_id" TEXT NOT NULL, "max_billable_minutes_per_stop" INTEGER, - "max_charge_per_stop" NUMERIC, - "max_charge_per_day" NUMERIC, - "max_charge_per_shipment" NUMERIC, + "max_charge_per_stop" REAL, + "max_charge_per_day" REAL, + "max_charge_per_shipment" REAL, "day_boundary_mode" TEXT NOT NULL DEFAULT 'PerStop', "convert_to_layover_at_minutes" INTEGER, "layover_accessorial_charge_id" TEXT, @@ -48,8 +48,8 @@ CREATE TABLE IF NOT EXISTS "detention_policies"( "unnotified_behavior" TEXT NOT NULL DEFAULT 'Bill', "auto_send_notice" INTEGER NOT NULL DEFAULT 0, "send_departure_summary" INTEGER NOT NULL DEFAULT 0, - "require_approval_over_amount" NUMERIC, - "auto_approve_under_amount" NUMERIC, + "require_approval_over_amount" REAL, + "auto_approve_under_amount" REAL, "currency" TEXT NOT NULL DEFAULT 'USD', "comments" TEXT, "version" INTEGER NOT NULL DEFAULT 0, @@ -108,7 +108,7 @@ CREATE TABLE IF NOT EXISTS "detention_policy_tiers"( "detention_policy_id" TEXT NOT NULL, "from_minute" INTEGER NOT NULL DEFAULT 0, "to_minute" INTEGER, - "rate" NUMERIC NOT NULL DEFAULT 0, + "rate" REAL NOT NULL DEFAULT 0, "rate_unit" TEXT NOT NULL DEFAULT 'Hour', "label" TEXT, "sort_order" INTEGER NOT NULL DEFAULT 0, @@ -158,12 +158,12 @@ CREATE TABLE IF NOT EXISTS "detention_occurrences"( "raw_dwell_minutes" INTEGER NOT NULL DEFAULT 0, "billable_minutes" INTEGER NOT NULL DEFAULT 0, "rounded_minutes" INTEGER NOT NULL DEFAULT 0, - "billable_units" NUMERIC NOT NULL DEFAULT 0, - "gross_amount" NUMERIC NOT NULL DEFAULT 0, - "billable_amount" NUMERIC NOT NULL DEFAULT 0, + "billable_units" REAL NOT NULL DEFAULT 0, + "gross_amount" REAL NOT NULL DEFAULT 0, + "billable_amount" REAL NOT NULL DEFAULT 0, "driver_pay_minutes" INTEGER NOT NULL DEFAULT 0, - "driver_pay_amount" NUMERIC NOT NULL DEFAULT 0, - "net_margin" NUMERIC NOT NULL DEFAULT 0, + "driver_pay_amount" REAL NOT NULL DEFAULT 0, + "net_margin" REAL NOT NULL DEFAULT 0, "cap_applied" TEXT NOT NULL DEFAULT 'None', "converted_to_layover" INTEGER NOT NULL DEFAULT 0, "currency" TEXT NOT NULL DEFAULT 'USD', @@ -178,7 +178,7 @@ CREATE TABLE IF NOT EXISTS "detention_occurrences"( "waiver_note" TEXT, "waived_by_id" TEXT, "waived_at" INTEGER, - "waived_amount" NUMERIC NOT NULL DEFAULT 0, + "waived_amount" REAL NOT NULL DEFAULT 0, "dispute_note" TEXT, "disputed_at" INTEGER, "collectability_score" INTEGER NOT NULL DEFAULT 0, @@ -285,8 +285,8 @@ CREATE TABLE IF NOT EXISTS "detention_notices"( "was_automatic" INTEGER NOT NULL DEFAULT 0, "satisfies_requirement" INTEGER NOT NULL DEFAULT 0, "quoted_free_minutes" INTEGER NOT NULL DEFAULT 0, - "quoted_rate" NUMERIC, - "quoted_amount" NUMERIC, + "quoted_rate" REAL, + "quoted_amount" REAL, "version" INTEGER NOT NULL DEFAULT 0, "created_at" INTEGER NOT NULL DEFAULT (unixepoch()), "updated_at" INTEGER NOT NULL DEFAULT (unixepoch()), @@ -319,6 +319,18 @@ ALTER TABLE "shipment_controls" ADD COLUMN "use_detention_policy_engine" INTEGER --bun:split +ALTER TABLE "customer_billing_profiles" DROP COLUMN "detention_billing_enabled"; + +--bun:split + +ALTER TABLE "customer_billing_profiles" DROP COLUMN "detention_rate_per_hour"; + +--bun:split + +ALTER TABLE "customer_billing_profiles" DROP COLUMN "count_detention_only_on_appointment_stops"; + +--bun:split + ALTER TABLE "additional_charges" ADD COLUMN "detention_occurrence_id" TEXT; --bun:split diff --git a/services/tms/internal/infrastructure/sqlite/migrations/20260831000000_dispatcher_console.tx.up.sql b/services/tms/internal/infrastructure/sqlite/migrations/20260831000000_dispatcher_console.tx.up.sql index 0a4e741db..8f91bde93 100644 --- a/services/tms/internal/infrastructure/sqlite/migrations/20260831000000_dispatcher_console.tx.up.sql +++ b/services/tms/internal/infrastructure/sqlite/migrations/20260831000000_dispatcher_console.tx.up.sql @@ -7,7 +7,7 @@ ALTER TABLE "dispatch_controls" ADD COLUMN "scoring_weights" TEXT NOT NULL DEFAU --bun:split -ALTER TABLE "dispatch_controls" ADD COLUMN "auto_assign_confidence_threshold" NUMERIC NOT NULL DEFAULT 0.8500; +ALTER TABLE "dispatch_controls" ADD COLUMN "auto_assign_confidence_threshold" REAL NOT NULL DEFAULT 0.8500; --bun:split diff --git a/services/tms/internal/infrastructure/sqlite/migrations/20260902000000_document_templates.tx.up.sql b/services/tms/internal/infrastructure/sqlite/migrations/20260902000000_document_templates.tx.up.sql index dc6144c64..f598768c9 100644 --- a/services/tms/internal/infrastructure/sqlite/migrations/20260902000000_document_templates.tx.up.sql +++ b/services/tms/internal/infrastructure/sqlite/migrations/20260902000000_document_templates.tx.up.sql @@ -69,10 +69,10 @@ CREATE TABLE IF NOT EXISTS "document_template_versions"( "footer_html" TEXT, "page_size" TEXT, "orientation" TEXT, - "margin_top" NUMERIC, - "margin_bottom" NUMERIC, - "margin_left" NUMERIC, - "margin_right" NUMERIC, + "margin_top" REAL, + "margin_bottom" REAL, + "margin_left" REAL, + "margin_right" REAL, "content_hash" TEXT NOT NULL, "starter_hash" TEXT, "publish_notes" TEXT,