refactor(db): applies consistent formatting to 'comment on' statements
This commit is contained in:
1 parent
426e6aaa79
commit
d97d34adc4
31 files changed
+173
-172
No files matched your search
@@ -137,7 +137,7 @@ check(
|
||||
length(trim(value)) > 10
|
||||
);
|
||||
comment on domain dbasserts_public_id is
|
||||
'dbasserts test domain type';
|
||||
'dbasserts test domain type';
|
||||
`
|
||||
createTable = `
|
||||
create table if not exists test_table_dbasserts (
|
||||
@@ -147,7 +147,7 @@ create table if not exists test_table_dbasserts (
|
||||
type_int int
|
||||
);
|
||||
comment on table test_table_dbasserts is
|
||||
'dbasserts test table'
|
||||
'dbasserts test table'
|
||||
`
|
||||
)
|
||||
rw := db.New(d)
|
||||
|
||||
@@ -104,7 +104,7 @@ func TestEnsureMigrationLog_UpdateForEditionSupport(t *testing.T) {
|
||||
entry text not null
|
||||
);
|
||||
comment on table log_migration is
|
||||
'log_migration entries are logging output from databaes migrations';
|
||||
'log_migration entries are logging output from databaes migrations';
|
||||
|
||||
create trigger
|
||||
default_create_time_column
|
||||
@@ -130,7 +130,7 @@ func TestEnsureMigrationLog_UpdateForEditionSupport(t *testing.T) {
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
comment on function log_migration_version() is
|
||||
'log_migration_version will set the log_migration entries to the current migration version';
|
||||
'log_migration_version will set the log_migration entries to the current migration version';
|
||||
|
||||
create trigger
|
||||
migration_version_column
|
||||
|
||||
@@ -134,6 +134,6 @@ as $$
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
comment on function log_migration_version() is
|
||||
'log_migration_version will set the log_migration entries to the current migration version';
|
||||
'log_migration_version will set the log_migration entries to the current migration version';
|
||||
`
|
||||
)
|
||||
@@ -7,7 +7,7 @@ create table log_migration(
|
||||
entry text not null
|
||||
);
|
||||
comment on table log_migration is
|
||||
'log_migration entries are logging output from database migrations';
|
||||
'log_migration entries are logging output from database migrations';
|
||||
|
||||
create or replace function
|
||||
log_migration_version()
|
||||
@@ -23,7 +23,7 @@ as $$
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
comment on function log_migration_version() is
|
||||
'log_migration_version will set the log_migration entries to the current migration version';
|
||||
'log_migration_version will set the log_migration entries to the current migration version';
|
||||
|
||||
create trigger
|
||||
version_column
|
||||
|
||||
@@ -5,14 +5,14 @@ check(
|
||||
length(trim(value)) > 10
|
||||
);
|
||||
comment on domain wt_public_id is
|
||||
'Random ID generated with github.com/hashicorp/go-secure-stdlib/base62';
|
||||
'Random ID generated with github.com/hashicorp/go-secure-stdlib/base62';
|
||||
|
||||
create domain wt_private_id as text not null
|
||||
check(
|
||||
length(trim(value)) > 10
|
||||
);
|
||||
comment on domain wt_private_id is
|
||||
'Random ID generated with github.com/hashicorp/go-secure-stdlib/base62';
|
||||
'Random ID generated with github.com/hashicorp/go-secure-stdlib/base62';
|
||||
|
||||
create domain wt_scope_id as text
|
||||
check(
|
||||
@@ -20,7 +20,7 @@ check(
|
||||
);
|
||||
-- Comment fixed in 57/01_fix_comments.up.sql
|
||||
comment on domain wt_scope_id is
|
||||
'"global" or random ID generated with github.com/hashicorp/go-secure-stdlib/base62';
|
||||
'"global" or random ID generated with github.com/hashicorp/go-secure-stdlib/base62';
|
||||
|
||||
create domain wt_user_id as text not null
|
||||
check(
|
||||
@@ -28,7 +28,7 @@ check(
|
||||
);
|
||||
-- Comment fixed in 57/01_fix_comments.up.sql
|
||||
comment on domain wt_scope_id is
|
||||
'"u_anon", "u_auth", or random ID generated with github.com/hashicorp/go-secure-stdlib/base62';
|
||||
'"u_anon", "u_auth", or random ID generated with github.com/hashicorp/go-secure-stdlib/base62';
|
||||
|
||||
create domain wt_role_id as text not null
|
||||
check(
|
||||
@@ -36,11 +36,11 @@ check(
|
||||
);
|
||||
-- Comment fixed in 57/01_fix_comments.up.sql
|
||||
comment on domain wt_scope_id is
|
||||
'Random ID generated with github.com/hashicorp/go-secure-stdlib/base62';
|
||||
'Random ID generated with github.com/hashicorp/go-secure-stdlib/base62';
|
||||
|
||||
create domain wt_timestamp as timestamp with time zone default current_timestamp;
|
||||
comment on domain wt_timestamp is
|
||||
'Standard timestamp for all create_time and update_time columns';
|
||||
'Standard timestamp for all create_time and update_time columns';
|
||||
|
||||
create or replace function update_time_column() returns trigger
|
||||
as $$
|
||||
@@ -75,7 +75,7 @@ create domain wt_version as bigint default 1 not null
|
||||
value > 0
|
||||
);
|
||||
comment on domain wt_version is
|
||||
'standard column for row version';
|
||||
'standard column for row version';
|
||||
|
||||
-- update_version_column() will increment the version column whenever row data
|
||||
-- is updated and should only be used in an update after trigger. This function
|
||||
|
||||
@@ -9,14 +9,14 @@ begin;
|
||||
value <= 65535
|
||||
);
|
||||
comment on domain wh_inet_port is
|
||||
'An ordinal number between 1 and 65535 representing a network port';
|
||||
'An ordinal number between 1 and 65535 representing a network port';
|
||||
|
||||
create domain wh_bytes_transmitted as bigint
|
||||
check(
|
||||
value >= 0
|
||||
);
|
||||
comment on domain wh_bytes_transmitted is
|
||||
'A non-negative integer representing the number of bytes transmitted';
|
||||
'A non-negative integer representing the number of bytes transmitted';
|
||||
|
||||
-- wh_dim_id generates and returns a random ID which should be considered as
|
||||
-- universally unique.
|
||||
@@ -30,7 +30,7 @@ begin;
|
||||
length(trim(value)) > 0
|
||||
);
|
||||
comment on domain wh_dim_id is
|
||||
'Random ID generated with pgcrypto';
|
||||
'Random ID generated with pgcrypto';
|
||||
|
||||
create domain wh_public_id as text
|
||||
check(
|
||||
@@ -39,18 +39,18 @@ begin;
|
||||
length(trim(value)) > 10
|
||||
);
|
||||
comment on domain wh_public_id is
|
||||
'Equivalent to wt_public_id but also allows the value to be ''None''';
|
||||
'Equivalent to wt_public_id but also allows the value to be ''None''';
|
||||
|
||||
create domain wh_timestamp as timestamp with time zone not null;
|
||||
comment on domain wh_timestamp is
|
||||
'Timestamp used in warehouse tables';
|
||||
'Timestamp used in warehouse tables';
|
||||
|
||||
create domain wh_dim_text as text not null
|
||||
check(
|
||||
length(trim(value)) > 0
|
||||
);
|
||||
comment on domain wh_dim_text is
|
||||
'Text fields in dimension tables are always not null and always not empty strings';
|
||||
'Text fields in dimension tables are always not null and always not empty strings';
|
||||
|
||||
-- wh_date_id returns the wh_date_dimension id for ts.
|
||||
create or replace function wh_date_id(ts wh_timestamp) returns integer
|
||||
|
||||
@@ -9,7 +9,7 @@ create domain wt_email as text
|
||||
constraint wt_email_too_long
|
||||
check (length(trim(value)) < 320);
|
||||
comment on domain wt_email is
|
||||
'standard column for email addresses';
|
||||
'standard column for email addresses';
|
||||
|
||||
-- wt_full_name defines a type for a person's full name which must be less than
|
||||
-- 512 chars. The type is defined to allow nulls and not be unique, which can
|
||||
@@ -20,7 +20,7 @@ create domain wt_full_name text
|
||||
constraint wt_full_name_too_long
|
||||
check(length(trim(value)) <= 512); -- gotta pick some upper limit.
|
||||
comment on domain wt_full_name is
|
||||
'standard column for the full name of a person';
|
||||
'standard column for the full name of a person';
|
||||
|
||||
-- wt_url defines a type for URLs which must be longer that 3 chars and
|
||||
-- less than 4k chars. It's defined to allow nulls, which can be overridden as
|
||||
@@ -33,7 +33,7 @@ create domain wt_url as text
|
||||
constraint wt_url_invalid_protocol
|
||||
check (value ~ 'https?:\/\/*');
|
||||
comment on domain wt_url is
|
||||
'standard column for URLs';
|
||||
'standard column for URLs';
|
||||
|
||||
-- wt_name defines a type for resource names that must be less than 128 chars.
|
||||
-- It's defined to allow nulls.
|
||||
@@ -43,7 +43,7 @@ create domain wt_name as text
|
||||
constraint wt_name_too_long
|
||||
check (length(trim(value)) < 128);
|
||||
comment on domain wt_name is
|
||||
'standard column for resource names';
|
||||
'standard column for resource names';
|
||||
|
||||
-- wt_description defines a type for resource descriptions that must be less
|
||||
-- than 1024 chars. It's defined to allow nulls.
|
||||
@@ -53,6 +53,6 @@ create domain wt_description as text
|
||||
constraint wt_description_too_long
|
||||
check (length(trim(value)) < 1024);
|
||||
comment on domain wt_description is
|
||||
'standard column for resource descriptions';
|
||||
'standard column for resource descriptions';
|
||||
|
||||
commit;
|
||||
@@ -17,7 +17,7 @@ begin;
|
||||
length(trim(u&'\fffe ' from value)) > 0
|
||||
);
|
||||
comment on domain wt_sentinel is
|
||||
'A non-empty string with a Unicode prefix of U+FFFE to indicate it is a sentinel value';
|
||||
'A non-empty string with a Unicode prefix of U+FFFE to indicate it is a sentinel value';
|
||||
|
||||
create function wt_to_sentinel(string text) returns text
|
||||
as $$
|
||||
|
||||
@@ -17,7 +17,7 @@ $$ language sql
|
||||
immutable
|
||||
returns null on null input;
|
||||
comment on function wt_is_sentinel is
|
||||
'wt_is_sentinel returns true if string is a sentinel value';
|
||||
'wt_is_sentinel returns true if string is a sentinel value';
|
||||
|
||||
alter domain wt_sentinel
|
||||
add constraint wt_sentinel_not_valid
|
||||
@@ -27,7 +27,7 @@ alter domain wt_sentinel
|
||||
length(trim(trailing u&'\ffff' from trim(leading u&'\fffe ' from value))) > 0
|
||||
);
|
||||
comment on domain wt_sentinel is
|
||||
'A non-empty string with a Unicode prefix of U+FFFE and suffix of U+FFFF to indicate it is a sentinel value';
|
||||
'A non-empty string with a Unicode prefix of U+FFFE and suffix of U+FFFF to indicate it is a sentinel value';
|
||||
|
||||
drop function wt_to_sentinel; -- wt_to_sentinel is not needed, dropping and not re-creating
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ begin;
|
||||
stable
|
||||
returns null on null input;
|
||||
comment on function wt_add_seconds is
|
||||
'wt_sub_seconds returns ts - sec.';
|
||||
'wt_sub_seconds returns ts - sec.';
|
||||
|
||||
create function wt_sub_seconds_from_now(sec integer) returns timestamp with time zone
|
||||
as $$
|
||||
@@ -20,6 +20,6 @@ begin;
|
||||
stable
|
||||
returns null on null input;
|
||||
comment on function wt_add_seconds_to_now is
|
||||
'wt_sub_seconds_from_now returns current_timestamp - sec.';
|
||||
'wt_sub_seconds_from_now returns current_timestamp - sec.';
|
||||
|
||||
commit;
|
||||
@@ -50,7 +50,7 @@ create table auth_oidc_method (
|
||||
unique(scope_id, issuer, client_id) -- a client_id must be unique for a provider within a scope.
|
||||
);
|
||||
comment on table auth_oidc_method is
|
||||
'auth_oidc_method entries are the current oidc auth methods configured for existing scopes.';
|
||||
'auth_oidc_method entries are the current oidc auth methods configured for existing scopes.';
|
||||
|
||||
-- auth_oidc_signing_alg entries are the signing algorithms allowed for an oidc
|
||||
-- auth method. There must be at least one allowed alg for each oidc auth method.
|
||||
@@ -69,7 +69,7 @@ create table auth_oidc_signing_alg (
|
||||
primary key(oidc_method_id, signing_alg_name)
|
||||
);
|
||||
comment on table auth_oidc_signing_alg is
|
||||
'auth_oidc_signing_alg entries are the signing algorithms allowed for an oidc auth method. There must be at least one allowed alg for each oidc auth method';
|
||||
'auth_oidc_signing_alg entries are the signing algorithms allowed for an oidc auth method. There must be at least one allowed alg for each oidc auth method';
|
||||
|
||||
-- auth_oidc_aud_claim entries are the audience claims for a specific oidc auth
|
||||
-- method. There can be 0 or more for each parent oidc auth method. If an auth
|
||||
@@ -89,7 +89,7 @@ create table auth_oidc_aud_claim (
|
||||
primary key(oidc_method_id, aud_claim)
|
||||
);
|
||||
comment on table auth_oidc_aud_claim is
|
||||
'auth_oidc_aud_claim entries are the audience claims for a specific oidc auth method. There can be 0 or more for each parent oidc auth method. If an auth method has any aud claims, an ID token must contain one of them to be valid.';
|
||||
'auth_oidc_aud_claim entries are the audience claims for a specific oidc auth method. There can be 0 or more for each parent oidc auth method. If an auth method has any aud claims, an ID token must contain one of them to be valid.';
|
||||
|
||||
|
||||
-- auth_oidc_certificate entries are optional PEM encoded x509 certificates.
|
||||
@@ -108,7 +108,7 @@ create table auth_oidc_certificate (
|
||||
primary key(oidc_method_id, certificate)
|
||||
);
|
||||
comment on table auth_oidc_certificate is
|
||||
'auth_oidc_certificate entries are optional PEM encoded x509 certificates. Each entry is a single certificate. An oidc auth method may have 0 or more of these optional x509s. If an auth method has any cert entries, they are used as trust anchors when connecting to the auth methods oidc provider (instead of the host system cert chain)';
|
||||
'auth_oidc_certificate entries are optional PEM encoded x509 certificates. Each entry is a single certificate. An oidc auth method may have 0 or more of these optional x509s. If an auth method has any cert entries, they are used as trust anchors when connecting to the auth methods oidc provider (instead of the host system cert chain)';
|
||||
|
||||
|
||||
-- auth_oidc_account entries are subtypes of auth_account and represent an
|
||||
@@ -160,7 +160,7 @@ create table auth_oidc_account (
|
||||
);
|
||||
-- Comment fixed in 57/01_fix_comments.up.sql
|
||||
comment on table auth_oidc_method is
|
||||
'auth_oidc_account entries are subtypes of auth_account and represent an oidc account.';
|
||||
'auth_oidc_account entries are subtypes of auth_account and represent an oidc account.';
|
||||
|
||||
-- auth_oidc_method column triggers
|
||||
create trigger insert_auth_method_subtype before insert on auth_oidc_method
|
||||
@@ -238,7 +238,7 @@ as $$
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
comment on function active_auth_oidc_method_must_be_complete() is
|
||||
'active_auth_oidc_method_must_be_complete() will raise an error if the oidc auth method is not complete';
|
||||
'active_auth_oidc_method_must_be_complete() will raise an error if the oidc auth method is not complete';
|
||||
|
||||
create trigger update_active_auth_oidc_method_must_be_complete before update on auth_oidc_method
|
||||
for each row execute procedure active_auth_oidc_method_must_be_complete();
|
||||
@@ -258,7 +258,7 @@ as $$
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
comment on function new_auth_oidc_method_must_be_inactive() is
|
||||
'new_auth_oidc_method_must_be_inactive ensures that new incomplete oidc auth methods must remain inactive';
|
||||
'new_auth_oidc_method_must_be_inactive ensures that new incomplete oidc auth methods must remain inactive';
|
||||
|
||||
create trigger new_auth_oidc_method_must_be_inactive before insert on auth_oidc_method
|
||||
for each row execute procedure active_auth_oidc_method_must_be_complete();
|
||||
@@ -345,7 +345,7 @@ declare alg_cnt int;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
comment on function on_delete_active_auth_oidc_method_must_be_complete() is
|
||||
'on_delete_active_auth_oidc_method_must_be_complete() will raise an error if the oidc auth method is not complete after a delete on algs';
|
||||
'on_delete_active_auth_oidc_method_must_be_complete() will raise an error if the oidc auth method is not complete after a delete on algs';
|
||||
|
||||
create trigger
|
||||
default_create_time_column
|
||||
|
||||
@@ -35,7 +35,7 @@ begin
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
comment on function insert_auth_method_subtype() is
|
||||
'insert_auth_method_subtype() inserts sub type name into the base type auth method table';
|
||||
'insert_auth_method_subtype() inserts sub type name into the base type auth method table';
|
||||
|
||||
-- update_auth_method_subtype() is a new function intended to be used in "before
|
||||
-- update" triggers for all auth method sub types. It's purpose is to ensure
|
||||
@@ -50,7 +50,7 @@ begin
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
comment on function update_auth_method_subtype() is
|
||||
'update_auth_method_subtype() will update base auth method type name column with new values from sub type';
|
||||
'update_auth_method_subtype() will update base auth method type name column with new values from sub type';
|
||||
|
||||
create trigger update_auth_method_subtype before update on auth_oidc_method
|
||||
for each row execute procedure update_auth_method_subtype();
|
||||
@@ -69,7 +69,7 @@ begin
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
comment on function delete_auth_method_subtype is
|
||||
'delete_auth_method_subtype() is an after trigger function for subytypes of auth_method';
|
||||
'delete_auth_method_subtype() is an after trigger function for subytypes of auth_method';
|
||||
|
||||
create trigger delete_auth_method_subtype after delete on auth_oidc_method
|
||||
for each row execute procedure delete_auth_method_subtype();
|
||||
|
||||
@@ -42,6 +42,6 @@ from
|
||||
left outer join auth_oidc_certificate cert on am.public_id = cert.oidc_method_id
|
||||
group by am.public_id, is_primary_auth_method; -- there can be only one public_id + is_primary_auth_method, so group by isn't a problem.
|
||||
comment on view oidc_auth_method_with_value_obj is
|
||||
'oidc auth method with its associated value objects (algs, auds, certs) as columns with | delimited values';
|
||||
'oidc auth method with its associated value objects (algs, auds, certs) as columns with | delimited values';
|
||||
|
||||
commit;
|
||||
@@ -22,7 +22,7 @@ from
|
||||
auth_password_method am
|
||||
left outer join iam_scope s on am.public_id = s.primary_auth_method_id;
|
||||
comment on view auth_password_method_with_is_primary is
|
||||
'password auth method with an is_primary_auth_method bool';
|
||||
'password auth method with an is_primary_auth_method bool';
|
||||
|
||||
|
||||
commit;
|
||||
@@ -4,7 +4,7 @@ create domain wt_priority as int not null
|
||||
constraint priority_must_be_greater_than_zero
|
||||
check(value > 0);
|
||||
comment on domain wt_priority is
|
||||
'Represents a priority value which must not be null and must be greater than zero';
|
||||
'Represents a priority value which must not be null and must be greater than zero';
|
||||
|
||||
-- wt_dns_name defines a type for dns names
|
||||
create domain wt_dns_name as text not null
|
||||
@@ -13,6 +13,6 @@ create domain wt_dns_name as text not null
|
||||
constraint wt_dns_name_too_long
|
||||
check (length(trim(value)) < 256);
|
||||
comment on domain wt_dns_name is
|
||||
'standard column for dns names';
|
||||
'standard column for dns names';
|
||||
|
||||
commit;
|
||||
@@ -28,7 +28,7 @@ create view host_plugin_host_set_with_value_obj as
|
||||
left outer join host_plugin_set_member hpsm on hs.public_id = hpsm.set_id
|
||||
group by hs.public_id, hc.plugin_id;
|
||||
comment on view host_plugin_host_set_with_value_obj is
|
||||
'host plugin host set with its associated value objects';
|
||||
'host plugin host set with its associated value objects';
|
||||
|
||||
-- REPLACED in 10_plugin_host_secrets_hmac.up.sql
|
||||
create view host_plugin_catalog_with_secret as
|
||||
|
||||
@@ -42,7 +42,7 @@ create table session_valid_state(
|
||||
primary key (prior_state, current_state)
|
||||
);
|
||||
comment on table session_valid_state is
|
||||
'session_valid_state entries define valid prior_state and current_state pairs to define valid state transitions';
|
||||
'session_valid_state entries define valid prior_state and current_state pairs to define valid state transitions';
|
||||
|
||||
insert into session_valid_state (prior_state, current_state)
|
||||
values
|
||||
|
||||
@@ -17,7 +17,7 @@ check(
|
||||
length(trim(value)) > 0
|
||||
);
|
||||
comment on domain kms_scope_id is
|
||||
'standard column for scope id';
|
||||
'standard column for scope id';
|
||||
|
||||
create domain kms_timestamp as timestamp with time zone default current_timestamp;
|
||||
comment on domain kms_timestamp is
|
||||
@@ -28,7 +28,7 @@ create domain kms_version as bigint default 1 not null
|
||||
value > 0
|
||||
);
|
||||
comment on domain kms_version is
|
||||
'standard column for row version';
|
||||
'standard column for row version';
|
||||
|
||||
-- kms_immutable_columns() will make the column names immutable which are passed as
|
||||
-- parameters when the trigger is created. It raises error code 23601 which is a
|
||||
|
||||
@@ -23,6 +23,8 @@ create table worker_auth_ca(
|
||||
create_time wt_timestamp,
|
||||
update_time wt_timestamp
|
||||
);
|
||||
comment on table worker_auth_ca is
|
||||
'worker_auth_ca is a one-row versioned table used for locking for certificate rotation on the worker_auth_ca_certificate table.';
|
||||
|
||||
create trigger immutable_columns before update on worker_auth_ca
|
||||
for each row execute procedure immutable_columns('private_id','create_time');
|
||||
@@ -38,9 +40,6 @@ insert into worker_auth_ca(private_id) values('roots');
|
||||
create trigger update_version_column after update on worker_auth_ca
|
||||
for each row execute procedure update_version_column(private_id);
|
||||
|
||||
comment on table worker_auth_ca is
|
||||
'worker_auth_ca is a one-row versioned table used for locking for certificate rotation on the worker_auth_ca_certificate table.';
|
||||
|
||||
create table worker_auth_ca_certificate(
|
||||
serial_number numeric,
|
||||
certificate bytea not null
|
||||
@@ -70,13 +69,12 @@ create table worker_auth_ca_certificate(
|
||||
constraint worker_auth_ca_fkey
|
||||
references worker_auth_ca(private_id)
|
||||
);
|
||||
comment on table worker_auth_ca_certificate is
|
||||
'worker_auth_ca_certificate is a table where each row represents a root certificate for used for worker authentication.';
|
||||
|
||||
create trigger immutable_columns before update on worker_auth_ca_certificate
|
||||
for each row execute procedure immutable_columns('serial_number', 'certificate', 'not_valid_before', 'not_valid_after', 'public_key', 'private_key', 'key_id', 'state', 'issuing_ca');
|
||||
|
||||
comment on table worker_auth_ca_certificate is
|
||||
'worker_auth_ca_certificate is a table where each row represents a root certificate for used for worker authentication.';
|
||||
|
||||
create table worker_auth_authorized(
|
||||
worker_key_identifier text primary key, -- The public key id for this WorkerAuth entry, generated from the signing pub key
|
||||
worker_id wt_public_id not null
|
||||
|
||||
@@ -9,7 +9,7 @@ create domain wt_controller_id as text
|
||||
length(trim(value)) > 0
|
||||
);
|
||||
comment on domain wt_controller_id is
|
||||
'A text column that can only be null or not empty representing the id of the controller.';
|
||||
'A text column that can only be null or not empty representing the id of the controller.';
|
||||
|
||||
-- Drop constraint that requires controller_id to be at least 10 chars
|
||||
-- Alters controller_id column defined in 34/02_worker_controller_tables.up.sql
|
||||
|
||||
@@ -34,7 +34,6 @@ begin;
|
||||
'injected_application'
|
||||
)
|
||||
);
|
||||
|
||||
-- update comment on table
|
||||
comment on table credential_purpose_enm is
|
||||
'credential_purpose_enm is an enumeration table for credential purposes. '
|
||||
|
||||
+7
-7
@@ -63,8 +63,8 @@ from credential_vault_store store
|
||||
on store.public_id = cert.store_id;
|
||||
comment on view credential_vault_store_private is
|
||||
'credential_vault_store_private is a view where each row contains a credential store and the credential store''s data needed to connect to Vault. '
|
||||
'The view returns a separate row for each current, maintaining and revoke token; maintaining tokens should only be used for token/credential renewal and revocation. '
|
||||
'Each row may contain encrypted data. This view should not be used to retrieve data which will be returned external to boundary.';
|
||||
'The view returns a separate row for each current, maintaining and revoke token; maintaining tokens should only be used for token/credential renewal and revocation. '
|
||||
'Each row may contain encrypted data. This view should not be used to retrieve data which will be returned external to boundary.';
|
||||
|
||||
-- Replaces view from 10/04_vault_credential.up.sql
|
||||
-- Updated in 44/01_credentials.up.sql
|
||||
@@ -94,7 +94,7 @@ where token_status = 'current'
|
||||
and delete_time is null;
|
||||
comment on view credential_vault_store_public is
|
||||
'credential_vault_store_public is a view where each row contains a credential store. '
|
||||
'No encrypted data is returned. This view can be used to retrieve data which will be returned external to boundary.';
|
||||
'No encrypted data is returned. This view can be used to retrieve data which will be returned external to boundary.';
|
||||
|
||||
-- Replaces view from 39/02_vault_ssh_private_key_override.up.sql
|
||||
-- Replaced in 42/01_ssh_private_key_passphrase.up.sql
|
||||
@@ -151,7 +151,7 @@ from credential_vault_library library
|
||||
and store.token_status = 'current';
|
||||
comment on view credential_vault_library_private is
|
||||
'credential_vault_library_private is a view where each row contains a credential library and the credential library''s data needed to connect to Vault. '
|
||||
'Each row may contain encrypted data. This view should not be used to retrieve data which will be returned external to boundary.';
|
||||
'Each row may contain encrypted data. This view should not be used to retrieve data which will be returned external to boundary.';
|
||||
|
||||
-- Replaces view from 39/02_vault_ssh_private_key_override.up.sql
|
||||
-- Replaced in 42/01_ssh_private_key_passphrase.up.sql
|
||||
@@ -174,7 +174,7 @@ select public_id,
|
||||
from credential_vault_library_private;
|
||||
comment on view credential_vault_library_public is
|
||||
'credential_vault_library_public is a view where each row contains a credential library and any of library''s credential mapping overrides. '
|
||||
'No encrypted data is returned. This view can be used to retrieve data which will be returned external to boundary.';
|
||||
'No encrypted data is returned. This view can be used to retrieve data which will be returned external to boundary.';
|
||||
|
||||
drop view credential_vault_credential_private;
|
||||
-- Replaces view from 10/04_vault_credential.up.sql
|
||||
@@ -221,7 +221,7 @@ from credential_vault_credential credential
|
||||
where credential.expiration_time != 'infinity'::date;
|
||||
comment on view credential_vault_credential_private is
|
||||
'credential_vault_credential_private is a view where each row contains a credential, '
|
||||
'the vault token used to issue the credential, and the credential store data needed to connect to Vault. '
|
||||
'Each row may contain encrypted data. This view should not be used to retrieve data which will be returned external to boundary.';
|
||||
'the vault token used to issue the credential, and the credential store data needed to connect to Vault. '
|
||||
'Each row may contain encrypted data. This view should not be used to retrieve data which will be returned external to boundary.';
|
||||
|
||||
commit;
|
||||
@@ -75,7 +75,7 @@ with
|
||||
and store.token_status = 'current';
|
||||
comment on view credential_vault_library_private is
|
||||
'credential_vault_library_private is a view where each row contains a credential library and the credential library''s data needed to connect to Vault. '
|
||||
'Each row may contain encrypted data. This view should not be used to retrieve data which will be returned external to boundary.';
|
||||
'Each row may contain encrypted data. This view should not be used to retrieve data which will be returned external to boundary.';
|
||||
|
||||
-- Replaces view from 41/01_worker_filter_vault_cred_store.up.sql
|
||||
-- Updated in 44/01_credentials.up.sql
|
||||
@@ -99,6 +99,6 @@ select public_id,
|
||||
from credential_vault_library_private;
|
||||
comment on view credential_vault_library_public is
|
||||
'credential_vault_library_public is a view where each row contains a credential library and any of library''s credential mapping overrides. '
|
||||
'No encrypted data is returned. This view can be used to retrieve data which will be returned external to boundary.';
|
||||
'No encrypted data is returned. This view can be used to retrieve data which will be returned external to boundary.';
|
||||
|
||||
commit;
|
||||
@@ -98,8 +98,8 @@ begin;
|
||||
on store.public_id = cert.store_id;
|
||||
comment on view credential_vault_store_private is
|
||||
'credential_vault_store_private is a view where each row contains a credential store and the credential store''s data needed to connect to Vault. '
|
||||
'The view returns a separate row for each current, maintaining and revoke token; maintaining tokens should only be used for token/credential renewal and revocation. '
|
||||
'Each row may contain encrypted data. This view should not be used to retrieve data which will be returned external to boundary.';
|
||||
'The view returns a separate row for each current, maintaining and revoke token; maintaining tokens should only be used for token/credential renewal and revocation. '
|
||||
'Each row may contain encrypted data. This view should not be used to retrieve data which will be returned external to boundary.';
|
||||
|
||||
-- Replaced in 49/01_vault_credentials.up.sql
|
||||
create view credential_vault_store_public as
|
||||
@@ -128,7 +128,7 @@ begin;
|
||||
and delete_time is null;
|
||||
comment on view credential_vault_store_public is
|
||||
'credential_vault_store_public is a view where each row contains a credential store. '
|
||||
'No encrypted data is returned. This view can be used to retrieve data which will be returned external to boundary.';
|
||||
'No encrypted data is returned. This view can be used to retrieve data which will be returned external to boundary.';
|
||||
|
||||
-- Replaced in 49/01_vault_credentials.up.sql
|
||||
create view credential_vault_library_private as
|
||||
@@ -186,7 +186,7 @@ begin;
|
||||
and store.token_status = 'current';
|
||||
comment on view credential_vault_library_private is
|
||||
'credential_vault_library_private is a view where each row contains a credential library and the credential library''s data needed to connect to Vault. '
|
||||
'Each row may contain encrypted data. This view should not be used to retrieve data which will be returned external to boundary.';
|
||||
'Each row may contain encrypted data. This view should not be used to retrieve data which will be returned external to boundary.';
|
||||
|
||||
-- Replaced in 49/01_vault_credentials.up.sql
|
||||
create view credential_vault_library_public as
|
||||
@@ -209,7 +209,7 @@ begin;
|
||||
from credential_vault_library_private;
|
||||
comment on view credential_vault_library_public is
|
||||
'credential_vault_library_public is a view where each row contains a credential library and any of library''s credential mapping overrides. '
|
||||
'No encrypted data is returned. This view can be used to retrieve data which will be returned external to boundary.';
|
||||
'No encrypted data is returned. This view can be used to retrieve data which will be returned external to boundary.';
|
||||
|
||||
-- Replaces view from 41/01_worker_filter_vault_cred_store.up.sql
|
||||
create view credential_vault_credential_private as
|
||||
@@ -254,7 +254,7 @@ begin;
|
||||
where credential.expiration_time != 'infinity'::date;
|
||||
comment on view credential_vault_credential_private is
|
||||
'credential_vault_credential_private is a view where each row contains a credential, '
|
||||
'the vault token used to issue the credential, and the credential store data needed to connect to Vault. '
|
||||
'Each row may contain encrypted data. This view should not be used to retrieve data which will be returned external to boundary.';
|
||||
'the vault token used to issue the credential, and the credential store data needed to connect to Vault. '
|
||||
'Each row may contain encrypted data. This view should not be used to retrieve data which will be returned external to boundary.';
|
||||
|
||||
commit;
|
||||
@@ -22,7 +22,7 @@ create table auth_oidc_scope (
|
||||
primary key(oidc_method_id, scope)
|
||||
);
|
||||
comment on table auth_oidc_scope is
|
||||
'auth_oidc_scope entries are the optional scopes for a specific oidc auth method. There can be 0 or more for each parent oidc auth method. If an auth method has any scopes, they will be added to provider requests along with the openid default.';
|
||||
'auth_oidc_scope entries are the optional scopes for a specific oidc auth method. There can be 0 or more for each parent oidc auth method. If an auth method has any scopes, they will be added to provider requests along with the openid default.';
|
||||
|
||||
create trigger default_create_time_column before insert on auth_oidc_scope
|
||||
for each row execute procedure default_create_time();
|
||||
@@ -76,6 +76,6 @@ from
|
||||
left outer join auth_oidc_scope cs on am.public_id = cs.oidc_method_id
|
||||
group by am.public_id, is_primary_auth_method; -- there can be only one public_id + is_primary_auth_method, so group by isn't a problem.
|
||||
comment on view oidc_auth_method_with_value_obj is
|
||||
'oidc auth method with its associated value objects (algs, auds, certs, scopes) as columns with | delimited values';
|
||||
'oidc auth method with its associated value objects (algs, auds, certs, scopes) as columns with | delimited values';
|
||||
|
||||
commit;
|
||||
@@ -22,7 +22,7 @@ begin
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
comment on function delete_auth_account_subtype is
|
||||
'delete_auth_account_subtype() is an after trigger function for subytypes of auth_account';
|
||||
'delete_auth_account_subtype() is an after trigger function for subytypes of auth_account';
|
||||
|
||||
create trigger delete_auth_account_subtype after delete on auth_oidc_account
|
||||
for each row execute procedure delete_auth_account_subtype();
|
||||
|
||||
@@ -2,12 +2,16 @@ begin;
|
||||
|
||||
-- Restores the correct comments originally defined in 7/01_functions.up.sql
|
||||
-- but incorrectly overridden in 12/01_timestamp_sub_funcs.up.sql.
|
||||
comment on function wt_add_seconds is 'wt_add_seconds returns ts + sec.';
|
||||
comment on function wt_add_seconds_to_now is 'wt_add_seconds_to_now returns current_timestamp + sec.';
|
||||
comment on function wt_add_seconds is
|
||||
'wt_add_seconds returns ts + sec.';
|
||||
comment on function wt_add_seconds_to_now is
|
||||
'wt_add_seconds_to_now returns current_timestamp + sec.';
|
||||
|
||||
-- Sets comments for functions defined in 12/01_timestamp_sub_funcs.up.sql.
|
||||
comment on function wt_sub_seconds is 'wt_sub_seconds returns ts - sec.';
|
||||
comment on function wt_sub_seconds_from_now is 'wt_sub_seconds_from_now returns current_timestamp - sec.';
|
||||
comment on function wt_sub_seconds is
|
||||
'wt_sub_seconds returns ts - sec.';
|
||||
comment on function wt_sub_seconds_from_now is
|
||||
'wt_sub_seconds_from_now returns current_timestamp - sec.';
|
||||
|
||||
-- Fixes incorrect comments in 2/04_oidc.up.sql
|
||||
comment on table auth_oidc_method is
|
||||
|
||||
@@ -21,7 +21,7 @@ create table auth_oidc_account_claim_map (
|
||||
primary key(oidc_method_id, to_claim)
|
||||
);
|
||||
comment on table auth_oidc_account_claim_map is
|
||||
'auth_oidc_account_claim_map entries are the optional claim maps from custom claims to the standard claims of sub, name and email. There can be 0 or more for each parent oidc auth method.';
|
||||
'auth_oidc_account_claim_map entries are the optional claim maps from custom claims to the standard claims of sub, name and email. There can be 0 or more for each parent oidc auth method.';
|
||||
|
||||
create trigger default_create_time_column before insert on auth_oidc_account_claim_map
|
||||
for each row execute procedure default_create_time();
|
||||
@@ -80,7 +80,7 @@ from
|
||||
left outer join auth_oidc_account_claim_map acm on am.public_id = acm.oidc_method_id
|
||||
group by am.public_id, is_primary_auth_method; -- there can be only one public_id + is_primary_auth_method, so group by isn't a problem.
|
||||
comment on view oidc_auth_method_with_value_obj is
|
||||
'oidc auth method with its associated value objects (algs, auds, certs, scopes) as columns with | delimited values';
|
||||
'oidc auth method with its associated value objects (algs, auds, certs, scopes) as columns with | delimited values';
|
||||
|
||||
|
||||
commit;
|
||||
@@ -10,7 +10,7 @@ begin;
|
||||
stable
|
||||
returns null on null input;
|
||||
comment on function wt_add_seconds is
|
||||
'wt_add_seconds returns ts + sec.';
|
||||
'wt_add_seconds returns ts + sec.';
|
||||
|
||||
create function wt_add_seconds_to_now(sec integer) returns timestamp with time zone
|
||||
as $$
|
||||
@@ -19,6 +19,6 @@ begin;
|
||||
stable
|
||||
returns null on null input;
|
||||
comment on function wt_add_seconds_to_now is
|
||||
'wt_add_seconds_to_now returns current_timestamp + sec.';
|
||||
'wt_add_seconds_to_now returns current_timestamp + sec.';
|
||||
|
||||
commit;
|
||||
@@ -1,36 +1,36 @@
|
||||
begin;
|
||||
|
||||
create domain wt_plugin_id as text not null
|
||||
check(
|
||||
length(trim(value)) > 10 or value = 'pi_system'
|
||||
);
|
||||
check(
|
||||
length(trim(value)) > 10 or value = 'pi_system'
|
||||
);
|
||||
comment on domain wt_plugin_id is
|
||||
'"pi_system", or random ID generated with github.com/hashicorp/go-secure-stdlib/base62';
|
||||
'"pi_system", or random ID generated with github.com/hashicorp/go-secure-stdlib/base62';
|
||||
|
||||
create table plugin (
|
||||
public_id wt_plugin_id primary key
|
||||
public_id wt_plugin_id primary key
|
||||
);
|
||||
comment on table plugin is
|
||||
'plugin is a table where each row represents a unique plugin registered with Boundary.';
|
||||
'plugin is a table where each row represents a unique plugin registered with Boundary.';
|
||||
|
||||
insert into plugin (public_id)
|
||||
values
|
||||
('pi_system');
|
||||
values
|
||||
('pi_system');
|
||||
|
||||
create trigger immutable_columns before update on plugin
|
||||
for each row execute procedure immutable_columns('public_id');
|
||||
for each row execute procedure immutable_columns('public_id');
|
||||
|
||||
create or replace function disallow_system_plugin_deletion() returns trigger
|
||||
as $$
|
||||
begin
|
||||
if old.public_id = 'pi_system' then
|
||||
raise exception 'deletion of system plugin not allowed';
|
||||
end if;
|
||||
return old;
|
||||
if old.public_id = 'pi_system' then
|
||||
raise exception 'deletion of system plugin not allowed';
|
||||
end if;
|
||||
return old;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
create trigger plugin_disallow_system_deletion before delete on plugin
|
||||
for each row execute procedure disallow_system_plugin_deletion();
|
||||
for each row execute procedure disallow_system_plugin_deletion();
|
||||
|
||||
commit;
|
||||
@@ -1,104 +1,104 @@
|
||||
begin;
|
||||
|
||||
create table job (
|
||||
plugin_id wt_plugin_id not null
|
||||
constraint plugin_fk
|
||||
references plugin(public_id)
|
||||
on delete cascade
|
||||
on update cascade,
|
||||
name wt_name not null,
|
||||
description wt_description not null,
|
||||
next_scheduled_run timestamp with time zone not null,
|
||||
primary key (plugin_id, name)
|
||||
plugin_id wt_plugin_id not null
|
||||
constraint plugin_fk
|
||||
references plugin(public_id)
|
||||
on delete cascade
|
||||
on update cascade,
|
||||
name wt_name not null,
|
||||
description wt_description not null,
|
||||
next_scheduled_run timestamp with time zone not null,
|
||||
primary key (plugin_id, name)
|
||||
);
|
||||
comment on table job is
|
||||
'job is a table where each row represents a unique job that can only have one running instance at any specific time.';
|
||||
'job is a table where each row represents a unique job that can only have one running instance at any specific time.';
|
||||
|
||||
create trigger immutable_columns before update on job
|
||||
for each row execute procedure immutable_columns('plugin_id', 'name');
|
||||
for each row execute procedure immutable_columns('plugin_id', 'name');
|
||||
|
||||
create table job_run_status_enm (
|
||||
name text not null primary key
|
||||
constraint only_predefined_job_status_allowed
|
||||
check(name in ('running', 'completed', 'failed', 'interrupted'))
|
||||
name text not null primary key
|
||||
constraint only_predefined_job_status_allowed
|
||||
check(name in ('running', 'completed', 'failed', 'interrupted'))
|
||||
);
|
||||
comment on table job_run_status_enm is
|
||||
'job_run_status_enm is an enumeration table where each row contains a valid job run state.';
|
||||
'job_run_status_enm is an enumeration table where each row contains a valid job run state.';
|
||||
|
||||
insert into job_run_status_enm (name)
|
||||
values
|
||||
('running'),
|
||||
('completed'),
|
||||
('failed'),
|
||||
('interrupted');
|
||||
values
|
||||
('running'),
|
||||
('completed'),
|
||||
('failed'),
|
||||
('interrupted');
|
||||
|
||||
create table job_run (
|
||||
private_id wh_dim_id primary key default wh_dim_id(),
|
||||
job_plugin_id wt_plugin_id not null,
|
||||
job_name wt_name not null,
|
||||
server_id wt_private_id
|
||||
constraint server_fkey
|
||||
references server(private_id)
|
||||
on delete set null
|
||||
on update cascade,
|
||||
create_time wt_timestamp,
|
||||
update_time wt_timestamp,
|
||||
end_time timestamp with time zone,
|
||||
completed_count int not null default 0
|
||||
constraint completed_count_can_not_be_negative
|
||||
check(completed_count >= 0),
|
||||
total_count int not null default 0
|
||||
constraint total_count_can_not_be_negative
|
||||
check(total_count >= 0),
|
||||
status text not null default 'running'
|
||||
constraint job_run_status_enm_fkey
|
||||
references job_run_status_enm (name)
|
||||
on delete restrict
|
||||
on update cascade,
|
||||
private_id wh_dim_id primary key default wh_dim_id(),
|
||||
job_plugin_id wt_plugin_id not null,
|
||||
job_name wt_name not null,
|
||||
server_id wt_private_id
|
||||
constraint server_fkey
|
||||
references server(private_id)
|
||||
on delete set null
|
||||
on update cascade,
|
||||
create_time wt_timestamp,
|
||||
update_time wt_timestamp,
|
||||
end_time timestamp with time zone,
|
||||
completed_count int not null default 0
|
||||
constraint completed_count_can_not_be_negative
|
||||
check(completed_count >= 0),
|
||||
total_count int not null default 0
|
||||
constraint total_count_can_not_be_negative
|
||||
check(total_count >= 0),
|
||||
status text not null default 'running'
|
||||
constraint job_run_status_enm_fkey
|
||||
references job_run_status_enm (name)
|
||||
on delete restrict
|
||||
on update cascade,
|
||||
|
||||
constraint job_run_completed_count_less_than_equal_to_total_count
|
||||
check(completed_count <= total_count),
|
||||
constraint job_run_completed_count_less_than_equal_to_total_count
|
||||
check(completed_count <= total_count),
|
||||
|
||||
constraint job_fkey
|
||||
foreign key (job_plugin_id, job_name)
|
||||
references job (plugin_id, name)
|
||||
on delete cascade
|
||||
on update cascade
|
||||
constraint job_fkey
|
||||
foreign key (job_plugin_id, job_name)
|
||||
references job (plugin_id, name)
|
||||
on delete cascade
|
||||
on update cascade
|
||||
);
|
||||
comment on table job_run is
|
||||
'job_run is a table where each row represents an instance of a job run that is either actively running or has already completed.';
|
||||
'job_run is a table where each row represents an instance of a job run that is either actively running or has already completed.';
|
||||
|
||||
create unique index job_run_status_constraint
|
||||
on job_run (job_plugin_id, job_name)
|
||||
where status = 'running';
|
||||
on job_run (job_plugin_id, job_name)
|
||||
where status = 'running';
|
||||
|
||||
create trigger update_time_column before update on job_run
|
||||
for each row execute procedure update_time_column();
|
||||
for each row execute procedure update_time_column();
|
||||
|
||||
create trigger default_create_time_column before insert on job_run
|
||||
for each row execute procedure default_create_time();
|
||||
for each row execute procedure default_create_time();
|
||||
|
||||
create trigger immutable_columns before update on job_run
|
||||
for each row execute procedure immutable_columns('private_id', 'job_plugin_id', 'job_name', 'create_time');
|
||||
for each row execute procedure immutable_columns('private_id', 'job_plugin_id', 'job_name', 'create_time');
|
||||
|
||||
create view job_jobs_to_run as
|
||||
with
|
||||
running_jobs (job_plugin_id, job_name) as (
|
||||
select job_plugin_id, job_name
|
||||
from job_run
|
||||
where status = 'running'
|
||||
),
|
||||
final (job_plugin_id, job_name, next_scheduled_run) as (
|
||||
select plugin_id, name, next_scheduled_run
|
||||
from job j
|
||||
where next_scheduled_run <= current_timestamp
|
||||
and not exists (
|
||||
select
|
||||
from running_jobs
|
||||
where job_plugin_id = j.plugin_id
|
||||
and job_name = j.name
|
||||
)
|
||||
)
|
||||
select job_plugin_id, job_name, next_scheduled_run from final;
|
||||
create view job_jobs_to_run as
|
||||
with
|
||||
running_jobs (job_plugin_id, job_name) as (
|
||||
select job_plugin_id, job_name
|
||||
from job_run
|
||||
where status = 'running'
|
||||
),
|
||||
final (job_plugin_id, job_name, next_scheduled_run) as (
|
||||
select plugin_id, name, next_scheduled_run
|
||||
from job j
|
||||
where next_scheduled_run <= current_timestamp
|
||||
and not exists (
|
||||
select
|
||||
from running_jobs
|
||||
where job_plugin_id = j.plugin_id
|
||||
and job_name = j.name
|
||||
)
|
||||
)
|
||||
select job_plugin_id, job_name, next_scheduled_run from final;
|
||||
|
||||
commit;
|
||||
Reference in new issue
Block a user