update db

This commit is contained in:
Jake Kasper
2025-08-22 08:29:48 -04:00
parent a0a9ec5411
commit bb365d918d
2 changed files with 18 additions and 1 deletions

View File

@@ -0,0 +1,15 @@
-- Migration: Add updated_at column to user_products table
-- This fixes the error: column "updated_at" of relation "user_products" does not exist
-- Add the updated_at column
ALTER TABLE user_products
ADD COLUMN updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP;
-- Update existing rows to have the current timestamp
UPDATE user_products SET updated_at = created_at WHERE updated_at IS NULL;
-- Create trigger to automatically update the timestamp
CREATE TRIGGER update_user_products_updated_at
BEFORE UPDATE ON user_products
FOR EACH ROW
EXECUTE FUNCTION update_updated_at_column();