diff options
| author | Lizzy Hunt <elizabeth.hunt@simponic.xyz> | 2024-04-01 17:35:10 -0600 |
|---|---|---|
| committer | Lizzy Hunt <elizabeth.hunt@simponic.xyz> | 2024-04-01 17:35:10 -0600 |
| commit | 1fd1444f97489f168d5a72591a75b5748e36081f (patch) | |
| tree | e497da7d128341609ea78fa2e48594c3532806a4 | |
| parent | 38110bb19dcd4ed5d83a5165da13e02c17ea0e76 (diff) | |
| download | hatecomputers.club-1fd1444f97489f168d5a72591a75b5748e36081f.tar.gz hatecomputers.club-1fd1444f97489f168d5a72591a75b5748e36081f.zip | |
make name type content unique in dns records
| -rw-r--r-- | database/migrate.go | 9 |
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 } |
