migrations: add OWNED BY for sequence

The OWNED BY option causes the sequence to be associated with a specific
table column, such that if that column (or its whole table) is dropped,
the sequence will be automatically dropped as well.

Change-Id: Ieedbf0a93e3fd7f7567417f128f291c53f3358d8
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/296449
Trust: Julie Qiu <julie@golang.org>
Run-TryBot: Julie Qiu <julie@golang.org>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
This commit is contained in:
Julie Qiu 2021-02-25 12:48:48 -05:00
Родитель 41ca6b309e
Коммит bba1b80fb0
2 изменённых файлов: 1 добавлений и 1 удалений

Просмотреть файл

@ -9,6 +9,5 @@ ALTER TABLE documentation DROP COLUMN new_goos;
ALTER TABLE documentation DROP COLUMN new_goarch;
DROP TRIGGER documentation_id_update ON documentation;
DROP FUNCTION update_documentation_id;
DROP SEQUENCE sequence_documentation_id;
END;

Просмотреть файл

@ -15,6 +15,7 @@ BEGIN
RETURN NEW;
END
$BODY$ LANGUAGE PLPGSQL;
ALTER SEQUENCE sequence_documentation_id OWNED BY documentation.id;
CREATE TRIGGER documentation_id_update
BEFORE INSERT OR UPDATE ON documentation