Skip to content

installers.db.postgresql #

postgresql

see the clients.postgresql for much more functionality

use psql

uses our hero configure output and jq command line trick

#export PGPASSWORD=`hero configure -c postgres -i default -s | jq -r '.passwd'`
psql -U 'root' -h localhost

to use in other installer


//e.g. in server configure function

import freeflowuniverse.crystallib.installers.db.postgresql
mut db := postgresql.get(server.config.postgresql_name)!

// now create the DB
db.db_create('gitea')!

fn requirements #

fn requirements() !

fn start #

fn start(args_ Config) !Server

get the postgres server

 name        string = 'default'
 path        string = '/data/postgresql'
 passwd      string

if name exists already in the config DB, it will load for that name

fn uninstall #

fn uninstall() !

remove postgresql from the system

struct Config #

@[params]
struct Config {
pub mut:
	name   string = 'default'
	path   string // /data/postgresql/${name} for linux /hero/var/postgresql/${args.name} for osx
	passwd string @[required]
}

struct Server #

struct Server {
pub mut:
	name        string
	config      Config
	path_config pathlib.Path
	path_data   pathlib.Path
	path_export pathlib.Path
}

fn (Server) start #

fn (mut server Server) start() !

run postgresql as docker compose

fn (Server) restart #

fn (mut server Server) restart() !

fn (Server) stop #

fn (mut server Server) stop() !

fn (Server) check #

fn (mut server Server) check() !

check health, return true if ok

fn (Server) ok #

fn (mut server Server) ok() bool

check health, return true if ok

fn (Server) db_exists #

fn (mut server Server) db_exists(name_ string) !bool

fn (Server) db_create #

fn (mut server Server) db_create(name_ string) !

fn (Server) db_delete #

fn (mut server Server) db_delete(name_ string) !

fn (Server) destroy #

fn (mut server Server) destroy() !

remove all data