make name type content unique in dns records

This commit is contained in:
Lizzy Hunt 2024-04-01 17:35:10 -06:00
parent 38110bb19d
commit 1fd1444f97
Signed by untrusted user who does not match committer: simponic
GPG Key ID: 2909B9A7FF6213EE
1 changed files with 8 additions and 1 deletions

View File

@ -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
}