Files
ubicloud/rhizome/postgres/bin/initialize-empty-database
Burak Yucesoy 31ef6bf0b9 Update data plane Postgres scripts to accept version as parameter
We used to hardcode 16 as the version, mostly while generating paths. With the
PG17 support, those paths changed to contain 17 instead of 16. Data plane does
not know the installed PostgreSQL version, so it needs that information from
control plane. With this commit we are updating data plane scripts to accept
version parameter from control plane.
2024-10-25 13:44:27 +03:00

22 lines
545 B
Ruby
Executable File

#!/bin/env ruby
# frozen_string_literal: true
require_relative "../../common/lib/util"
if ARGV.count != 1
fail "Wrong number of arguments. Expected 1, Given #{ARGV.count}"
end
v = ARGV[0]
r "chown postgres /dat"
# Below commands are required for idempotency
r "rm -rf /dat/#{v}"
r "rm -rf /etc/postgresql/#{v}"
r "pg_createcluster #{v} main --start --locale=C.UTF8"
r "sudo -u postgres psql -c 'CREATE ROLE ubi_replication WITH REPLICATION LOGIN'"
r "sudo -u postgres psql -c 'CREATE ROLE ubi_monitoring WITH LOGIN IN ROLE pg_monitor'"