Fix: Remove UNIQUE constraint from microchip field to allow NULL values
This commit is contained in:
@@ -26,7 +26,7 @@ function initDatabase(dbPath) {
|
||||
sex TEXT NOT NULL CHECK(sex IN ('male', 'female')),
|
||||
birth_date DATE,
|
||||
color TEXT,
|
||||
microchip TEXT UNIQUE,
|
||||
microchip TEXT,
|
||||
photo_urls TEXT, -- JSON array of photo URLs
|
||||
notes TEXT,
|
||||
is_active INTEGER DEFAULT 1,
|
||||
@@ -35,6 +35,13 @@ function initDatabase(dbPath) {
|
||||
)
|
||||
`);
|
||||
|
||||
// Create unique index for microchip that allows NULL values
|
||||
db.exec(`
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS idx_dogs_microchip
|
||||
ON dogs(microchip)
|
||||
WHERE microchip IS NOT NULL
|
||||
`);
|
||||
|
||||
// Parents table - Relationship mapping
|
||||
db.exec(`
|
||||
CREATE TABLE IF NOT EXISTS parents (
|
||||
|
||||
Reference in New Issue
Block a user