Files
threshold/internal/db/schema/migrations/oss/postgres/8/01_connection.up.sql
T
Timothy Messier 8caaf3e076 refactor(schema): Add support for migration editions
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
2021-10-08 06:50:26 -04:00

26 lines
636 B
PL/PgSQL

begin;
alter table session_connection
add column server_id text;
-- Note: here, and in the session table, we should add a trigger ensuring that
-- if server_id goes to null, we mark connections as closed. See
-- https://hashicorp.atlassian.net/browse/ICU-1495
alter table session_connection
add constraint server_fkey
foreign key (server_id)
references server (private_id)
on delete set null
on update cascade;
-- We now populate the connection information from existing session information
update session_connection sc
set
server_id = s.server_id
from
session s
where
sc.session_id = s.public_id;
commit;