blakeblackshear / frigate

NVR with realtime local object detection for IP cameras
https://frigate.video
MIT License
19.2k stars 1.76k forks source link

[Support]: Is migration twice handled? #7844

Closed PovilasID closed 1 year ago

PovilasID commented 1 year ago

Describe the problem you are having

TL;DR I did migration from 0.12->0.13->0.12-0.13 and the last one failed.

Migrating from 0.12 to 0.13 looked ok but I after adding global audio configs config looked to cause a crash even after removing audio section manually from a file, so I tried to revert to 0.12 and it worked... except all the events were missing, so I tried switching back to 0.13 and I got error. Log is bellow.

Looks like it tries to migrate a table that is already there. There are multiple ways to fix it either in SQL or python by including a check for exitance of table or modifying the current merge to

Version

0.13.0

Frigate config file

mqtt:
  host: localhost

ffmpeg:
  hwaccel_args: preset-vaapi

go2rtc:
  streams:
    durys:
      - rtsp://192.168.2.179:554/Streaming/Channels/101
    durys_sub:
      - rtsp://192.168.2.179:554/Streaming/Channels/102
    siltnamis:
      - rtsp://192.168.2.210:554/cam/realmonitor?channel=1&subtype=0&authbasic=64
    kamera1:
      - rtsp://192.168.2.191:554/cam/realmonitor?channel=1&subtype=0&authbasic=64
      - "ffmpeg:kamera1#video=h264#hardware#audio=opus"

cameras:
  # # Stable detection
  durys:
    ffmpeg:
      inputs:
        - path: rtsp://192.168.2.179:554/Streaming/Channels/101
          roles:
            - record
            - detect
    record:
      enabled: true
      retain:
        days: 3
        # mode: motion # Keeps only motion parts in an hour
        mode: all
      events:
        pre_capture: 15
        post_capture: 15
    detect:
      width: 1920
      height: 1080
      max_disappeared: 50
    objects:
      track:
        - person
        - car
        - bicycle
    motion:
      threshold: 20 # when recording only motion allows to tune how little/much motion  
      mask:
        - 0,1080,338,1080,315,680,0,495
    snapshots:
      enabled: True
      timestamp: True
      bounding_box: True
      retain:
        objects:
          person: 15
    zones:
      sodas:
        coordinates: 1670,351,1920,1080,0,1080,0,87

  siltnamis:
    ffmpeg:
      inputs:
        - path: rtsp://192.168.2.210:554/cam/realmonitor?channel=1&subtype=0&authbasic=64
          roles:
            #- record
            - detect
    record:
      enabled: true
      retain:
        days: 3
        # mode: motion # Keeps only motion parts in an hour
        mode: all
    detect:
      width: 2304
      height: 1296
    objects:
      track:
        - person
        - car
    snapshots:
      enabled: True
      timestamp: True
      bounding_box: True
      retain:
        objects:
          person: 15

  kamera1:
    ffmpeg:
      inputs:
        - path: rtsp://192.168.2.191:554/cam/realmonitor?channel=1&subtype=0&authbasic=64
          roles:
            - record
            - detect
    ui:
      order: 3
      dashboard: True
    record:
      enabled: true

    detect:
      width: 1920
      height: 1080
    objects:
      track:
        - person

timestamp_style:
  # Optional: Position of the timestamp (default: shown below)
  #           "tl" (top left), "tr" (top right), "bl" (bottom left), "br" (bottom right)
  position: "tl"
  # Optional: Format specifier conform to the Python package "datetime" (default: shown below)
  #           Additional Examples:
  #             german: "%d.%m.%Y %H:%M:%S"
  format: "%Y-%m-%d %H:%M:%S"

detectors:
  ov:
    type: openvino
    device: AUTO
    model:
      path: /openvino-model/ssdlite_mobilenet_v2.xml

model:
  width: 300
  height: 300
  input_tensor: nhwc
  input_pixel_format: bgr
  labelmap_path: /openvino-model/coco_91cl_bkgr.txt

Relevant log output

[2023-09-17 01:06:32] peewee_migrate.logs            INFO    : Migrate "014_event_updates_for_fp"
2023-09-16 22:06:32.983659146  [2023-09-17 01:06:32] peewee_migrate.logs            INFO    : add_column ('event', 'score', <FloatField: Event.score>)
2023-09-16 22:06:32.984800080  duplicate column name: score
2023-09-16 22:06:32.984968293  [2023-09-17 01:06:32] peewee_migrate.logs            ERROR   : Migration failed: 014_event_updates_for_fp
2023-09-16 22:06:32.984970514  Traceback (most recent call last):
2023-09-16 22:06:32.984975412    File "/usr/local/lib/python3.9/dist-packages/peewee.py", line 3251, in execute_sql
2023-09-16 22:06:32.984977248      cursor.execute(sql, params or ())
2023-09-16 22:06:32.984978800  sqlite3.OperationalError: duplicate column name: score
2023-09-16 22:06:32.984980542
2023-09-16 22:06:32.984982068  During handling of the above exception, another exception occurred:
2023-09-16 22:06:32.984992307
2023-09-16 22:06:32.984993629  Traceback (most recent call last):
2023-09-16 22:06:32.984995298    File "/usr/local/lib/python3.9/dist-packages/peewee_migrate/router.py", line 200, in run_one
2023-09-16 22:06:32.984996492      migrator()
2023-09-16 22:06:32.984998045    File "/usr/local/lib/python3.9/dist-packages/peewee_migrate/migrator.py", line 76, in __call__
2023-09-16 22:06:32.985009085      op.run()
2023-09-16 22:06:32.985010767    File "/usr/local/lib/python3.9/dist-packages/playhouse/migrate.py", line 165, in run
2023-09-16 22:06:32.985012498      self._handle_result(method(*self.args, **kwargs))
2023-09-16 22:06:32.985014084    File "/usr/local/lib/python3.9/dist-packages/playhouse/migrate.py", line 159, in _handle_result
2023-09-16 22:06:32.985020552      self._handle_result(item)
2023-09-16 22:06:32.985021745    File "/usr/local/lib/python3.9/dist-packages/playhouse/migrate.py", line 156, in _handle_result
2023-09-16 22:06:32.985022681      result.run()
2023-09-16 22:06:32.985023800    File "/usr/local/lib/python3.9/dist-packages/playhouse/migrate.py", line 165, in run
2023-09-16 22:06:32.985024794      self._handle_result(method(*self.args, **kwargs))
2023-09-16 22:06:32.985030997    File "/usr/local/lib/python3.9/dist-packages/playhouse/migrate.py", line 154, in _handle_result
2023-09-16 22:06:32.985032090      self.execute(result)
2023-09-16 22:06:32.985033285    File "/usr/local/lib/python3.9/dist-packages/playhouse/migrate.py", line 150, in execute
2023-09-16 22:06:32.985034378      self.migrator.database.execute(node)
2023-09-16 22:06:32.985035530    File "/usr/local/lib/python3.9/dist-packages/peewee.py", line 3259, in execute
2023-09-16 22:06:32.985036511      return self.execute_sql(sql, params)
2023-09-16 22:06:32.985037621    File "/usr/local/lib/python3.9/dist-packages/peewee.py", line 3251, in execute_sql
2023-09-16 22:06:32.985043963      cursor.execute(sql, params or ())
2023-09-16 22:06:32.985045093    File "/usr/local/lib/python3.9/dist-packages/peewee.py", line 3019, in __exit__
2023-09-16 22:06:32.985046096      reraise(new_type, new_type(exc_value, *exc_args), traceback)
2023-09-16 22:06:32.985047123    File "/usr/local/lib/python3.9/dist-packages/peewee.py", line 192, in reraise
2023-09-16 22:06:32.985048162      raise value.with_traceback(tb)
2023-09-16 22:06:32.985049264    File "/usr/local/lib/python3.9/dist-packages/peewee.py", line 3251, in execute_sql
2023-09-16 22:06:32.985050247      cursor.execute(sql, params or ())
2023-09-16 22:06:32.985051243  peewee.OperationalError: duplicate column name: score
2023-09-16 22:06:34.228654686  [INFO] Service Frigate exited with code 1 (by signal 0)

FFprobe output from your camera

---

Frigate stats

No response

Operating system

Other

Install method

Docker Compose

Coral version

CPU (no coral)

Network connection

Wired

Camera make and model

Dahua, hikvision, amcrest

Any other information that may be helpful

No response

NickM-27 commented 1 year ago

This is covered in the release notes, downgrading is not supported without restoring a backup of the db or deleting the db and starting fresh.