Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
039c550
Set map scale during map creation during scene import
daddo-intel Jan 13, 2026
96d26c5
Merge branch 'main' of https://github.com/open-edge-platform/scenescape
daddo-intel Jan 15, 2026
23f8d8d
Merge branch 'main' of https://github.com/open-edge-platform/scenescape
daddo-intel Jan 21, 2026
0968474
Merge branch 'main' of https://github.com/open-edge-platform/scenescape
daddo-intel Jan 22, 2026
491e473
Merge branch 'main' of https://github.com/open-edge-platform/scenescape
daddo-intel Jan 26, 2026
154c85b
Merge branch 'main' of https://github.com/open-edge-platform/scenescape
daddo-intel Jan 27, 2026
4254d2f
Merge branch 'main' of https://github.com/open-edge-platform/scenescape
daddo-intel Jan 27, 2026
90d0488
Merge branch 'main' of https://github.com/open-edge-platform/scenescape
daddo-intel Jan 27, 2026
7f2972d
Initial plan
Copilot Jan 29, 2026
7404b53
Remove makemigrations from runtime, add migrations dir to Dockerfile
Copilot Jan 29, 2026
9ea7448
Add Django migrations documentation and helper script
Copilot Jan 29, 2026
7c9a8be
Add CI/CD migration integration guide and update Agents.md
Copilot Jan 29, 2026
4e7645d
Add deprecation notices to legacy migration tools
Copilot Jan 29, 2026
1058846
Fix .gitignore to allow Django migrations and add migrations __init__.py
Copilot Jan 29, 2026
74adad9
Merge branch 'main' of https://github.com/open-edge-platform/scenescape
daddo-intel Jan 29, 2026
73361cf
Merge branch 'main' of https://github.com/open-edge-platform/scenescape
daddo-intel Feb 3, 2026
54fdfa8
Merge branch 'main' of https://github.com/open-edge-platform/scenescape
daddo-intel Feb 3, 2026
70058d8
Merge branch 'main' of https://github.com/open-edge-platform/scenescape
daddo-intel Feb 4, 2026
aab521e
Merge branch 'main' of https://github.com/open-edge-platform/scenescape
daddo-intel Feb 5, 2026
89f7bf4
Merge branch 'main' of https://github.com/open-edge-platform/scenescape
daddo-intel Feb 9, 2026
3a1e0a7
Merge branch 'main' of https://github.com/open-edge-platform/scenescape
daddo-intel Feb 11, 2026
b449578
Merge branch 'main' of https://github.com/open-edge-platform/scenescape
daddo-intel Feb 12, 2026
7797509
Merge branch 'main' of https://github.com/open-edge-platform/scenescape
daddo-intel Feb 13, 2026
9af0ff3
Merge branch 'main' of https://github.com/open-edge-platform/scenescape
daddo-intel Feb 17, 2026
39f818d
Merge branch 'main' of https://github.com/open-edge-platform/scenescape
daddo-intel Feb 17, 2026
26321bd
Merge branch 'main' of https://github.com/open-edge-platform/scenescape
daddo-intel Feb 18, 2026
a9417db
Merge branch 'main' of https://github.com/open-edge-platform/scenescape
daddo-intel Feb 22, 2026
a41ff1c
Merge branch 'main' of https://github.com/open-edge-platform/scenescape
daddo-intel Feb 25, 2026
6395dd2
Merge branch 'main' of https://github.com/open-edge-platform/scenescape
daddo-intel Feb 26, 2026
0636785
Merge branch 'main' of https://github.com/open-edge-platform/scenescape
daddo-intel Mar 2, 2026
2cb8972
Merge branch 'main' of https://github.com/open-edge-platform/scenescape
daddo-intel Mar 2, 2026
6ca8af4
Merge branch 'main' of https://github.com/open-edge-platform/scenescape
daddo-intel Mar 2, 2026
ab2920d
Merge branch 'main' of https://github.com/open-edge-platform/scenescape
daddo-intel Mar 5, 2026
fc7eb29
Merge branch 'main' into copilot/fix-django-migration-usage
daddo-intel Mar 5, 2026
b450181
Add initial migration file
daddo-intel Mar 5, 2026
6440fae
Manager file structure should match manager image
daddo-intel Mar 5, 2026
926cd88
Merge branch 'main' of https://github.com/open-edge-platform/scenescape
daddo-intel Mar 5, 2026
66a4582
Merge branch 'main' into fix/ITEP-88294-fix-database-migration-process
daddo-intel Mar 5, 2026
7fd8089
Restructure manager package layout (preserve history)
daddo-intel Mar 5, 2026
e0c3e22
Remove manager-2 backup folder
daddo-intel Mar 5, 2026
4de153f
Remove secrets.py
daddo-intel Mar 5, 2026
ddab550
Remove test migration fields
daddo-intel Mar 5, 2026
7aaac9f
Update Agents.md
daddo-intel Mar 5, 2026
3964b64
Remove debug statements
daddo-intel Mar 5, 2026
90a4bbc
Update print statements in generate_migrations.sh
daddo-intel Mar 5, 2026
84dbcd1
Fix missing copyright & licensing
daddo-intel Mar 5, 2026
186da28
Update REUSE.toml
daddo-intel Mar 5, 2026
c7d0b6c
Fix indentation for 0001_initial.py
daddo-intel Mar 5, 2026
276500b
Fix prettier-write
daddo-intel Mar 5, 2026
e52ddaf
Fix secrets path for tests
daddo-intel Mar 6, 2026
4bf11f2
Merge branch 'main' into fix/ITEP-88294-fix-database-migration-process
daddo-intel Mar 6, 2026
97ffa62
Merge branch 'main' into fix/ITEP-88294-fix-database-migration-process
daddo-intel Mar 9, 2026
86b96b3
Merge branch 'main' into fix/ITEP-88294-fix-database-migration-process
dmytroye Mar 9, 2026
61cfcd4
Merge branch 'main' into fix/ITEP-88294-fix-database-migration-process
dmytroye Mar 9, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ manager/src/static/assets
manager/src/static/bootstrap*
manager/src/static/examples
manager/secrets
manager/src/django/secrets.py
manager/src/manager/secrets.py
docker-compose.yml
kubernetes/setup/
kubernetes/manager
media
migrations
# Ignore runtime migrations directory (not Django source migrations)
/migrations
**/workspace/migrations
pvd-mqtt/detect
sample_data/xREF_*
test_data
Expand Down
2 changes: 1 addition & 1 deletion REUSE.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ version = 1
path = [
"docs/doxygen/Doxyfile.common",
"docs/doxygen/api_docs",
"manager/src/static/site.webmanifest",
"manager/src/manager/static/site.webmanifest",
"tests/security/fuzzing/token",
"**/*.env",
"**/mp4",
Expand Down
2 changes: 1 addition & 1 deletion docs/development/vscode-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Create `.vscode/settings.json` in the project root, or press `Ctrl+Shift+P` →
"python.terminal.activateEnvironment": true,
"python.analysis.extraPaths": [
"${workspaceFolder}",
"${workspaceFolder}/manager/src/django",
"${workspaceFolder}/manager/src/manager",
"${workspaceFolder}/tests",
"${workspaceFolder}/scene_common/src",
"${workspaceFolder}/controller/src",
Expand Down
2 changes: 1 addition & 1 deletion exclude_for_release.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ docs/doxygen/html
exclude_for_release.txt
model_installer/models
venv
manager/src/django/settings_local.py
manager/src/manager/settings_local.py
secrets
SECURITY.md
*.bundle
Expand Down
17 changes: 11 additions & 6 deletions manager/Agents.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ SPDX-License-Identifier: Apache-2.0

# Manager Service - AI Agent Guide

## Documentation

- [MIGRATIONS.md](MIGRATIONS.md) - Django migrations workflow and best practices

## Service Overview

The **Manager** service is the Django-based web UI and REST API gateway for Intel® SceneScape. It provides user-facing interfaces for system configuration, scene management, camera setup, and PostgreSQL-backed persistence for metadata and configuration.
Expand All @@ -15,13 +19,13 @@ The **Manager** service is the Django-based web UI and REST API gateway for Inte

### Core Modules

1. **Django Application** (`src/django/`):
1. **Django Application** (`src/manager/`):
- Scene management views and APIs
- Camera configuration interfaces
- User authentication and authorization
- PostgreSQL ORM models

2. **REST API** (`src/django/api/`):
2. **REST API** (`src/manager/api/`):
- RESTful endpoints for external integrations
- Scene CRUD operations
- Camera calibration triggers
Expand Down Expand Up @@ -225,11 +229,12 @@ class Camera(models.Model):

### Adding New Database Model

1. Define model in `src/django/scenescape/models.py`
1. Define model in `src/manager/models.py`
2. Create migration: `docker compose exec manager python manage.py makemigrations`
3. Review migration file in `src/django/scenescape/migrations/`
4. Apply: `docker compose exec manager python manage.py migrate`
5. Update admin interface if needed: `src/django/scenescape/admin.py`
3. Review migration file in `src/manager/migrations/`
4. Commit migration file to version control
5. Apply: `docker compose exec manager python manage.py migrate`
6. Update admin interface if needed: `src/manager/admin.py`

### Modifying Web UI

Expand Down
12 changes: 3 additions & 9 deletions manager/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,9 @@ RUN : \

# Copy application code
RUN mkdir -p $SCENESCAPE_HOME/manager
COPY ./manager/src/django/*.py \
./manager/src/setup.py \
./version.txt $SCENESCAPE_HOME/manager/
COPY ./manager/src/django/ppl_generator/* $SCENESCAPE_HOME/manager/ppl_generator/
COPY ./manager/src/management/ $SCENESCAPE_HOME/manager/management
COPY ./manager/src/templates/ $SCENESCAPE_HOME/manager/templates
COPY ./manager/src/static/ $SCENESCAPE_HOME/manager/static
COPY ./manager/src/templatetags/ $SCENESCAPE_HOME/manager/templatetags
COPY ./manager/src/django/manage.py $SCENESCAPE_HOME
COPY ./manager/src/manager $SCENESCAPE_HOME/manager
COPY ./manager/src/manage.py $SCENESCAPE_HOME/manage.py
COPY ./version.txt $SCENESCAPE_HOME/manager/
COPY --from=scenescape-manager-builder /usr/local/lib/python3.11/site-packages/fast_geometry /usr/local/lib/python3.11/site-packages/fast_geometry
COPY --from=scenescape-manager-builder /usr/local/lib/python3.11/site-packages/scene_common /usr/local/lib/python3.11/site-packages/scene_common

Expand Down
180 changes: 180 additions & 0 deletions manager/MIGRATIONS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
# SPDX-FileCopyrightText: (C) 2025 Intel Corporation

# SPDX-License-Identifier: Apache-2.0

# Django Migrations Guide

## Overview

SceneScape uses Django's migration system to manage database schema changes. Migration files are version-controlled and applied at runtime to ensure consistent database upgrades across releases.

## Important: Proper Migration Usage

**DO NOT** run `makemigrations` at runtime or in production. Migrations should be:

1. Generated during development
2. Reviewed and tested
3. Committed to version control
4. Built into the Docker image
5. Applied at runtime via `migrate` only

## Creating Migrations

### For Local Development

When you modify Django models in `src/manager/models.py`, follow these steps:

1. **Make your model changes** in `src/manager/models.py`

2. **Generate migration file** using the generate_migrations.sh script:

```bash
bash manager/tools/generate_migrations.sh
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On clear repo, without scenescape deployed it is failing. I suggesting adding pre-requirements in readme with minimal requirements.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I deployed scenescape. But when I run script I got errors about unable to connect to postgres.

==> Django Migration Generator for SceneScape Manager

/usr/local/lib/python3.11/site-packages/django/core/management/commands/makemigrations.py:161: RuntimeWarning: Got an error checking a consistent migration history performed for database connection 'default': connection to server at "localhost" (::1), port 5432 failed: Connection refused
        Is the server running on that host and accepting TCP/IP connections?
connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused
        Is the server running on that host and accepting TCP/IP connections?

  warnings.warn(
Intel® SceneScape version.txt file not found.
No changes detected in app 'manager'
==> Migrations can be found at /home/labrat/scenescape-review/manager/src/manager/migrations

==> Migration files generated in manager/src/manager/migrations/

```

3. **Review the generated migration** in `src/manager/migrations/`:

```bash
ls -la manager/src/manager/migrations/
```

4. ** Re-build manager**

```bash
make manager
```

5. **Verify the migration is being applied **:

```bash
docker compose down web && docker compose up web
```

6. **Check migration status**:

```bash
bash manager/tools/generate_migrations.sh --show --network scenescape_scenescape --dbhost pgserver --dbport 5432
```

7. **Commit the migration file** to version control:
```bash
git add manager/src/manager/migrations/XXXX_*.py
git commit -m "Add migration for [describe changes]"
```

### For CI/CD and Release Process

Migration generation should be automated as part of the release build:

1. **In CI/CD pipeline**, after model changes are merged:

```bash
# If migrations are needed, generate them
bash manager/tools/generate_migrations.sh

# Build the manager image
make manager

# Review migrations
manager/src/manager/migrations

# Commit and push the generated migrations
git add manager/src/manager/migrations/
git commit -m "Generate migrations for release"
git push
```

2. **Rebuild the image** with the new migrations included

## Migration Naming Convention

Django automatically names migrations as:

- `0001_initial.py` - Initial schema
- `0002_<description>.py` - Subsequent changes
- `0003_<description>.py` - More changes
- etc.

For releases, you may want to include version information in the description:

```bash
docker compose exec manager python manage.py makemigrations manager --name release_2026_1_0
```

This creates: `0002_release_2026_1_0.py`

## Applying Migrations

Migrations are applied automatically at container startup via the `migrate` command in `config/scenescape-init`.

To manually apply migrations:

```bash
docker exec -it -w /home/scenescape/SceneScape scenescape-web-1 \
python manage.py migrate
```

## Checking Migration Status

View all migrations and their application status:

```bash
docker exec -it -w /home/scenescape/SceneScape scenescape-web-1 \
python manage.py showmigrations
```

Example output:

```
manager
[X] 0001_initial
[X] 0002_release_2026_1_0
[ ] 0003_add_new_field
```

## Troubleshooting

### Migration conflicts

If multiple developers create migrations in parallel:

1. Merge the code
2. Run `makemigrations --merge` to create a merge migration
3. Test the merge migration
4. Commit the merge migration file

### Reverting migrations

```bash
# Revert to a specific migration
docker exec -it -w /home/scenescape/SceneScape scenescape-web-1 \
python manage.py migrate manager 0001_initial

# Revert all migrations for an app
docker exec -it -w /home/scenescape/SceneScape scenescape-web-1 \
python manage.py migrate manager zero
```

### Fake migrations

In rare cases (like database schema already matches):

```bash
docker exec -it -w /home/scenescape/SceneScape scenescape-web-1 \
python manage.py migrate manager --fake
```

## Best Practices

1. **Always review generated migrations** before committing
2. **Test migrations** on a copy of production data
3. **Keep migrations small** - one logical change per migration
4. **Never edit applied migrations** - create a new migration instead
5. **Document complex migrations** with comments in the migration file
6. **Backup database** before applying migrations in production

## References

- [Django Migrations Documentation](https://docs.djangoproject.com/en/5.2/topics/migrations/)
- [Django makemigrations Command](https://docs.djangoproject.com/en/5.2/ref/django-admin/#makemigrations)
- [Django migrate Command](https://docs.djangoproject.com/en/5.2/ref/django-admin/#migrate)
2 changes: 1 addition & 1 deletion manager/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ RUNTIME_OS_IMAGE = python:3.11-slim-bookworm
TARGET = scenescape-manager-runtime
SHELL = /bin/bash
CERTDOMAIN = scenescape.intel.com
JSLIBDIR = src/static
JSLIBDIR = src/manager/static
CURL_FLAGS = --connect-timeout 5 --max-time 120 --retry 5 --retry-delay 0
FORCE_VAAPI ?= 0
THREEJS_VERSION = 168
Expand Down
31 changes: 18 additions & 13 deletions manager/config/scenescape-init
Original file line number Diff line number Diff line change
Expand Up @@ -244,21 +244,26 @@ fi
export -n DBPASS SUPASS

if [ -n "$DBTYPE" ]; then
cd ${MANAGERDIR}
# Determine "first run" using the marker (or another check)
CREATEDB=0
MIGRATIONS=${DBROOT}/migrations/__init__.py
if [ ! -e ${MIGRATIONS} ] ; then
CREATEDB=1
MIGRATIONS_MARKER="${DBROOT}/migrations/__init__.py"
if [ ! -e "${MIGRATIONS_MARKER}" ]; then
CREATEDB=1
mkdir -p "$(dirname "${MIGRATIONS_MARKER}")"
touch "${MIGRATIONS_MARKER}"
fi
Comment on lines +250 to 254
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The if [ ! -e "${MIGRATIONS_MARKER}" ] block is missing indentation for its body (CREATEDB/mkdir/touch). Shell will still run, but this makes it easy to misread and is inconsistent with the rest of the script. Indent the body of the if consistently.

Copilot uses AI. Check for mistakes.
if [ ${CREATEDB} = 1 ] ; then
mkdir -p ${DBROOT}/migrations
touch ${MIGRATIONS}
echo "Checking if database is empty..."
if ! (./manage.py showmigrations | grep -q '\[X\]'); then
echo "Database is empty — running initial migrations..."
(./manage.py makemigrations manager)
(./manage.py migrate)
fi

# ALWAYS apply migrations
cd ${MANAGERDIR}
echo "==> Applying pending migrations..."
./manage.py migrate --noinput

if [ "${CREATEDB}" -eq 1 ] && [ -n "${EXAMPLEDB:-}" ]; then
echo "==> Preloading example DB..."
mkdir -p "${DBROOT}/media"
tar -C "${DBROOT}/media" -xf "${EXAMPLEDB}"
./manage.py loaddata "${DBROOT}/media/data.json"
rm -f "${DBROOT}/media/data.json" "${DBROOT}/media/meta.json"
fi
Comment on lines +261 to 267
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new migration preloading block will run on first start when EXAMPLEDB is set, but the legacy preload block later in this script still exists (further down, inside if [ ${CREATEDB} = 1 ]). That results in loaddata/tar extraction being executed twice on first run. Remove the older preload block or consolidate into a single code path.

Copilot uses AI. Check for mistakes.

./manage.py updatedbstatus --not-ready
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading
Loading