This refactors the schema package and subpackages to support editions.
An Edition is a collection of sql migrations. A given boundary binary
can have multiple migration editions. The `schema.Manager` is updated to
apply the necessary migrations in the correct order, leveraging an
Edition's priority to determine the order in which the separate Editions
are applied.
The sql migration files are now nested under a directory for the
edition.
This also switches from the generated code to using embed, which
eliminates the need for the `make migrations` target and the generated
code. As such this commit removes the target and generated code.
See:
https://pkg.go.dev/embed
37 lines
1.1 KiB
PL/PgSQL
37 lines
1.1 KiB
PL/PgSQL
begin;
|
|
|
|
update credential_vault_credential
|
|
set external_id = concat(external_id, u&'\ffff')
|
|
where wt_is_sentinel(external_id)
|
|
and not starts_with(reverse(external_id), u&'\ffff');
|
|
|
|
alter domain wt_sentinel
|
|
drop constraint wt_sentinel_not_valid;
|
|
|
|
drop function wt_is_sentinel;
|
|
|
|
create function wt_is_sentinel(string text)
|
|
returns bool
|
|
as $$
|
|
select starts_with(string, u&'\fffe') and starts_with(reverse(string), u&'\ffff');
|
|
$$ 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';
|
|
|
|
alter domain wt_sentinel
|
|
add constraint wt_sentinel_not_valid
|
|
check(
|
|
wt_is_sentinel(value)
|
|
or
|
|
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';
|
|
|
|
drop function wt_to_sentinel; -- wt_to_sentinel is not needed, dropping and not re-creating
|
|
|
|
commit;
|