From 9da2c9381a46cecf4e3002a5520d3cbb2d8c1bba Mon Sep 17 00:00:00 2001 From: Sebastian Hugentobler Date: Sat, 2 Nov 2019 14:41:53 +0100 Subject: [PATCH] fix user id sequence in postgre --- rootfs/etc/cont-init.d/02-fix-postgre-schema | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 rootfs/etc/cont-init.d/02-fix-postgre-schema diff --git a/rootfs/etc/cont-init.d/02-fix-postgre-schema b/rootfs/etc/cont-init.d/02-fix-postgre-schema new file mode 100644 index 0000000..b784468 --- /dev/null +++ b/rootfs/etc/cont-init.d/02-fix-postgre-schema @@ -0,0 +1,6 @@ +#!/usr/bin/with-contenv sh + +if [ "$DB_TYPE" == "postgres" ]; then + psql --host "$DB_HOST" --port "$DB_PORT" --username "$DB_USER" --dbname "$DB_NAME" --command \ + "CREATE SEQUENCE IF NOT EXISTS users_id_seq AS integer START 1 OWNED BY users.id; ALTER TABLE users ALTER COLUMN id SET DEFAULT nextval('users_id_seq');" +fi