database-migration-docker

command
v0.8.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 3, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

README

Database Migration Docker Example

This example demonstrates that the database extension with migrations can now start successfully in Docker containers after the migration initialization fix.

The Problem (Before)

Applications using Forge's database extension would panic during startup in Docker with:

panic: stat .: no such file or directory
goroutine 1 [running]:
github.com/xraph/forge/extensions/database/migrate.init.0()

The Solution (After)

The fix makes migration discovery lazy and graceful, allowing applications to start successfully in any environment.

Testing the Fix

Run Locally
cd examples/database-migration-docker
go run main.go

Expected output:

✅ Application started successfully!
✅ This would have panicked before the fix!
✅ Database extension with migrations works in Docker/CI!
✅ Application stopped gracefully
Run in Docker
cd examples/database-migration-docker

# Build the Docker image
docker build -t migration-demo .

# Run the container
docker run --rm migration-demo

Expected output:

✅ Application started successfully!
✅ This would have panicked before the fix!
✅ Database extension with migrations works in Docker/CI!
✅ Application stopped gracefully

What Changed

Before Fix
  • init() function called DiscoverCaller() at package initialization
  • ❌ Filesystem access required before main() runs
  • ❌ Panic if working directory doesn't exist or isn't accessible
After Fix
  • ✅ Migration discovery is lazy (happens when actually needed)
  • ✅ Filesystem errors are logged but don't prevent startup
  • ✅ Applications start successfully in any environment
  • ✅ Fully backward compatible

Files Changed

  1. extensions/database/migrate/migrations.go - Core library fix
  2. cmd/forge/plugins/database.go - Template generation fix
  3. extensions/database/migrate/migrations_test.go - Comprehensive tests

Deployment Platforms

This fix ensures applications work on:

  • ✅ Docker / Podman
  • ✅ Kubernetes
  • ✅ Render.com
  • ✅ Fly.io
  • ✅ Railway
  • ✅ Google Cloud Run
  • ✅ AWS ECS/Fargate
  • ✅ Azure Container Instances
  • ✅ Any containerized platform

Technical Details

See the following documentation for more details:

  • MIGRATION_FIX_SUMMARY.md - Quick summary
  • MIGRATION_INITIALIZATION_FIX.md - Detailed technical documentation

Documentation

Overview

Package main demonstrates that the database extension with migrations can now start successfully in Docker/CI environments without panicking.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL