⚒️ Automated Airtable to Postgres migration with n8n

191 views · ⚒️ Engineering

Description

Overview

This ETL system automates the process of migrating data from Airtable to PostgreSQL with a single API request.

> ⚙️ Originally built in-house to help us migrate off Airtable after exceeding usage limits.


🔧 How It Works

  1. Accepts Airtable and Postgres credentials via HTTP requests.
  2. Authenticates both services and validates schema compatibility.
  3. Fetches data from Airtable and maps each table and field to PostgreSQL equivalents.
  4. Creates the necessary tables in your Postgres database.
  5. Inserts all records in batches.
  6. Returns a success response with summary stats.

> Bonus operations: You can list or delete created tables using API endpoints.


Setup Instructions (n8n Workflow)

Step 1: Airtable Configuration

Step 2: PostgreSQL Configuration

Step 3: Deploy in n8n


API Endpoints & Payloads

Here are the available HTTP endpoints and how to use them.


1. Test Airtable Credentials

curl -X POST "https://n8n.com/webhook/123/validate-airtable" \
  -H "Content-Type: application/json" \
  -d '{
    "airtable": {
      "airtableId": "app12345",
      "airtableToken": "pjhy.iyhhs"
    }
  }'

2. Test PostgreSQL Credentials

curl -X POST "https://n8n.com/webhook/123/validate-postgres" \
  -H "Content-Type: application/json" \
  -d '{
    "postgres": {
      "host": "aws-0-us-west-1.pooler.supabase.com",
      "port": "6543",
      "user": "postgres.username",
      "password": "gamjgnrkxetb",
      "database": "postgres"
    }
  }'

3. Sync Airtable Data to Postgres

curl -X POST "https://n8n.com/webhook/123/sync" \
  -H "Content-Type: application/json" \
  -d '{
    "host": "aws-0-us-west-1.pooler.supabase.com",
    "port": "6543",
    "user": "postgres.username",
    "password": "gamjgnrkxetb",
    "database": "postgres",
    "airtableId": "app73PqALbM3AM0xN",
    "airtableToken": "patNCueRkrLI98fEq.9ae7f9786e9ad73ac21ca26d8046f08ad77e135ae950a6e2ff3760d85aca3db4",
    "action": "Move"
  }'

Expected Response:

[
  {
    "statusCode": 200,
    "statusMessage": "Data migration successful",
    "recordsProcessed": 152,
    "tablesProcessed": 3
  }
]

4.List All Created Tables

curl -X POST "https://n8n.com/webhook/123/list-tables" \
  -H "Content-Type: application/json" \
  -d '{
    "postgres": {
      "host": "aws-0-us-west-1.pooler.supabase.com",
      "port": "6543",
      "user": "postgres.username",
      "password": "gamjgnrkxetb",
      "database": "postgres"
    }
  }'

5. Delete Migrated Tables

curl -X POST "https://n8n.com/webhook/123/delete-tables" \
  -H "Content-Type: application/json" \
  -d '{
    "postgres": {
      "host": "aws-0-us-west-1.pooler.supabase.com",
      "port": "6543",
      "user": "postgres.username",
      "password": "gamjgnrkxetb",
      "database": "postgres"
    }
  }'

Technical Notes


Usage Scenarios


Requirements


Need Help?

Feel free to reach out via LinkedIn or Email if you need help adapting this workflow for your organization or extending it with extra transformations.

Happy productivity!

🔗 Nodes Used

HTTP Request, Webhook

📥 Import

Download workflow.json and import into n8n: Workflow menu → Import from File

📖 Importing guide · 🔑 Credential setup