Skip to content

database integrity trigger functions#65

Open
vicchois wants to merge 1 commit into
mainfrom
database-integrity-trigger-functions
Open

database integrity trigger functions#65
vicchois wants to merge 1 commit into
mainfrom
database-integrity-trigger-functions

Conversation

@vicchois

@vicchois vicchois commented May 4, 2026

Copy link
Copy Markdown
Contributor

Created database integrity trigger functions for the following tables at supabase/schemas/functions/protect_cols.sql with a corresponding migration file.

  • users
    • Function: private.protect_users_cols()
      • For the email field, set new.email to old.email if auth.role() is authenticated.
    • Trigger: before update users
  • user_roles
    • Function: private.protect_user_roles_cols()
    • Trigger: before update user_roles
  • stores
    • Function: private.protect_stores_cols()
    • Trigger: before update stores
  • store_items
    • Function: private.protect_store_items_cols()
    • Trigger: before update store_items
  • inventory_items
    • Function: private.protect_inventory_items_cols()
    • Trigger: before update inventory_items
  • subcategories
    • Function: private.protect_subcategories_cols()
    • Trigger: before update subcategories
  • categories
    • Function: private.protect_categories_cols()
    • Trigger: before update categories
  • tickets
    • Function: private.protect_tickets_cols()
      • Edit: For the status field, set new.status to old.status if:
        • old.status is “fulfilled”
        • (1) private.can_manage_store(old.store_id) returns false, and (2) old.status is not “ready” or new.status is not “fulfilled”
        • (1) private.can_manage_store(old.store_id) returns true, (2) old.status is “requested”, and (3) new.status is “fulfilled”.
    • Trigger: before update tickets
  • ticket_items
    • Function: private.protect_ticket_items_cols()
    • Trigger: before update ticket_items
  • donations
    • Function: private.protect_donations_cols()
    • Trigger: before update donations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant