diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 285c4dc..e0d27ac 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -72,8 +72,9 @@ Note: Syncfusion usage in the dashboard is already documented above; if a UI for - Dashboard (dev): `dashboard/Dockerfile.dev` exposes :5173 and waits for API via `dashboard/wait-for-backend.sh`. - Mosquitto: allows anonymous in dev; WebSocket on :9001. - Common env vars: `DB_CONN`, `DB_USER`, `DB_PASSWORD`, `DB_HOST=db`, `DB_NAME`, `ENV`, `MQTT_USER`, `MQTT_PASSWORD`. -- Alembic: prod compose runs `alembic ... upgrade head` and `server/init_defaults.py` before gunicorn. - - Use `server/init_academic_periods.py` to populate default Austrian school years after migration. + - Alembic: prod compose runs `alembic ... upgrade head` and `server/init_defaults.py` before gunicorn. + - Local dev: prefer `python server/initialize_database.py` for one-shot setup (migrations + defaults + academic periods). + - `server/init_academic_periods.py` remains available to (re)seed school years. ## Production - `docker-compose.prod.yml` uses prebuilt images (`ghcr.io/robbstarkaustria/*`). @@ -100,6 +101,7 @@ Note: Syncfusion usage in the dashboard is already documented above; if a UI for 4) Return JSON-safe values (serialize enums and datetimes). - When extending media types, update `MediaType` and any logic in `eventmedia` and dashboard that depends on it. - Academic periods: Events/media can be optionally associated with periods for educational organization. Only one period should be active at a time (`is_active=True`). + - Initialization scripts: legacy DB init scripts were removed; use Alembic and `initialize_database.py` going forward. ## Quick examples - Add client description persists to DB and publishes group via MQTT: see `PUT /api/clients//description` in `routes/clients.py`. diff --git a/README.md b/README.md index ec3160f..0e823d9 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ A comprehensive multi-service digital signage solution for educational instituti 1. **Clone the repository** ```bash - git clone + git clone https://github.com/RobbStarkAustria/infoscreen_2025.git cd infoscreen_2025 ``` @@ -98,7 +98,13 @@ A comprehensive multi-service digital signage solution for educational instituti # or: docker compose up -d --build ``` -4. **Access the services** +4. **Initialize the database (first run only)** + ```bash + # One-shot: runs all Alembic migrations, creates default admin/group, and seeds academic periods + python server/initialize_database.py + ``` + +5. **Access the services** - Dashboard: http://localhost:5173 - API: http://localhost:8000 - Database: localhost:3306 @@ -177,6 +183,7 @@ infoscreen_2025/ │ ├── routes/ # API endpoints │ ├── alembic/ # Database migrations │ ├── media/ # File storage +│ ├── initialize_database.py # All-in-one DB initialization (dev) │ └── worker.py # Background jobs ├── listener/ # MQTT listener service ├── scheduler/ # Event scheduling service @@ -213,6 +220,9 @@ make fix-perms # Fix file permissions ### Database Management ```bash +# One-shot initialization (schema + defaults + academic periods) +python server/initialize_database.py + # Access database directly docker exec -it infoscreen-db mysql -u${DB_USER} -p${DB_PASSWORD} ${DB_NAME} diff --git a/connect_to_github.sh b/connect_to_github.sh deleted file mode 100755 index e1f3020..0000000 --- a/connect_to_github.sh +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/bash -# Script to connect this workspace to your existing GitHub repository - -echo "🔗 Connecting workspace to GitHub repository..." -echo "=================================================" - -# Check if repository name is provided -if [ -z "$1" ]; then - echo "❌ Error: Repository name required" - echo "" - echo "Usage: $0 " - echo "" - echo "Examples:" - echo " $0 infoscreen_2025" - echo " $0 infoscreen-2025" - echo " $0 infoscreen_server_2025" - echo "" - echo "Your GitHub username appears to be: robbstarkaustria" - exit 1 -fi - -REPO_NAME="$1" -GITHUB_USER="robbstarkaustria" -REPO_URL="https://github.com/${GITHUB_USER}/${REPO_NAME}.git" - -echo "Repository: ${REPO_URL}" -echo "" - -# Add the remote origin -echo "🔄 Adding remote origin..." -git remote add origin "$REPO_URL" - -if [ $? -eq 0 ]; then - echo "✅ Remote origin added successfully" -else - echo "⚠️ Remote might already exist, removing and re-adding..." - git remote remove origin 2>/dev/null - git remote add origin "$REPO_URL" -fi - -# Show current remotes -echo "" -echo "📋 Current remotes:" -git remote -v - -echo "" -echo "🔄 Fetching from remote repository..." -git fetch origin - -echo "" -echo "🔄 Setting upstream and pushing..." -git branch --set-upstream-to=origin/main main - -# Try to push (might require authentication) -echo "" -echo "🚀 Pushing to GitHub..." -echo "Note: You may need to authenticate with GitHub" -git push -u origin main - -if [ $? -eq 0 ]; then - echo "" - echo "🎉 Successfully connected and pushed to GitHub!" - echo "Repository URL: https://github.com/${GITHUB_USER}/${REPO_NAME}" -else - echo "" - echo "⚠️ Push failed. This might be because:" - echo "1. You need to authenticate with GitHub" - echo "2. The repository doesn't exist" - echo "3. You don't have push permissions" - echo "" - echo "Try running: git push -u origin main" - echo "Or use GitHub CLI: gh auth login" -fi \ No newline at end of file