Initial commit: Clean Mold Cost Calculator application

- Flask-based mold cost calculation application
- PostgreSQL database with SQLAlchemy ORM
- Docker/Podman containerization
- Comprehensive documentation in docs/
- Clean, organized codebase without obsolete files
- Production-ready deployment configuration
- Enhanced pytest configuration with coverage reporting
- Master/Development branch structure
This commit is contained in:
Gan, Jimmy
2025-06-24 02:30:09 +08:00
commit 6c0d5a4e63
108 changed files with 15911 additions and 0 deletions
+44
View File
@@ -0,0 +1,44 @@
import os
import sys
import psycopg2
from pathlib import Path
def get_db_url():
"""Get database URL from environment variables."""
db_user = os.getenv('DB_USER', 'mold_user')
db_password = os.getenv('DB_PASSWORD', 'mold_password')
db_host = os.getenv('DB_HOST', 'localhost')
db_port = os.getenv('DB_PORT', '5434')
db_name = os.getenv('DB_NAME', 'mold_cost_calculator_dev')
return f"postgresql://{db_user}:{db_password}@{db_host}:{db_port}/{db_name}"
def run_migration():
# Get database URL from environment
db_url = get_db_url()
try:
# Connect to the database
conn = psycopg2.connect(db_url)
conn.autocommit = True
cur = conn.cursor()
# Read and execute the migration SQL
migration_file = Path(__file__).parent / 'update_mold_types.sql'
with open(migration_file, 'r') as f:
sql = f.read()
cur.execute(sql)
print("Migration completed successfully!")
except Exception as e:
print(f"Error running migration: {str(e)}")
sys.exit(1)
finally:
if 'cur' in locals():
cur.close()
if 'conn' in locals():
conn.close()
if __name__ == '__main__':
run_migration()