Skip to main content

New Column Addition Strategies

Introduction

When a Neosync Job is configured for relational databases, all columns for each selected table must have a transformer mapping configured. This page goes into detail how Neosync handles new columns that may be added to your source database in-between updating a job.

This is a common occurrence for any company that is adding new columns to a database and may not update Neosync straight away.

Driver Support

StrategyDescriptionPostgreSQLMySQLMS SQL Server
HaltStops the job run if a new column is detected that is not found in the configured job mappings.
AutoMapAutomatically generates a fake value. See more below.
ContinueIgnores new columns; may fail if column doesn't have default. See more below.

Halt Strategy

This strategy is plain and simple. During the job run, Neosync compares the configured job mappings with the source database. For the selected tables in the job mappings, a diff is made and if a column is found in the source connection that doesn't exist in the job mappings, the run is halted.

Continue Strategy

This strategy tells Neosync to ignore any difference in job mappings from the source database.

Neosync is able to detect that new columns were added in the source, but it will leave them off of the insert statement. This may result in failures if any unmapped columns do not have a column default in the destination connection. However, any additional columns that have a default or are a generated column will not result in a job run failure.

ExampleSuccess
ALTER TABLE ADD COLUMN foo TEXT NOT NULL DEFAULT "test"
ALTER TABLE ADD COLUMN foo TEXT NULL DEFAULT NULL
ALTER TABLE ADD COLUMN full_name TEXT GENERATED ALWAYS AS (first_name || ' ' || last_name) STORED
ALTER TABLE ADD COLUMN foo TEXT NOT NULL

Auto Map

Automap is a smart strategy that attempts to do what it can to prevent PII from leaking or from failure modes with additional columns being added.

Not all data types are currently supported and will continue to receive updates over time to improve data type support.

The algorithm works as follows:

  1. If the column has a DB Default or is Generated, use the database default
  2. If the column is Nullable, set the column to null.
  3. Based on the data type, generate a proper value that will fit within that column.
  4. If an unsupported data type is detected, halt the run.

Passthrough

Passthrough mode is a strategy that allows Neosync to handle new columns found in source tables by setting them to passthrough. This means that any new columns detected in the source database will be included in the table sync and their values will be directly copied from the source to the destination without any transformation.

This strategy is useful when you want to reduce the need for manual updates to job mappings when new columns are added to the source database.

Note: It is recommended to use the init schema destination option with the passthrough strategy to ensure that the destination schema is always updated to match the source schema.

Postgres

Postgres has many data types and not all of them are currently supported in the auto map mode. Support will continue to increase over time.

Data TypeSupportGenerator
smallintGenerateInt64
integerGenerateInt64
bigintGenerateInt64
decimalGenerateFloat64
numericGenerateFloat64
realGenerateFloat64
double precisionGenerateFloat64
serialGenerateDefault
smallserialGenerateDefault
bigserialGenerateDefault
moneyGenerateFloat64
charGenerateString
varcharGenerateString
textGenerateString
bytea
timestamp
timestamptz
date
time
timetz
interval
booleanGenerateBool
point
line
lseg
box
path
polygon
circle
cidr
inet
macaddr
bit
tsvector
uuidGenerateUuid
xml
json
jsonb
int4range
int8range
numrange
tsrange
tstzrange
daterange
oid
text[]

MySQL

MySQL has many data types and not all of them are currently supported in the auto map mode. Support will continue to increase over time.

Data TypeSupportGenerator
tinyintGenerateInt64
smallintGenerateInt64
mediumintGenerateInt64
integerGenerateInt64
intGenerateInt64
bigintGenerateInt64
floatGenerateFloat64
decimalGenerateFloat64
decGenerateFloat64
doubleGenerateFloat64
double precisionGenerateFloat64
charGenerateString
varcharGenerateString
tinytextGenerateString
textGenerateString
mediumtextGenerateString
longtextGenerateString
booleanGenerateBool
boolGenerateBool
enumGenerateCategorical
setGenerateCategorical
dateGenerateJavaScript
datetimeGenerateJavaScript
timestampGenerateJavaScript
timeGenerateJavaScript
yearGenerateJavaScript
bit
binary
varbinary
tinyblob
blob
mediumblob
longblob