Skip to content

Run MongoDB → MotherDuck migration

POST
/migrate

Extracts data from MongoDB for the specified flocks and loads it into MotherDuck. Supports two modes:

  • incremental (default): queries MAX(last_updated) per collection/flock and only fetches records changed since then. Changed records are upserted (delete + re-insert by uid).
  • full: deletes all flock data and re-inserts everything from MongoDB. Use for initial loads or resets.

Default flocks: ["example", "sheepy-owners-club"].

Collections migrated (19): person, organisation, member, payment, message, membership_type, ticket_type, booking, ticket, attendee, activity, bank_account, badge, connection, evidence, pledge, grant, group, group_member.

Note: The HTTP API Gateway has a 30s timeout. For long-running migrations, invoke the Lambda directly via aws lambda invoke.

object
flocks

List of flock bucket IDs to migrate.

Array<string>
default: example,sheepy-owners-club
Example
[
"example"
]
mode

incremental syncs only records changed since the last run. full deletes all flock data and re-inserts everything.

string
default: incremental
Allowed values: incremental full
collections

Specific collections to migrate. If omitted, all 19 collections are migrated.

Array<string>
Example
[
"person",
"member"
]
summary

If true, returns a cost summary without actually running the migration. Useful for estimating MotherDuck DU cost.

boolean
Examples

Incremental sync (default)

{
"flocks": [
"example"
]
}

Migration completed successfully

object
status
required
string
Allowed values: success
Example
success
mode
required
string
Allowed values: incremental full
Example
incremental
flocks
required
Array<string>
Example
[
"example"
]
totals
required

Row counts per collection per flock.

object
key
additional properties
object
key
additional properties
integer
Example
{
"person": {
"example": 1250
},
"organisation": {
"example": 340
}
}
grand_total
required

Total rows inserted across all tables and flocks.

integer
Example
6770
Example
{
"status": "success",
"mode": "incremental",
"flocks": [
"example"
],
"totals": {
"person": {
"example": 1250
},
"organisation": {
"example": 340
},
"member": {
"example": 980
},
"payment": {
"example": 4200
}
},
"grand_total": 6770
}

Authentication required

object
error
required
object
code
required

Machine-readable error code.

string
Example
unauthorized
message
required

Human-readable error message.

string
Example
Authentication required
Example
{
"error": {
"code": "unauthorized",
"message": "Authentication required"
}
}

Internal server error

object
error
required
object
code
required

Machine-readable error code.

string
Example
unauthorized
message
required

Human-readable error message.

string
Example
Authentication required
Example
{
"error": {
"code": "schema_error",
"message": "Schema application failed"
}
}