feat(backend): Add database initialization and seed data scripts (Phase 3)
Implemented complete database initialization and seed data system for Docker development environment. Changes: - Enhanced init-db.sql with PostgreSQL extensions (uuid-ossp, pg_trgm, btree_gin) - Created seed-data.sql with demo tenant, users, project, epics, stories, and tasks - Updated docker-compose.yml to mount both initialization scripts - Added DEMO-ACCOUNTS.md documentation with credentials and testing guide - Added test-db-init.ps1 PowerShell script for testing initialization Features: - Automatic demo data creation on first startup - 2 demo users (Owner and Developer with Demo@123456 password) - 1 demo project with realistic Epic/Story/Task hierarchy - Idempotent seed data (checks if data exists before inserting) - Multi-tenant structure with proper TenantId isolation - Detailed logging and error handling Demo Accounts: - owner@demo.com / Demo@123456 (Owner role) - developer@demo.com / Demo@123456 (Member role) Demo Project Data: - Tenant: Demo Company - Project: DEMO - Demo Project - Epic: User Authentication System - 2 Stories (Login Page, Registration Feature) - 7 Tasks (various statuses: Done, InProgress, Todo) Testing: - Run: .\scripts\test-db-init.ps1 - Or: docker-compose down -v && docker-compose up -d Documentation: See scripts/DEMO-ACCOUNTS.md for full details 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,17 +1,29 @@
|
||||
-- ============================================
|
||||
-- ColaFlow Database Initialization Script
|
||||
-- This script runs automatically when PostgreSQL container starts
|
||||
-- This script runs automatically when PostgreSQL container starts for the first time
|
||||
-- File: /docker-entrypoint-initdb.d/01-init-db.sql
|
||||
-- ============================================
|
||||
|
||||
-- Enable required extensions
|
||||
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
|
||||
CREATE EXTENSION IF NOT EXISTS "pg_trgm"; -- For full-text search
|
||||
CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; -- UUID generation functions
|
||||
CREATE EXTENSION IF NOT EXISTS "pg_trgm"; -- Full-text search support (trigram matching)
|
||||
CREATE EXTENSION IF NOT EXISTS "btree_gin"; -- GIN index optimization for multi-column queries
|
||||
|
||||
-- Create initial database schema
|
||||
-- Note: Actual schema will be created by EF Core migrations
|
||||
-- Grant all privileges on database
|
||||
GRANT ALL PRIVILEGES ON DATABASE colaflow TO colaflow;
|
||||
|
||||
-- Create test user for development
|
||||
-- Password: Test123! (BCrypt hashed)
|
||||
-- Output confirmation
|
||||
DO $$
|
||||
BEGIN
|
||||
-- Add any initial seed data here if needed
|
||||
RAISE NOTICE 'Database initialized successfully';
|
||||
RAISE NOTICE '========================================';
|
||||
RAISE NOTICE 'ColaFlow Database Initialized Successfully!';
|
||||
RAISE NOTICE '========================================';
|
||||
RAISE NOTICE 'Extensions installed:';
|
||||
RAISE NOTICE ' - uuid-ossp (UUID generation)';
|
||||
RAISE NOTICE ' - pg_trgm (Full-text search)';
|
||||
RAISE NOTICE ' - btree_gin (Index optimization)';
|
||||
RAISE NOTICE '';
|
||||
RAISE NOTICE 'Next: EF Core migrations will create schema';
|
||||
RAISE NOTICE 'Next: Seed data will populate demo accounts';
|
||||
RAISE NOTICE '========================================';
|
||||
END $$;
|
||||
|
||||
Reference in New Issue
Block a user