fix(db): change prefix column type to TEXT in prefix_snapshot_row
CI / changes (push) Successful in 8s
CI / openapi (push) Has been skipped
CI / commitlint (push) Has been skipped
CI / web (push) Has been skipped
CI / go (push) Successful in 54s
CI / bird2 (push) Successful in 14s
CI / release (push) Successful in 3m44s
CI / changes (push) Successful in 8s
CI / openapi (push) Has been skipped
CI / commitlint (push) Has been skipped
CI / web (push) Has been skipped
CI / go (push) Successful in 54s
CI / bird2 (push) Successful in 14s
CI / release (push) Successful in 3m44s
Updated the prefix column in the prefix_snapshot_row table from CIDR to TEXT to accommodate broader input formats. Adjusted related SQL insert statements accordingly.
This commit is contained in:
@@ -86,7 +86,7 @@ func (p *Postgres) ensurePrefixSnapshot(ctx context.Context, db execQuerier, con
|
||||
}
|
||||
if _, err := db.Exec(ctx, `
|
||||
INSERT INTO prefix_snapshot_row (snapshot_id, ord, prefix, community_id, source)
|
||||
VALUES ($1::uuid, $2, $3::cidr, $4::uuid, $5)`,
|
||||
VALUES ($1::uuid, $2, $3, $4::uuid, $5)`,
|
||||
snapID, i, strings.TrimSpace(pr.Prefix), comm, src); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
@@ -97,8 +97,8 @@ protocol direct {
|
||||
}
|
||||
if _, err := tx.Exec(ctx, `
|
||||
INSERT INTO prefix_snapshot_row (snapshot_id, ord, prefix, community_id, source)
|
||||
VALUES ($1::uuid, 0, '203.0.113.0/24'::cidr, $2::uuid, 'demo'),
|
||||
($1::uuid, 1, '2001:db8::/32'::cidr, $2::uuid, 'demo')`, snapID, cid); err != nil {
|
||||
VALUES ($1::uuid, 0, '203.0.113.0/24', $2::uuid, 'demo'),
|
||||
($1::uuid, 1, '2001:db8::/32', $2::uuid, 'demo')`, snapID, cid); err != nil {
|
||||
return err
|
||||
}
|
||||
if _, err := tx.Exec(ctx, `
|
||||
|
||||
@@ -10,7 +10,7 @@ CREATE TABLE prefix_snapshot (
|
||||
CREATE TABLE prefix_snapshot_row (
|
||||
snapshot_id UUID NOT NULL REFERENCES prefix_snapshot (id) ON DELETE CASCADE,
|
||||
ord INTEGER NOT NULL,
|
||||
prefix CIDR NOT NULL,
|
||||
prefix TEXT NOT NULL,
|
||||
community_id UUID REFERENCES bgp_community (id) ON DELETE SET NULL,
|
||||
source TEXT NOT NULL DEFAULT '',
|
||||
PRIMARY KEY (snapshot_id, ord)
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
-- Backfill prefix snapshots from revision_materialized_prefix.
|
||||
-- prefix_snapshot_row.prefix is TEXT (revision_materialized_prefix.prefix since 000003).
|
||||
|
||||
ALTER TABLE prefix_snapshot_row
|
||||
ALTER COLUMN prefix TYPE TEXT USING prefix::text;
|
||||
|
||||
WITH new_snaps AS (
|
||||
INSERT INTO prefix_snapshot (id, content_hash)
|
||||
|
||||
Reference in New Issue
Block a user