Add migration to allow the extended zone kind in the database
The zones.kind CHECK constraint still only allowed 'forward', 'reverse4' and 'reverse6', so creating an extended zone hit a constraint failure and a 500. Rebuilds the zones table with the widened constraint while preserving row ids so records.zone_id references stay valid. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V8c76Xr2BycaHHu5N4buqi
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
-- Adds the "extended" zone kind, which answers authoritatively only for the
|
||||
-- records it holds and falls through to recursion for everything else.
|
||||
--
|
||||
-- SQLite has no ALTER TABLE ... DROP/ADD CONSTRAINT, so the CHECK constraint
|
||||
-- on zones.kind is widened by rebuilding the table. The rebuilt table keeps
|
||||
-- the same name, column order and row ids, so records.zone_id references
|
||||
-- remain valid without touching the records table at all.
|
||||
|
||||
CREATE TABLE zones_new (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
name TEXT NOT NULL UNIQUE,
|
||||
kind TEXT NOT NULL DEFAULT 'forward'
|
||||
CHECK (kind IN ('forward', 'reverse4', 'reverse6', 'extended')),
|
||||
description TEXT NOT NULL DEFAULT '',
|
||||
enabled INTEGER NOT NULL DEFAULT 1,
|
||||
default_ttl INTEGER NOT NULL DEFAULT 3600,
|
||||
primary_ns TEXT NOT NULL,
|
||||
admin_email TEXT NOT NULL,
|
||||
serial INTEGER NOT NULL DEFAULT 1,
|
||||
refresh INTEGER NOT NULL DEFAULT 7200,
|
||||
retry INTEGER NOT NULL DEFAULT 3600,
|
||||
expire INTEGER NOT NULL DEFAULT 1209600,
|
||||
minimum INTEGER NOT NULL DEFAULT 3600,
|
||||
auto_serial INTEGER NOT NULL DEFAULT 1,
|
||||
created_at INTEGER NOT NULL DEFAULT (unixepoch()),
|
||||
updated_at INTEGER NOT NULL DEFAULT (unixepoch())
|
||||
);
|
||||
|
||||
INSERT INTO zones_new (id, name, kind, description, enabled, default_ttl, primary_ns,
|
||||
admin_email, serial, refresh, retry, expire, minimum, auto_serial, created_at, updated_at)
|
||||
SELECT id, name, kind, description, enabled, default_ttl, primary_ns,
|
||||
admin_email, serial, refresh, retry, expire, minimum, auto_serial, created_at, updated_at
|
||||
FROM zones;
|
||||
|
||||
DROP TABLE zones;
|
||||
ALTER TABLE zones_new RENAME TO zones;
|
||||
|
||||
CREATE INDEX idx_zones_enabled ON zones (enabled);
|
||||
CREATE INDEX idx_zones_kind ON zones (kind);
|
||||
Reference in New Issue
Block a user