Add DNS record priority and provider ID to database.

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/3a59ba47-a215-4480-864c-5683509ff1dc.jpg
This commit is contained in:
alphaeusmote
2025-04-11 02:08:07 +00:00
+15 -12
View File
@@ -432,8 +432,8 @@ export class DatabaseStorage implements IStorage {
// Use raw SQL to select only columns that actually exist in the database // Use raw SQL to select only columns that actually exist in the database
const query = sql` const query = sql`
SELECT SELECT
id, domain_id, name, type, content, ttl, id, domain_id, name, type, content, ttl, priority,
is_active, auto_update, notes, last_updated, created_at provider_record_id, is_active, auto_update, notes, last_updated, created_at
FROM dns_records FROM dns_records
WHERE domain_id = ${domainId} WHERE domain_id = ${domainId}
`; `;
@@ -453,13 +453,14 @@ export class DatabaseStorage implements IStorage {
type: record.type, type: record.type,
content: record.content, content: record.content,
ttl: record.ttl, ttl: record.ttl,
priority: record.priority,
providerRecordId: record.provider_record_id,
isActive: record.is_active, isActive: record.is_active,
isAutoIP: record.auto_update, // Map auto_update to isAutoIP isAutoIP: record.auto_update, // Map auto_update to isAutoIP
notes: record.notes, notes: record.notes,
lastUpdated: record.last_updated, lastUpdated: record.last_updated,
createdAt: record.created_at, createdAt: record.created_at,
proxied: null, // Add missing fields with null values proxied: null // Add missing field for frontend compatibility
providerId: null
})); }));
} catch (error) { } catch (error) {
console.error("Error in getDnsRecordsByDomain:", error); console.error("Error in getDnsRecordsByDomain:", error);
@@ -539,8 +540,8 @@ export class DatabaseStorage implements IStorage {
UPDATE dns_records UPDATE dns_records
SET last_updated = ${new Date()} SET last_updated = ${new Date()}
WHERE id = ${id} WHERE id = ${id}
RETURNING id, domain_id, name, type, content, ttl, RETURNING id, domain_id, name, type, content, ttl, priority,
is_active, auto_update, notes, last_updated, created_at provider_record_id, is_active, auto_update, notes, last_updated, created_at
`; `;
const updateResult = await db.execute(updateQuery); const updateResult = await db.execute(updateQuery);
@@ -557,13 +558,14 @@ export class DatabaseStorage implements IStorage {
type: record.type, type: record.type,
content: record.content, content: record.content,
ttl: record.ttl, ttl: record.ttl,
priority: record.priority,
providerRecordId: record.provider_record_id,
isActive: record.is_active, isActive: record.is_active,
isAutoIP: record.auto_update, isAutoIP: record.auto_update,
notes: record.notes, notes: record.notes,
lastUpdated: record.last_updated, lastUpdated: record.last_updated,
createdAt: record.created_at, createdAt: record.created_at,
proxied: null, proxied: null // Maintained for frontend compatibility
providerId: null
}; };
} }
@@ -599,8 +601,8 @@ export class DatabaseStorage implements IStorage {
// Add WHERE and RETURNING // Add WHERE and RETURNING
sqlQuery = sql`${sqlQuery} WHERE id = ${id} sqlQuery = sql`${sqlQuery} WHERE id = ${id}
RETURNING id, domain_id, name, type, content, ttl, RETURNING id, domain_id, name, type, content, ttl, priority,
is_active, auto_update, notes, last_updated, created_at`; provider_record_id, is_active, auto_update, notes, last_updated, created_at`;
// Execute the query // Execute the query
const result = await db.execute(sqlQuery); const result = await db.execute(sqlQuery);
@@ -618,13 +620,14 @@ export class DatabaseStorage implements IStorage {
type: updatedRecord.type, type: updatedRecord.type,
content: updatedRecord.content, content: updatedRecord.content,
ttl: updatedRecord.ttl, ttl: updatedRecord.ttl,
priority: updatedRecord.priority,
providerRecordId: updatedRecord.provider_record_id,
isActive: updatedRecord.is_active, isActive: updatedRecord.is_active,
isAutoIP: updatedRecord.auto_update, isAutoIP: updatedRecord.auto_update,
notes: updatedRecord.notes, notes: updatedRecord.notes,
lastUpdated: updatedRecord.last_updated, lastUpdated: updatedRecord.last_updated,
createdAt: updatedRecord.created_at, createdAt: updatedRecord.created_at,
proxied: null, proxied: null // Maintained for frontend compatibility
providerId: null
}; };
} catch (error) { } catch (error) {
console.error("Error in updateDnsRecord:", error); console.error("Error in updateDnsRecord:", error);