Your SCMD project has been successfully upgraded from SQLite (tardigrade.db) to PostgreSQL!
-
go.mod - Added PostgreSQL dependencies:
github.com/lib/pq- PostgreSQL drivergithub.com/joho/godotenv- Environment variable management
-
database.go (NEW) - PostgreSQL database layer:
InitDB()- Initializes PostgreSQL connection from .envCloseDB()- Closes database connectionSearchCommands()- Searches commands with pattern matchingAddCommand()- Adds new commands to databaseCheckCommandExists()- Checks for duplicate commands
-
search.go - Updated CLI search:
- Removed tardigrade-mod dependency
- Now uses PostgreSQL SearchCommands()
- Maintains same output format
-
savecmd.go - Updated CLI save:
- Removed tardigrade-mod dependency
- Now uses PostgreSQL AddCommand()
- Improved error handling
-
server.go - Updated web interface:
- Removed tardigrade-mod dependency
- HomePage() now uses PostgreSQL for searches
- AddPage() now uses PostgreSQL for saving commands
- Database connection initialized at server startup
-
tools.go - Updated utility functions:
- Removed tardigrade-mod dependency
- copyDB() now shows pg_dump instructions
-
download.go - Updated download function:
- Now shows migration instructions instead of downloading tardigrade.db
- .env.example - Template for database configuration
- POSTGRESQL_MIGRATION.md - Detailed migration guide
- UPGRADE_SUMMARY.md - This file
- test_connection.go - Connection test utility
- interactive.go - NEW Interactive CLI mode with natural language support
- INTERACTIVE_MODE.md - Interactive mode documentation
- QUICKSTART.md - Quick start guide
- README.md - Updated with PostgreSQL information
Make sure your .env file has the correct PostgreSQL credentials:
DB_HOST=192.168.1.4
DB_PORT=5432
DB_USER=user_name
DB_PASS=password
DB_NAME=database_name
TB_NAME=scmdYou can test the PostgreSQL connection with:
go run test_connection.go database.goStart an interactive CLI session:
scmd.exe --interactive
# or
scmd.exe -iThen use natural language or commands:
scmd> provide me with postgresql replication example
scmd> /search docker,kubernetes
scmd> /add docker ps -a | List all containers
scmd> /list
scmd> exit
See INTERACTIVE_MODE.md for full documentation.
All existing commands work the same:
CLI Search:
scmd.exe --search "docker"
scmd.exe --search "docker,kubernetes"CLI Save:
scmd.exe --save "docker ps -a" "List all containers"Web Interface:
scmd.exe --web
scmd.exe --web -port 8080
scmd.exe --web -port 8080 -blockYour PostgreSQL table should have this structure:
CREATE TABLE scmd (
id SERIAL PRIMARY KEY,
key TEXT NOT NULL,
data TEXT NOT NULL
);Optional indexes for better performance:
CREATE INDEX idx_scmd_key ON scmd USING gin(to_tsvector('english', key));
CREATE INDEX idx_scmd_data ON scmd USING gin(to_tsvector('english', data));✓ Case-insensitive search - Uses PostgreSQL ILIKE ✓ Multiple pattern search - Comma-separated patterns ✓ Duplicate detection - Checks before inserting ✓ Connection pooling - Efficient database connections ✓ Error handling - Proper error logging ✓ Environment-based config - Easy deployment
- Update dependencies in go.mod
- Create PostgreSQL database layer
- Update CLI search functionality
- Update CLI save functionality
- Update web interface
- Remove tardigrade-mod dependencies
- Create configuration templates
- Update documentation
- Build and test compilation
- Test the connection - Run test_connection.go
- Test CLI search - Try searching for existing commands
- Test CLI save - Try adding a new command
- Test web interface - Start the web server and test search/add
- Monitor logs - Check scmdweb.log for any issues
- Verify PostgreSQL is running
- Check .env credentials
- Test with:
psql -h DB_HOST -p DB_PORT -U DB_USER -d DB_NAME
- Verify table name in .env matches your PostgreSQL table
- Check table exists:
\dtin psql
- Verify data was imported from tardigrade.db
- Check table has data:
SELECT COUNT(*) FROM scmd;
- Scalability - Handle millions of commands
- Concurrent access - Multiple users simultaneously
- Full-text search - Better search capabilities
- Backup/restore - Enterprise-grade tools
- Remote access - Access from anywhere
- ACID compliance - Data integrity guaranteed
The old tardigrade.db file is no longer used. All functionality remains the same from a user perspective - only the backend storage has changed.
For issues or questions:
- Check POSTGRESQL_MIGRATION.md for detailed migration info
- Review the .env.example for configuration reference
- Test connection with test_connection.go
- Check PostgreSQL logs for database errors