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
+13 -12
View File
@@ -58,11 +58,11 @@ export const dnsRecords = pgTable("dns_records", {
type: text("type").notNull(),
content: text("content").notNull(),
ttl: integer("ttl").default(3600),
proxied: boolean("proxied").default(false),
isActive: boolean("is_active").default(true).notNull(),
isAutoIP: boolean("is_auto_ip").default(false).notNull(),
priority: integer("priority"),
providerRecordId: text("provider_record_id"),
notes: text("notes"),
providerId: uuid("provider_id").references(() => providers.id, { onDelete: "set null" }),
isActive: boolean("is_active").default(true).notNull(),
isAutoIP: boolean("auto_update").default(false).notNull(), // renamed to match database column
lastUpdated: timestamp("last_updated"),
createdAt: timestamp("created_at").defaultNow().notNull(),
});
@@ -211,15 +211,19 @@ export const insertDnsRecordSchema = createInsertSchema(dnsRecords)
type: true,
content: true,
ttl: true,
proxied: true,
isActive: true,
isAutoIP: true,
notes: true,
providerId: true,
priority: true,
providerRecordId: true,
})
.extend({
// Override providerId to make it optional
providerId: z.string().uuid().nullable().optional(),
// Add proxied field for backward compatibility with frontend
proxied: z.boolean().nullable().optional(),
// Make priority optional with default value
priority: z.number().optional().default(0),
// Make provider record ID optional
providerRecordId: z.string().nullable().optional(),
});
export const insertProviderSchema = createInsertSchema(providers).pick({
@@ -382,10 +386,7 @@ export const dnsRecordsRelations = relations(dnsRecords, ({ one, many }) => ({
fields: [dnsRecords.domainId],
references: [domains.id],
}),
provider: one(providers, {
fields: [dnsRecords.providerId],
references: [providers.id],
}),
// Provider is now referenced through the domain, not directly
history: many(dnsHistory),
}));