02-remove-invalid.sql 698 B

1234567891011121314151617181920
  1. -- Copyright (C) 2025 The Syncthing Authors.
  2. --
  3. -- This Source Code Form is subject to the terms of the Mozilla Public
  4. -- License, v. 2.0. If a copy of the MPL was not distributed with this file,
  5. -- You can obtain one at https://mozilla.org/MPL/2.0/.
  6. -- Remote files with the invalid bit instead gain the RemoteInvalid local
  7. -- flag.
  8. UPDATE files
  9. SET local_flags = local_flags | {{.FlagLocalRemoteInvalid}}
  10. FROM (
  11. SELECT idx FROM devices
  12. WHERE device_id = '7777777-777777N-7777777-777777N-7777777-777777N-7777777-77777Q4'
  13. ) AS local_device
  14. WHERE invalid AND device_idx != local_device.idx
  15. ;
  16. -- The invalid column goes away.
  17. ALTER TABLE files DROP COLUMN invalid
  18. ;