Skip to content

Commit

Permalink
bump schema version
Browse files Browse the repository at this point in the history
  • Loading branch information
internet-diglett committed Nov 14, 2023
1 parent e8d4768 commit 049f324
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 54 deletions.
2 changes: 1 addition & 1 deletion nexus/db-model/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1269,7 +1269,7 @@ table! {
///
/// This should be updated whenever the schema is changed. For more details,
/// refer to: schema/crdb/README.adoc
pub const SCHEMA_VERSION: SemverVersion = SemverVersion::new(9, 0, 0);
pub const SCHEMA_VERSION: SemverVersion = SemverVersion::new(10, 0, 0);

allow_tables_to_appear_in_same_query!(
system_update,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
107 changes: 54 additions & 53 deletions schema/crdb/dbinit.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2757,58 +2757,6 @@ CREATE TABLE IF NOT EXISTS omicron.public.db_metadata (
CHECK (singleton = true)
);

CREATE SEQUENCE IF NOT EXISTS omicron.public.ipv4_nat_version START 1 INCREMENT 1;

CREATE TABLE IF NOT EXISTS omicron.public.ipv4_nat_entry (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
external_address INET NOT NULL,
first_port INT4 NOT NULL,
last_port INT4 NOT NULL,
sled_address INET NOT NULL,
vni INT4 NOT NULL,
mac INT8 NOT NULL,
version_added INT8 NOT NULL DEFAULT nextval('omicron.public.ipv4_nat_version'),
version_removed INT8,
time_created TIMESTAMPTZ NOT NULL DEFAULT now(),
time_deleted TIMESTAMPTZ
);

CREATE UNIQUE INDEX IF NOT EXISTS ipv4_nat_version_added ON omicron.public.ipv4_nat_entry (
version_added
)
STORING (
external_address,
first_port,
last_port,
sled_address,
vni,
mac,
time_created,
time_deleted
);

CREATE UNIQUE INDEX IF NOT EXISTS overlapping_ipv4_nat_entry ON omicron.public.ipv4_nat_entry (
external_address,
first_port,
last_port
) WHERE time_deleted IS NULL;

CREATE INDEX IF NOT EXISTS ipv4_nat_lookup ON omicron.public.ipv4_nat_entry (external_address, first_port, last_port, sled_address, vni, mac);

CREATE UNIQUE INDEX IF NOT EXISTS ipv4_nat_version_removed ON omicron.public.ipv4_nat_entry (
version_removed
)
STORING (
external_address,
first_port,
last_port,
sled_address,
vni,
mac,
time_created,
time_deleted
);

-- Per-VMM state.
CREATE TABLE IF NOT EXISTS omicron.public.vmm (
id UUID PRIMARY KEY,
Expand Down Expand Up @@ -2899,14 +2847,67 @@ CREATE TABLE IF NOT EXISTS omicron.public.db_metadata (
CHECK (singleton = true)
);


CREATE SEQUENCE IF NOT EXISTS omicron.public.ipv4_nat_version START 1 INCREMENT 1;

CREATE TABLE IF NOT EXISTS omicron.public.ipv4_nat_entry (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
external_address INET NOT NULL,
first_port INT4 NOT NULL,
last_port INT4 NOT NULL,
sled_address INET NOT NULL,
vni INT4 NOT NULL,
mac INT8 NOT NULL,
version_added INT8 NOT NULL DEFAULT nextval('omicron.public.ipv4_nat_version'),
version_removed INT8,
time_created TIMESTAMPTZ NOT NULL DEFAULT now(),
time_deleted TIMESTAMPTZ
);

CREATE UNIQUE INDEX IF NOT EXISTS ipv4_nat_version_added ON omicron.public.ipv4_nat_entry (
version_added
)
STORING (
external_address,
first_port,
last_port,
sled_address,
vni,
mac,
time_created,
time_deleted
);

CREATE UNIQUE INDEX IF NOT EXISTS overlapping_ipv4_nat_entry ON omicron.public.ipv4_nat_entry (
external_address,
first_port,
last_port
) WHERE time_deleted IS NULL;

CREATE INDEX IF NOT EXISTS ipv4_nat_lookup ON omicron.public.ipv4_nat_entry (external_address, first_port, last_port, sled_address, vni, mac);

CREATE UNIQUE INDEX IF NOT EXISTS ipv4_nat_version_removed ON omicron.public.ipv4_nat_entry (
version_removed
)
STORING (
external_address,
first_port,
last_port,
sled_address,
vni,
mac,
time_created,
time_deleted
);

INSERT INTO omicron.public.db_metadata (
singleton,
time_created,
time_modified,
version,
target_version
) VALUES
( TRUE, NOW(), NOW(), '9.0.0', NULL)
( TRUE, NOW(), NOW(), '10.0.0', NULL)
ON CONFLICT DO NOTHING;

COMMIT;

0 comments on commit 049f324

Please sign in to comment.