Files
sonr/internal/migrations/011_common_functions.sql
T

21 lines
413 B
PL/PgSQL
Raw Normal View History

2025-10-03 14:45:52 -04:00
-- +goose Up
-- +goose StatementBegin
-- Create a common function to update the updated_at column
CREATE OR REPLACE FUNCTION update_updated_at_column()
RETURNS TRIGGER AS $$
BEGIN
NEW.updated_at = NOW();
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
-- +goose StatementEnd
-- +goose Down
-- +goose StatementBegin
-- Drop the function
DROP FUNCTION IF EXISTS update_updated_at_column();
-- +goose StatementEnd