mirror of
https://github.com/scottlamb/moonfire-nvr.git
synced 2025-04-22 11:35:41 -04:00
rearrange check deletes to satisfy foreign key
Otherwise `moonfire-nvr check --delete-orphan-rows` can fail with this error: ``` I0305 113848.655 main moonfire_db::check] Deleting 2 recording rows E0305 113848.655 main moonfire_nvr] Exiting due to error: FOREIGN KEY constraint failed ``` The new order matches the online system's `db::raw::delete_recordings`.
This commit is contained in:
parent
9aa72fe670
commit
cb4f30b5a2
@ -171,9 +171,9 @@ pub fn run(conn: &mut rusqlite::Connection, opts: &Options) -> Result<i32, Error
|
|||||||
let tx = conn.transaction()?;
|
let tx = conn.transaction()?;
|
||||||
if !ctx.rows_to_delete.is_empty() {
|
if !ctx.rows_to_delete.is_empty() {
|
||||||
info!("Deleting {} recording rows", ctx.rows_to_delete.len());
|
info!("Deleting {} recording rows", ctx.rows_to_delete.len());
|
||||||
let mut d1 = tx.prepare("delete from recording where composite_id = ?")?;
|
let mut d1 = tx.prepare("delete from recording_playback where composite_id = ?")?;
|
||||||
let mut d2 = tx.prepare("delete from recording_playback where composite_id = ?")?;
|
let mut d2 = tx.prepare("delete from recording_integrity where composite_id = ?")?;
|
||||||
let mut d3 = tx.prepare("delete from recording_integrity where composite_id = ?")?;
|
let mut d3 = tx.prepare("delete from recording where composite_id = ?")?;
|
||||||
for &id in &ctx.rows_to_delete {
|
for &id in &ctx.rows_to_delete {
|
||||||
d1.execute(params![id.0])?;
|
d1.execute(params![id.0])?;
|
||||||
d2.execute(params![id.0])?;
|
d2.execute(params![id.0])?;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user