Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(migrations): add indexes for ip, netblock, rir, and asn assets #34

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Loading