update db
This commit is contained in:
@@ -103,7 +103,8 @@ CREATE TABLE user_products (
|
||||
custom_rate_amount DECIMAL(8, 4),
|
||||
custom_rate_unit VARCHAR(50),
|
||||
notes TEXT,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
-- Application plans (what user plans to apply)
|
||||
@@ -242,4 +243,5 @@ CREATE TRIGGER update_users_updated_at BEFORE UPDATE ON users FOR EACH ROW EXECU
|
||||
CREATE TRIGGER update_properties_updated_at BEFORE UPDATE ON properties FOR EACH ROW EXECUTE FUNCTION update_updated_at_column();
|
||||
CREATE TRIGGER update_lawn_sections_updated_at BEFORE UPDATE ON lawn_sections FOR EACH ROW EXECUTE FUNCTION update_updated_at_column();
|
||||
CREATE TRIGGER update_user_equipment_updated_at BEFORE UPDATE ON user_equipment FOR EACH ROW EXECUTE FUNCTION update_updated_at_column();
|
||||
CREATE TRIGGER update_user_products_updated_at BEFORE UPDATE ON user_products FOR EACH ROW EXECUTE FUNCTION update_updated_at_column();
|
||||
CREATE TRIGGER update_application_plans_updated_at BEFORE UPDATE ON application_plans FOR EACH ROW EXECUTE FUNCTION update_updated_at_column();
|
||||
15
database/migrations/add_updated_at_to_user_products.sql
Normal file
15
database/migrations/add_updated_at_to_user_products.sql
Normal 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();
|
||||
Reference in New Issue
Block a user