flownexus-lwm2m / flownexus

IoT server with LwM2M support
https://flownexus-lwm2m.github.io/flownexus
Apache License 2.0
3 stars 2 forks source link

Error while running the ./django_startup.sh script #35

Closed Kappuccino111 closed 5 months ago

Kappuccino111 commented 5 months ago

Replication: To replicate the issue , first remove the existing database through rm -rf db.sqlite3. Run the script. Stop the script. Re-running the script produces this error :

sqlite3.IntegrityError: UNIQUE constraint failed: sensordata_resourcetype.object_id, sensordata_resourcetype.resource_id

Fix : After the fixture gets loaded into the database for the first time , we add a condition to check whether the data has already been loaded through a custom script since the sensordata_resourcetype has a unique constraint.

@jonas-rem were you deleting db.sqlite3 to run this script again ??

jonas-rem commented 5 months ago

When executing the script, we can check if the database exist or not. Only if the database is newly created we need to add the initialization data.

Deleting the database is usually not required and should not be part of the script. This can be required for testing or if the database model significantly changed.