refactor(db): normalize asn prefix cache and ttl cleanup
Строки asn_prefix_cache_row; периодический prune через evobgp-ingest. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
CREATE TABLE asn_prefix_cache_row (
|
||||
asn BIGINT NOT NULL REFERENCES asn_prefix_cache (asn) ON DELETE CASCADE,
|
||||
prefix CIDR NOT NULL,
|
||||
PRIMARY KEY (asn, prefix)
|
||||
);
|
||||
|
||||
INSERT INTO asn_prefix_cache_row (asn, prefix)
|
||||
SELECT apc.asn, t.elem::cidr
|
||||
FROM asn_prefix_cache apc
|
||||
CROSS JOIN LATERAL jsonb_array_elements_text(apc.prefixes_json) AS t(elem)
|
||||
WHERE jsonb_typeof(apc.prefixes_json) = 'array'
|
||||
AND jsonb_array_length(apc.prefixes_json) > 0;
|
||||
|
||||
ALTER TABLE asn_prefix_cache DROP COLUMN prefixes_json;
|
||||
Reference in New Issue
Block a user