-- Database initialization script for Kanba -- This script runs when the PostgreSQL container starts -- Create the database if it doesn't exist -- (This is handled by the POSTGRES_DB environment variable) -- Create extensions that might be useful CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; CREATE EXTENSION IF NOT EXISTS "pgcrypto"; -- Create a function to generate slugs CREATE OR REPLACE FUNCTION generate_slug(input_text TEXT) RETURNS TEXT AS $$ BEGIN RETURN lower( regexp_replace( regexp_replace( regexp_replace(input_text, '[^a-zA-Z0-9\s-]', '', 'g'), '\s+', '-', 'g' ), '-+', '-', 'g' ) ); END; $$ LANGUAGE plpgsql; -- Create a function to update updated_at timestamp CREATE OR REPLACE FUNCTION update_updated_at_column() RETURNS TRIGGER AS $$ BEGIN NEW.updated_at = now(); RETURN NEW; END; $$ LANGUAGE plpgsql; -- Log that initialization is complete DO $$ BEGIN RAISE NOTICE 'Kanba database initialization completed successfully!'; END $$;