Functions and Triggers

The Functions component copies your PostgreSQL functions and stored procedures. The Triggers component copies the triggers associated with your tables.

Functions

What Is Copied

  • Function name and schema
  • Parameters (names, types, default values)
  • Return type
  • Function body (the SQL/plpgsql code)
  • Language (plpgsql, sql, plv8, etc.)
  • Attributes (VOLATILE, STABLE, IMMUTABLE, SECURITY DEFINER, etc.)

Examples of Cloned Functions

  • Business logic functions
  • RPC functions called from the Supabase client
  • Validation functions
  • Stored procedures

Re-cloning

Functions use CREATE OR REPLACE — if the function already exists on the target, it is updated with the new definition. No duplicates.

Triggers

What Is Copied

  • Trigger name
  • Associated table
  • Trigger event (INSERT, UPDATE, DELETE)
  • Timing (BEFORE, AFTER, INSTEAD OF)
  • Condition (WHEN clause)
  • Function called by the trigger

Examples of Cloned Triggers

  • on_user_created — actions after a user signs up
  • update_updated_at — automatically update the updated_at field
  • validate_data — validation before insertion

Clone Order

Triggers are cloned after functions, since a trigger references a function. The order is:

  1. Tables (structure)
  2. Functions
  3. Triggers

Key Considerations

SituationBehavior
Function already existsReplaced (CREATE OR REPLACE)
Trigger already existsDropped and recreated
Function using an uninstalled extensionFails — install the extension first
Trigger on an excluded tableThe trigger is still cloned (the table exists, only the data is excluded)

Next Steps