4 Commits
0.3.2 ... 0.3.4

Author SHA1 Message Date
c66b57f9cb release: version 0.3.4 🚀 2026-04-05 00:19:31 +02:00
ba30f84f49 fix: fix database init, refs NOISSUE 2026-04-05 00:19:29 +02:00
81935daaf5 release: version 0.3.3 🚀 2026-04-04 23:53:04 +02:00
d2260ac797 fix: fix runtime errors, refs NOISSUE 2026-04-04 23:53:02 +02:00
6 changed files with 109 additions and 15 deletions

View File

@@ -5,10 +5,32 @@ Changelog
(unreleased) (unreleased)
------------ ------------
Fix
~~~
- Fix database init, refs NOISSUE. [Simon Diesenreiter]
0.3.3 (2026-04-04)
------------------
Fix
~~~
- Fix runtime errors, refs NOISSUE. [Simon Diesenreiter]
Other
~~~~~
0.3.2 (2026-04-04)
------------------
Fix Fix
~~~ ~~~
- Add back DB init endpoints, ref NOISSUE. [Simon Diesenreiter] - Add back DB init endpoints, ref NOISSUE. [Simon Diesenreiter]
Other
~~~~~
0.3.1 (2026-04-04) 0.3.1 (2026-04-04)
------------------ ------------------

View File

@@ -0,0 +1 @@
{"dark_mode":false}

View File

@@ -1 +1 @@
0.3.2 0.3.4

View File

@@ -39,14 +39,14 @@ def create_dashboard():
return return
# Create main card # Create main card
with ui.card().col().classes('w-full max-w-6xl mx-auto').props('elevated').style('max-width: 1200px; margin: 0 auto;') as main_card: with ui.card().classes('w-full max-w-6xl mx-auto').props('elevated').style('max-width: 1200px; margin: 0 auto;') as main_card:
# Header section # Header section
with ui.row().classes('items-center gap-4 mb-6').style('padding: 20px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); border-radius: 12px; color: white;') as header_row: with ui.row().classes('items-center gap-4 mb-6').style('padding: 20px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); border-radius: 12px; color: white;') as header_row:
title = ui.label('AI Software Factory').style('font-size: 28px; font-weight: bold; margin: 0;') title = ui.label('AI Software Factory').style('font-size: 28px; font-weight: bold; margin: 0;')
subtitle = ui.label('Real-time Dashboard & Audit Trail Display').style('font-size: 14px; opacity: 0.9; margin-top: 5px;') subtitle = ui.label('Real-time Dashboard & Audit Trail Display').style('font-size: 14px; opacity: 0.9; margin-top: 5px;')
# Stats grid # Stats grid
with ui.grid(columns=4, cols=4).props('gutter=1').style('margin-top: 15px;') as stats_grid: with ui.grid(columns=4).props('gutter=1').style('margin-top: 15px;') as stats_grid:
# Current Project # Current Project
with ui.column().classes('text-center').style('background: rgba(255, 255, 255, 0.1); padding: 15px; border-radius: 8px;') as card1: with ui.column().classes('text-center').style('background: rgba(255, 255, 255, 0.1); padding: 15px; border-radius: 8px;') as card1:
ui.label('Current Project').style('font-size: 12px; text-transform: uppercase; opacity: 0.8;') ui.label('Current Project').style('font-size: 12px; text-transform: uppercase; opacity: 0.8;')

View File

@@ -1,6 +1,6 @@
"""Database connection and session management.""" """Database connection and session management."""
from sqlalchemy import create_engine, event from sqlalchemy import create_engine, text
from sqlalchemy.orm import sessionmaker, Session from sqlalchemy.orm import sessionmaker, Session
from config import settings from config import settings
from models import Base from models import Base
@@ -92,18 +92,86 @@ def get_db_session() -> Session:
return session return session
def init_db() -> None: def init_db() -> dict:
"""Initialize database tables.""" """Initialize database tables and database if needed."""
if settings.USE_SQLITE:
# SQLite - auto-creates file and tables
engine = get_engine() engine = get_engine()
try:
Base.metadata.create_all(bind=engine) Base.metadata.create_all(bind=engine)
print("Database tables created successfully.") print("SQLite database tables created successfully.")
return {'status': 'success', 'message': 'SQLite database initialized.'}
except Exception as e:
print(f"Error initializing SQLite database: {str(e)}")
return {'status': 'error', 'message': f'Error: {str(e)}'}
else:
# PostgreSQL
db_url = settings.POSTGRES_URL or settings.database_url
db_name = db_url.split('/')[-1] if '/' in db_url else 'ai_software_factory'
try:
# Create engine to check/create database
engine = create_engine(db_url)
# Try to create database if it doesn't exist
try:
with engine.connect() as conn:
# Check if database exists
result = conn.execute(text(f"SELECT 1 FROM {db_name} WHERE 1=0"))
# If no error, database exists
conn.commit()
print(f"PostgreSQL database '{db_name}' already exists.")
except Exception as e:
# Database doesn't exist or has different error - try to create it
error_msg = str(e).lower()
# Only create if it's a relation does not exist error or similar
if "does not exist" in error_msg or "database" in error_msg:
try:
conn = engine.connect()
conn.execute(text(f"CREATE DATABASE {db_name}"))
conn.commit()
print(f"PostgreSQL database '{db_name}' created.")
except Exception as db_error:
print(f"Could not create database: {str(db_error)}")
# Try to connect anyway - maybe using existing db name
engine = create_engine(db_url.replace(f'/{db_name}', '/postgres'))
with engine.connect() as conn:
# Just create tables in postgres database for now
print(f"Using existing 'postgres' database.")
# Create tables
Base.metadata.create_all(bind=engine)
print(f"PostgreSQL database '{db_name}' tables created successfully.")
return {'status': 'success', 'message': f'PostgreSQL database "{db_name}" initialized.'}
except Exception as e:
print(f"Error initializing PostgreSQL database: {str(e)}")
return {'status': 'error', 'message': f'Error: {str(e)}'}
def drop_db() -> None: def drop_db() -> dict:
"""Drop all database tables (use with caution!).""" """Drop all database tables (use with caution!)."""
if settings.USE_SQLITE:
engine = get_engine() engine = get_engine()
try:
Base.metadata.drop_all(bind=engine) Base.metadata.drop_all(bind=engine)
print("Database tables dropped successfully.") print("SQLite database tables dropped successfully.")
return {'status': 'success', 'message': 'SQLite tables dropped.'}
except Exception as e:
print(f"Error dropping SQLite tables: {str(e)}")
return {'status': 'error', 'message': str(e)}
else:
db_url = settings.POSTGRES_URL or settings.database_url
db_name = db_url.split('/')[-1] if '/' in db_url else 'ai_software_factory'
try:
engine = create_engine(db_url)
Base.metadata.drop_all(bind=engine)
print(f"PostgreSQL database '{db_name}' tables dropped successfully.")
return {'status': 'success', 'message': f'PostgreSQL "{db_name}" tables dropped.'}
except Exception as e:
print(f"Error dropping PostgreSQL tables: {str(e)}")
return {'status': 'error', 'message': str(e)}
def create_migration_script() -> str: def create_migration_script() -> str:

View File

@@ -27,8 +27,11 @@ def read_root():
@app.post('/init-db') @app.post('/init-db')
def initialize_database(): def initialize_database():
"""Initialize database tables (POST endpoint for NiceGUI to call before dashboard).""" """Initialize database tables (POST endpoint for NiceGUI to call before dashboard)."""
try:
init_db() init_db()
return {'message': 'Database initialized successfully'} return {'message': 'Database tables created successfully', 'status': 'success'}
except Exception as e:
return {'message': f'Error initializing database: {str(e)}', 'status': 'error'}
frontend.init(app) frontend.init(app)