Open History to see the last commit
1-- Custom SQL migration file, put your code below! --
2
3-- Create a function to update the updated_at timestamp
4CREATE OR REPLACE FUNCTION update_updated_at_column()
5RETURNS TRIGGER AS $$
6BEGIN
7 NEW.updated_at = NOW();
8 RETURN NEW;
9END;
10$$ LANGUAGE plpgsql;
11
12-- Create trigger for todos table
13DROP TRIGGER IF EXISTS update_todos_updated_at ON "todos";
14CREATE TRIGGER update_todos_updated_at
15BEFORE UPDATE ON "todos"
16FOR EACH ROW
17EXECUTE FUNCTION update_updated_at_column();
18
19-- Create trigger for config table
20DROP TRIGGER IF EXISTS update_config_updated_at ON "config";
21CREATE TRIGGER update_config_updated_at
22BEFORE UPDATE ON "config"
23FOR EACH ROW
24EXECUTE FUNCTION update_updated_at_column();
25
26-- Insert default config for background color
27INSERT INTO "config" ("key", "value")
28VALUES ('backgroundColor', '#f5f5f5')
29ON CONFLICT ("key") DO NOTHING;