Quellcode des ICON CRM (2)
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
-- Database Schema Update for Customer Profiles
|
||||
|
||||
-- Add 'address' column to 'icon_customers' if it doesn't exist
|
||||
DO $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (SELECT 1 FROM information_schema.columns
|
||||
WHERE table_name = 'icon_customers' AND column_name = 'address') THEN
|
||||
ALTER TABLE icon_customers ADD COLUMN "address" text;
|
||||
END IF;
|
||||
END $$;
|
||||
@@ -0,0 +1,20 @@
|
||||
-- Database Schema Update for Expert Profiles
|
||||
|
||||
-- Check if the table 'icon_experts' exists and add the new columns
|
||||
-- 'hourlyRateOnsite' and 'hourlyRateRemote'.
|
||||
-- Using numeric(10, 2) is suitable for currency values.
|
||||
|
||||
DO $$
|
||||
BEGIN
|
||||
-- Add hourlyRateOnsite column if it doesn't exist
|
||||
IF NOT EXISTS (SELECT 1 FROM information_schema.columns
|
||||
WHERE table_name = 'icon_experts' AND column_name = 'hourlyRateOnsite') THEN
|
||||
ALTER TABLE icon_experts ADD COLUMN "hourlyRateOnsite" numeric(10, 2);
|
||||
END IF;
|
||||
|
||||
-- Add hourlyRateRemote column if it doesn't exist
|
||||
IF NOT EXISTS (SELECT 1 FROM information_schema.columns
|
||||
WHERE table_name = 'icon_experts' AND column_name = 'hourlyRateRemote') THEN
|
||||
ALTER TABLE icon_experts ADD COLUMN "hourlyRateRemote" numeric(10, 2);
|
||||
END IF;
|
||||
END $$;
|
||||
@@ -0,0 +1,18 @@
|
||||
-- Add updated_at column if it doesn't exist
|
||||
ALTER TABLE icon_experts ADD COLUMN IF NOT EXISTS updated_at TIMESTAMP WITH TIME ZONE DEFAULT timezone('utc'::text, now());
|
||||
|
||||
-- Function to handle updating the updated_at timestamp
|
||||
CREATE OR REPLACE FUNCTION update_updated_at_column()
|
||||
RETURNS TRIGGER AS $$
|
||||
BEGIN
|
||||
NEW.updated_at = timezone('utc'::text, now());
|
||||
RETURN NEW;
|
||||
END;
|
||||
$$ language 'plpgsql';
|
||||
|
||||
-- Trigger to execute the function before each update
|
||||
DROP TRIGGER IF EXISTS update_icon_experts_updated_at ON icon_experts;
|
||||
CREATE TRIGGER update_icon_experts_updated_at
|
||||
BEFORE UPDATE ON icon_experts
|
||||
FOR EACH ROW
|
||||
EXECUTE FUNCTION update_updated_at_column();
|
||||
Reference in New Issue
Block a user