Skip to content

Commit

Permalink
dbinit.sql should not be ALTER TABLE-ing after creating tables (#6116)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nieuwejaar authored Jul 18, 2024
1 parent 5b32a8d commit 2ba2846
Showing 1 changed file with 25 additions and 28 deletions.
53 changes: 25 additions & 28 deletions schema/crdb/dbinit.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1430,7 +1430,8 @@ CREATE TYPE IF NOT EXISTS omicron.public.network_interface_kind AS ENUM (
'instance',

/* An interface attached to a service. */
'service'
'service',
'probe'
);

CREATE TABLE IF NOT EXISTS omicron.public.network_interface (
Expand Down Expand Up @@ -1871,6 +1872,8 @@ CREATE TABLE IF NOT EXISTS omicron.public.external_ip (
*/
state omicron.public.ip_attach_state NOT NULL,

is_probe BOOL NOT NULL DEFAULT false,

/* The name must be non-NULL iff this is a floating IP. */
CONSTRAINT null_fip_name CHECK (
(kind != 'floating' AND name IS NULL) OR
Expand Down Expand Up @@ -2618,11 +2621,32 @@ CREATE TABLE IF NOT EXISTS omicron.public.switch_port_settings_port_config (
geometry omicron.public.switch_port_geometry
);

CREATE TYPE IF NOT EXISTS omicron.public.switch_link_fec AS ENUM (
'Firecode',
'None',
'Rs'
);

CREATE TYPE IF NOT EXISTS omicron.public.switch_link_speed AS ENUM (
'0G',
'1G',
'10G',
'25G',
'40G',
'50G',
'100G',
'200G',
'400G'
);

CREATE TABLE IF NOT EXISTS omicron.public.switch_port_settings_link_config (
port_settings_id UUID,
lldp_service_config_id UUID NOT NULL,
link_name TEXT,
mtu INT4,
fec omicron.public.switch_link_fec,
speed omicron.public.switch_link_speed,
autoneg BOOL NOT NULL DEFAULT false,

PRIMARY KEY (port_settings_id, link_name)
);
Expand Down Expand Up @@ -3599,27 +3623,6 @@ FROM
WHERE
instance.time_deleted IS NULL AND vmm.time_deleted IS NULL;

CREATE TYPE IF NOT EXISTS omicron.public.switch_link_fec AS ENUM (
'Firecode',
'None',
'Rs'
);

CREATE TYPE IF NOT EXISTS omicron.public.switch_link_speed AS ENUM (
'0G',
'1G',
'10G',
'25G',
'40G',
'50G',
'100G',
'200G',
'400G'
);

ALTER TABLE omicron.public.switch_port_settings_link_config ADD COLUMN IF NOT EXISTS fec omicron.public.switch_link_fec;
ALTER TABLE omicron.public.switch_port_settings_link_config ADD COLUMN IF NOT EXISTS speed omicron.public.switch_link_speed;

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

CREATE TABLE IF NOT EXISTS omicron.public.ipv4_nat_entry (
Expand Down Expand Up @@ -3696,8 +3699,6 @@ CREATE UNIQUE INDEX IF NOT EXISTS lookup_bfd_session ON omicron.public.bfd_sessi
switch
) WHERE time_deleted IS NULL;

ALTER TABLE omicron.public.switch_port_settings_link_config ADD COLUMN IF NOT EXISTS autoneg BOOL NOT NULL DEFAULT false;

CREATE INDEX IF NOT EXISTS ipv4_nat_lookup_by_vni ON omicron.public.ipv4_nat_entry (
vni
)
Expand Down Expand Up @@ -3790,10 +3791,6 @@ CREATE UNIQUE INDEX IF NOT EXISTS lookup_probe_by_name ON omicron.public.probe (
) WHERE
time_deleted IS NULL;

ALTER TABLE omicron.public.external_ip ADD COLUMN IF NOT EXISTS is_probe BOOL NOT NULL DEFAULT false;

ALTER TYPE omicron.public.network_interface_kind ADD VALUE IF NOT EXISTS 'probe';

CREATE TYPE IF NOT EXISTS omicron.public.upstairs_repair_notification_type AS ENUM (
'started',
'succeeded',
Expand Down

0 comments on commit 2ba2846

Please sign in to comment.