Fix adding DNS records by adding priority and provider record ID fields

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 9111ef36-26c8-4085-84ca-a35dc1fec1b5
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/7083d608-d6d3-4a6a-9a27-6286c5109627/a4984ce1-f551-4b2e-820f-afb1b97cacf1.jpg
This commit is contained in:
alphaeusmote
2025-04-11 02:05:23 +00:00
parent 300f0462c2
commit 0eec01aca2
2 changed files with 27 additions and 21 deletions
+14 -9
View File
@@ -390,8 +390,8 @@ export class DatabaseStorage implements IStorage {
// Use raw SQL to select only columns that actually exist in the database
const query = sql`
SELECT
id, domain_id, name, type, content, ttl,
is_active, auto_update, notes, last_updated, created_at
id, domain_id, name, type, content, ttl, priority,
provider_record_id, is_active, auto_update, notes, last_updated, created_at
FROM dns_records
WHERE id = ${id}
`;
@@ -412,13 +412,14 @@ export class DatabaseStorage implements IStorage {
type: record.type,
content: record.content,
ttl: record.ttl,
priority: record.priority,
providerRecordId: record.provider_record_id,
isActive: record.is_active,
isAutoIP: record.auto_update, // Map auto_update to isAutoIP
notes: record.notes,
lastUpdated: record.last_updated,
createdAt: record.created_at,
proxied: null, // Add missing fields with null values
providerId: null
proxied: null // Field for frontend compatibility
};
} catch (error) {
console.error("Error in getDnsRecord:", error);
@@ -474,21 +475,23 @@ export class DatabaseStorage implements IStorage {
// Create SQL query with proper parameterization using SQL template literals
const queryText = sql`
INSERT INTO dns_records (
domain_id, name, type, content, ttl,
is_active, auto_update, notes, last_updated
domain_id, name, type, content, ttl, priority,
is_active, auto_update, notes, last_updated, provider_record_id
) VALUES (
${validFields.domainId},
${validFields.name},
${validFields.type},
${validFields.content},
${validFields.ttl || 3600},
${validFields.priority || 0},
${validFields.isActive !== undefined ? validFields.isActive : true},
${isAutoIP !== undefined ? isAutoIP : false},
${validFields.notes || null},
${new Date()}
${new Date()},
${null} -- provider_record_id will be populated when syncing with providers
)
RETURNING id, domain_id, name, type, content, ttl,
is_active, auto_update, notes, last_updated, created_at
RETURNING id, domain_id, name, type, content, ttl, priority,
is_active, auto_update, notes, last_updated, created_at, provider_record_id
`;
// Execute the query directly with SQL template literal
@@ -508,11 +511,13 @@ export class DatabaseStorage implements IStorage {
type: newRecord.type,
content: newRecord.content,
ttl: newRecord.ttl,
priority: newRecord.priority,
isActive: newRecord.is_active,
isAutoIP: newRecord.auto_update, // Map auto_update to isAutoIP
notes: newRecord.notes,
lastUpdated: newRecord.last_updated,
createdAt: newRecord.created_at,
providerRecordId: newRecord.provider_record_id,
proxied: null, // Add missing fields with null values
providerId: null
};