Models

Understanding Prequel models

What are data models?

In this documentation, a data model refers to the Prequel representation of the structured data to be transferred using Prequel. An individual data model usually represents a single table, though (depending on the source/destination) it may also refer to a JSON blob or other file format (e.g., Parquet, CSV).

Data model configuration

📘

API reference

For the complete list of fields, their editability, and environment-specific constraints, see the Models API (PATCH) in the OpenAPI spec: OpenAPI 2023-12-01 – Models.

Each Prequel data model is configured via a JSON file with a specific format. If no model_name is provided, the name of the file (not including the extension) will be the name used for the table in the destination database. For example, for the configuration below, the destination table will appear as logs.

{
  "model_name": "logs",
  "columns": [
    {
      "name_in_source": "id",
      "name_in_destination": "id",
      "data_type": "text",
      "is_primary_key": true
    },
    {
      "name_in_source": "log",
      "name_in_destination": "event_log",
      "description":"A descriptive text entry of the event that occurred.",
      "data_type": "text"
    },
    {
      "name_in_source": "updated_at",
      "name_in_destination": "updated_at",
      "data_type": "timestamp",
      "is_last_modified": true
    }
  ],
  "source_table": "source_schema.application_logs",
  "source_name": "Example Production Source",
  "organization_column": "organization_id"
}
📘

Syncing config files from GitHub

You can use the Prequel GitHub Action to automatically sync any config file changes from GitHub to Prequel.

Configuration file keys

Each configuration file has 7 top level config keys: columns and source_table are always required; organization_column is required in multi-tenant tables mode; model_name, description, source_name, and source_id are optional.

Config file keys

Config KeyRequiredDescription
model_nameName of table to be loaded into the destination. If left blank, the file name (not including file extension) will be used.
descriptionTable description. Will be applied to destination tables if provided.
columnsA list of all destination columns (for this destination table). This is used to CREATE the table in the destination database, so it is important to use accurate types that correspond to the source data. The order of this list dictates the order in which columns appear in the destination database.

These columns are also used to create the READ and WRITE query, so it is important to use the correct name_in_source and a descriptive name_in_destination for end customers. They can, but do not need to be, the same name.

is_primary_key and is_last_modified are two important column flags that indicate which columns to use for detecting changes and propagating changes to the correct row in the destination. One of each must be present on one of the column objects.
source_tableSpecifies the name of the source table to be queried.
source_nameAssociates this model with a source by name. Required when multiple sources exist. If omitted with a single source, that source is used automatically. If provided, the value must match an existing source name, even in single-source accounts.
source_idAssociates this model with a source by ID. Carries the same enforcement as source_name. Both fields can be specified together, in which case the source must match both values.
organization_column (multi-tenant tables mode only)Specifies the column in the source table used to filter rows by tenant. Required in multi-tenant tables mode; not used in schema-tenanted mode (tenancy is determined by schema name instead). Because this column is not necessarily a column you want to transfer to recipients, it does not need to appear in the columns list. This column must be a string or varchar (non-numeric) data type.
📘

Choosing between source_name and source_id

Prefer source_name for config files shared across staging and production environments. Source names are consistent across environments, whereas source IDs are environment-specific UUIDs that differ between deployments. Use source_id when you need to reference a source by its UUID, or specify both fields together to require the source to match on both name and ID.

Column object keys

Column object keyRequiredDescription
name_in_sourceThe column name in the source system.
name_in_destinationThe column name to use in the destination table.
data_typeThe logical data type for this column. Refer to Acceptable Types.
is_primary_key(On exactly one column)Marks the primary key column used to identify rows. Exactly one column must be set.
is_last_modified(On exactly one column)Marks the column containing the last-updated timestamp used for change detection. Exactly one column must be set.
descriptionOptional human‑readable description for the column.
⚠️

is_primary_key and is_last_modified must appear within the first 32 columns

Both the primary key column and the last modified column must be positioned within the first 32 entries of the columns array (positions 1–32). This is a Prequel model requirement. It does not constrain the column order in your source table. The limit exists to respect ordinal position constraints in destination systems that implement indexing or partitioning by specific columns.

🚧

Using Acceptable Types

Use the correct data_type for each column to maintain compatibility with all destinations. Refer to the Data Types documentation for the complete list of supported types.

Column ordering

The order of columns in the columns array determines the column order in the destination table, but only at initial table creation. For existing destinations, columns added via schema evolution are always appended to the end of the destination table schema, regardless of their position in the model config. See Schema evolution for more detail.

Column name and table name conflicts

A column's name_in_source and name_in_destination cannot match the source table name or the destination table name (case-insensitive). This applies to both the column name as written and the table name as written.

Reserved column names

Some reserved keywords cannot be used as column names due to reserved statuses in common destination systems. There are 334:

1-6768-134135-201202-268269-334
ACCESSIBLEDEFERRABLEINOUTNULLSMALLINT
ACCOUNTDEFINEINSENSITIVENULLSSOME
ADDDELAYEDINSERTNUMERICSPATIAL
ALLDELETEINTOFSPECIFIC
ALTERDENSE_RANKINT1OFFSETSQL
ANALYSEDESCINT2ONSQL_BIG_RESULT
ANALYZEDESCRIBEINT3ONLYSQL_CALC_FOUND_ROWS
ANDDETERMINISTICINT4OPTIMIZESQL_SMALL_RESULT
ANTIDISTINCTINT8OPTIMIZER_COSTSSQLEXCEPTION
ANYDISTINCTROWINTEGEROPTIONSQLSTATE
ARRAYDIVINTERSECTOPTIONALLYSQLWARNING
ASDOINTERVALORSSL
ASCDOUBLEINTOORDERSTART
ASENSITIVEDROPIO_AFTER_GTIDSORGANIZATIONSTARTING
ASSERT_ROWS_MODIFIEDDUALIO_BEFORE_GTIDSOUTSTORED
ASYMMETRICEACHISOUTERSTRAIGHT_JOIN
ATELSEISNULLOUTFILESTRUCT
AUTHORIZATIONELSEIFISSUEOVERSYMMETRIC
BEFOREEMPTYITERATEOVERLAPSSYSTEM
BETWEENENCLOSEDJOINPARTITIONTABLE
BIGINTENDJSON_TABLEPERCENT_RANKTABLESAMPLE
BINARYENUMKEYPLACINGTERMINATED
BLOBESCAPEKEYSPRECEDINGTHEN
BOTHESCAPEDKILLPRECISIONTINYBLOB
BYEXCEPTLAGPRIMARYTINYINT
CALLEXCLUDELAST_VALUEPROCEDURETINYTEXT
CASCADEEXISTSLATERALPROTOTO
CASEEXITLEADPURGETRAILING
CASTEXPLAINLEADINGQUALIFYTREAT
CHANGEEXTRACTLEAVERANGETRIGGER
CHARFALSELEFTRANKTRUE
CHARACTERFETCHLIKEREADUNBOUNDED
CHECKFIRST_VALUELIMITREAD_WRITEUNDO
COLLATEFLOATLINEARREADSUNION
COLLATIONFLOAT4LINESREALUNIQUE
COLUMNFLOAT8LOADRECURSIVEUNLOCK
CONCURRENTLYFOLLOWINGLOCALTIMEREFERENCESUNNEST
CONDITIONFORLOCALTIMESTAMPREGEXPUNSIGNED
CONNECTFORCELOCKRELEASEUPDATE
CONNECTIONFOREIGNLONGRENAMEUSAGE
CONSTRAINTFREEZELONGBLOBREPEATUSE
CONTAINSFROMLONGTEXTREPLACEUSER
CONTINUEFULLLOOKUPREQUIREUSING
CONVERTFULLTEXTLOOPRESIGNALUTC_DATE
CREATEFUNCTIONLOW_PRIORITYRESTRICTUTC_TIME
CROSSGENERATEDMASTER_BINDRETURNUTC_TIMESTAMP
CUBEGETMASTER_SSL_VERIFY_SERVER_CERTRETURNINGVALUES
CUME_DISTGRANTMATCHREVOKEVARBINARY
CURRENTGROUPMAXVALUERIGHTVARCHAR
CURRENT_CATALOGGROUPINGMEDIUMBLOBRLIKEVARCHARACTER
CURRENT_DATEGROUPSMEDIUMINTROLLUPVARIADIC
CURRENT_ROLEGSCLUSTERMEDIUMTEXTROWVARYING
CURRENT_SCHEMAHASHMERGEROW_NUMBERVERBOSE
CURRENT_TIMEHAVINGMIDDLEINTROWSVIEW
CURRENT_TIMESTAMPHIGH_PRIORITYMINUSSAMPLEVIRTUAL
CURRENT_USERHOUR_MICROSECONDMINUTE_MICROSECONDSCHEMAWHEN
CURSORHOUR_MINUTEMINUTE_SECONDSCHEMASWHENEVER
DATABASEHOUR_SECONDMODSECOND_MICROSECONDWHERE
DATABASESIFMODIFIESSELECTWHILE
DAY_HOURIGNORENATURALSEMIWINDOW
DAY_MICROSECONDILIKENEWSENSITIVEWITH
DAY_MINUTEINNOSEPARATORWITHIN
DAY_SECONDINCREMENTNO_WRITE_TO_BINLOGSESSION_USERWRITE
DECINDEXNOTSETXOR
DECIMALINFILENOTNULLSHOWYEAR_MONTH
DECLAREINITIALLYNTH_VALUESIGNALZEROFILL
DEFAULTINNERNTILESIMILAR``

Reserved column name prefixes

In order to avoid conflicts in common destination systems, column names cannot start with certain reserved prefixes. There are 10 reserved prefixes:

1-56-10
PARGO_PREFIX__TABLE_
_FILE__PARTITION
_ROW_TIMESTAMP__ROOT__
_COLIDENTIFIER_CHANGE_SEQUENCE_NUMBER
_CHANGE_TYPE_CHANGE_TIMESTAMP

Grouping data models into products

By default, every destination you add to Prequel will be sent all configured models. Products allow you to only send a subset of those models to destinations.