summaryrefslogtreecommitdiff
path: root/database
diff options
context:
space:
mode:
authorLizzy Hunt <elizabeth.hunt@simponic.xyz>2024-04-01 17:35:10 -0600
committerLizzy Hunt <elizabeth.hunt@simponic.xyz>2024-04-01 17:35:10 -0600
commit1fd1444f97489f168d5a72591a75b5748e36081f (patch)
treee497da7d128341609ea78fa2e48594c3532806a4 /database
parent38110bb19dcd4ed5d83a5165da13e02c17ea0e76 (diff)
downloadhatecomputers.club-1fd1444f97489f168d5a72591a75b5748e36081f.tar.gz
hatecomputers.club-1fd1444f97489f168d5a72591a75b5748e36081f.zip
make name type content unique in dns records
Diffstat (limited to 'database')
-rw-r--r--database/migrate.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/database/migrate.go b/database/migrate.go
index 1609bc2..a117480 100644
--- a/database/migrate.go
+++ b/database/migrate.go
@@ -59,10 +59,17 @@ func MigrateDNSRecords(dbConn *sql.DB) (*sql.DB, error) {
ttl INTEGER NOT NULL,
internal BOOLEAN NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE);`)
+ FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE
+ );`)
+ if err != nil {
+ return dbConn, err
+ }
+
+ _, err = dbConn.Exec(`CREATE UNIQUE INDEX IF NOT EXISTS idx_dns_records_name_content_type ON dns_records (name, type, content);`)
if err != nil {
return dbConn, err
}
+
return dbConn, nil
}