initSchema (db.go:163-166) treats user_version == 0 as "empty database" and calls createSchema, which unconditionally runs CREATE TABLE files (db.go:176-191). If the database already has a files table but user_version is 0 — a database created by some other tool, a partially initialized file, or one whose user_version was reset — the user gets create schema: table files already exists, which explains nothing and suggests no action.
README §Database says a database whose schema version is not 1 is a fatal error, so the intended behaviour for an unrecognized database is a clear schema-version error, not a raw SQLite complaint.
Definition of done
initSchema distinguishes a genuinely empty database from one that has a files table but no recognized version, and reports the latter with a clear fatal error naming the file and telling the operator to remove it and rescan.
Alternatively createSchema uses CREATE TABLE IF NOT EXISTS — but only if the version is then still validated, so an unversioned foreign database is not silently adopted.
A test creates a database with a bare files table and user_version = 0 and asserts the error message.
make check green.
`initSchema` (`db.go:163-166`) treats `user_version == 0` as "empty database" and calls `createSchema`, which unconditionally runs `CREATE TABLE files` (`db.go:176-191`). If the database already has a `files` table but `user_version` is 0 — a database created by some other tool, a partially initialized file, or one whose `user_version` was reset — the user gets `create schema: table files already exists`, which explains nothing and suggests no action.
README §Database says a database whose schema version is not 1 is a fatal error, so the intended behaviour for an unrecognized database is a clear schema-version error, not a raw SQLite complaint.
## Definition of done
1. `initSchema` distinguishes a genuinely empty database from one that has a `files` table but no recognized version, and reports the latter with a clear fatal error naming the file and telling the operator to remove it and rescan.
2. Alternatively `createSchema` uses `CREATE TABLE IF NOT EXISTS` — but only if the version is then still validated, so an unversioned foreign database is not silently adopted.
3. A test creates a database with a bare `files` table and `user_version = 0` and asserts the error message.
4. `make check` green.
clawbot
added this to the 1.0.0 milestone 2026-08-09 03:45:01 +02:00
createSchema now checks for an existing files table before creating one. At user_version 0 with a files table present it returns the schema-version error telling the operator to remove the file and rescan, so a foreign or partially initialized database is fatal instead of emitting the raw SQLite table files already exists. A genuinely empty database is unchanged. Added a test that opens a database with a bare files table and user_version 0 for scan and asserts that error. Change stays inside initSchema/createSchema; openDB untouched.
Model: opus-4-8
Fixed in https://git.eeqj.de/sneak/sfdupes/pulls/58 .
`createSchema` now checks for an existing `files` table before creating one. At `user_version` 0 with a `files` table present it returns the schema-version error telling the operator to remove the file and rescan, so a foreign or partially initialized database is fatal instead of emitting the raw SQLite `table files already exists`. A genuinely empty database is unchanged. Added a test that opens a database with a bare `files` table and `user_version` 0 for scan and asserts that error. Change stays inside `initSchema`/`createSchema`; `openDB` untouched.
Model: opus-4-8
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
initSchema(db.go:163-166) treatsuser_version == 0as "empty database" and callscreateSchema, which unconditionally runsCREATE TABLE files(db.go:176-191). If the database already has afilestable butuser_versionis 0 — a database created by some other tool, a partially initialized file, or one whoseuser_versionwas reset — the user getscreate schema: table files already exists, which explains nothing and suggests no action.README §Database says a database whose schema version is not 1 is a fatal error, so the intended behaviour for an unrecognized database is a clear schema-version error, not a raw SQLite complaint.
Definition of done
initSchemadistinguishes a genuinely empty database from one that has afilestable but no recognized version, and reports the latter with a clear fatal error naming the file and telling the operator to remove it and rescan.createSchemausesCREATE TABLE IF NOT EXISTS— but only if the version is then still validated, so an unversioned foreign database is not silently adopted.filestable anduser_version = 0and asserts the error message.make checkgreen.Fixed in #58 .
createSchemanow checks for an existingfilestable before creating one. Atuser_version0 with afilestable present it returns the schema-version error telling the operator to remove the file and rescan, so a foreign or partially initialized database is fatal instead of emitting the raw SQLitetable files already exists. A genuinely empty database is unchanged. Added a test that opens a database with a barefilestable anduser_version0 for scan and asserts that error. Change stays insideinitSchema/createSchema;openDBuntouched.Model: opus-4-8