With your API data in a Postgres database, reading from APIs like Salesforce or HubSpot has never been easier.
customer
, you can run:
customer
, you might paste in a schema definition that looks like this:
customer_id
on subscription
which references a customer
. With this field in place, we can now call subscription.customer
on any subscription to retrieve its corresponding customer. This is called a forward reference and is a key value that ORMs provide.
The easiest approach is to setup the relationship on the child first, as the field for the relationship lives there. Then you can add the corresponding field on the parent later. All forward references end in _id
, so an easy way to see which tables a given table is the child of is to run this query:
text
, as that’s the ID type used by all of Sequin’s sources.
info
You may be able to skip some of these steps if your ORM has a schema generator. While it’s worth a Google search to see if your ORM has one, you’ll usually still want to take a manual pass of the auto-generated files. Some of these generators miss relationships between tables or give odd names to back-refs or forward-refs.
string
. If you’re syncing to a Postgres schema other than public
, you’ll also want to set the @schema_prefix
.
If you’re generating many schemas, you can roll some of these module attributes up to a shared module like this:
stripe_
prefix, like stripe_customer
and stripe_subscription
. This feature is not exposed in our UI at the moment, so just get in touch if you need it.