Skip to content

Commit

Permalink
feat(migrations): add indexes for ip, netblock, rir, and asn assets
Browse files Browse the repository at this point in the history
  • Loading branch information
rynmrtn committed Apr 20, 2024
1 parent 53f9062 commit a457fd7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
11 changes: 11 additions & 0 deletions migrations/postgres/010_asset_content_idx.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-- +migrate Up
CREATE INDEX IF NOT EXISTS idx_ip_content_address ON assets USING gin ((content->>'address') gin_trgm_ops) WHERE type = 'IPAddress';
CREATE INDEX IF NOT EXISTS idx_net_content_cidr ON assets USING gin ((content->>'cidr') gin_trgm_ops) WHERE type = 'Netblock';
CREATE INDEX IF NOT EXISTS idx_rir_content_name ON assets USING gin ((content->>'name') gin_trgm_ops) WHERE type = 'RIROrg';
CREATE INDEX IF NOT EXISTS idx_asn_content_num ON assets USING gin ((content->>'number') gin_trgm_ops) WHERE type = 'ASN';

-- +migrate Down
DROP INDEX IF EXISTS idx_ip_content_address;
DROP INDEX IF EXISTS idx_net_content_cidr;
DROP INDEX IF EXISTS idx_rir_content_name;
DROP INDEX IF EXISTS idx_asn_content_num;
11 changes: 11 additions & 0 deletions migrations/sqlite3/008_asset_content_idx.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-- +migrate Up
CREATE INDEX idx_ip_content_address ON assets (content->>'address' COLLATE NOCASE) WHERE type = 'IPAddress';
CREATE INDEX idx_net_content_cidr ON assets (content->>'cidr' COLLATE NOCASE) WHERE type = 'Netblock';
CREATE INDEX idx_rir_content_name ON assets (content->>'name' COLLATE NOCASE) WHERE type = 'RIROrg';
CREATE INDEX idx_asn_content_num ON assets (content->>'number' COLLATE NOCASE) WHERE type = 'ASN';

-- +migrate Down
DROP INDEX IF EXISTS idx_ip_content_address;
DROP INDEX IF EXISTS idx_net_content_cidr;
DROP INDEX IF EXISTS idx_rir_content_name;
DROP INDEX IF EXISTS idx_asn_content_num;

0 comments on commit a457fd7

Please sign in to comment.