Prerequisites
If you’re running Sequin locally, be sure to install and configure Sequin first. You’ll need permission to create publications and replication slots on your database. You may also need administration privileges on your database if logical replication is not configured (more below).Provision a Postgres user for Sequin
When in development, it’s probably fine to supply Sequin with an existing user. However, when in production, you should create a dedicated user for Sequin. The user needs the following permissions:connect
permission on the database.select
permission on all the tables you want to connect to Sequin.replication
permission to read from replication slots.
Enable logical replication
Sequin uses logical replication to capture changes from your Postgres database. To find out if logical replication is enabled on your database, connect to your database and run the following SQL command:wal_level
must be set to logical
.
If it’s not, you’ll need to enable it. Note that this requires a restart of your database.
Follow these steps to enable logical replication:
1
Locate your postgresql.conf file
The location varies by platform:
- Linux: Usually in
/etc/postgresql/<version>/main/postgresql.conf
- macOS (Homebrew):
/usr/local/var/postgresql@<version>/postgresql.conf
- Windows:
C:\Program Files\PostgreSQL\<version>\data\postgresql.conf
2
Edit postgresql.conf
Open postgresql.conf in your text editor and set:If you can’t find the
wal_level
setting, add it at the end of the file.3
Restart PostgreSQL
Restart PostgreSQL to apply the changes:Linux:macOS:Windows:
show wal_level;
command again to verify the change took effect.
Connect Sequin to your database
In the Sequin Console, navigate to the “Databases” tab and click “Connect Database”.Database connection details
Fill in the connection details for your database:- Host: The host address of your database.
- Port: The port number of your database.
- Database: The name of your database.
- Username: The username Sequin will use to connect to your database.
- Password: The password Sequin will use to connect to your database.
Replication configuration
1
Slot name and publication name
Fill in the “Slot name” and “Publication name” that you’d like Sequin to use.
2
Create slot and publication
Follow the instructions to create the slot and publication on your database.The simplest publication is one that includes all tables:However, you can also create a publication that includes specific tables or schemas. You’ll just need to modify the publication as needed in the future.
Be sure to create the publication before you create the slot.
Test and connect
1
Test connection
Click “Test connection” to verify that Sequin can connect to your database.
2
Connect
Once the test goes green, click “Connect” to finish the connection process.
Monitoring
Sequin will run health checks against your database connection automatically. You can view the status of the connection at any time in your database’s “Overview” page.Adding tables to your publication
If you created a publication that contained a subset of your tables, you can add more tables to the publication later. To add tables to an existing publication, use thealter publication
command: