YunoHost-Apps / Experimental_helpers

6 stars 12 forks source link

ynh_psql_execute_as_root : Missing db in the command #25

Closed anmol26s closed 5 years ago

anmol26s commented 6 years ago

Hi The ynh_psql_execute_as_root is missing db name in the command. see https://github.com/YunoHost-Apps/Experimental_helpers/blob/master/postgres/postgres#L71

Because of this I can not create an extension for a specific database. So ynh_psql_execute_as_root "CREATE EXTENSION IF NOT EXISTS unaccent;" "$db_name"

don't work for peertube.

JimboJoe commented 6 years ago

I worked around that one in Discourse: https://github.com/YunoHost-Apps/discourse_ynh/blob/master/scripts/install#L89-L90 :

ynh_psql_execute_as_root "\connect $db_name
CREATE EXTENSION IF NOT EXISTS hstore; CREATE EXTENSION IF NOT EXISTS pg_trgm;"

Yet that should be changed to be analogous with the MySQL helper.

anmol26s commented 6 years ago

@JimboJoe Thanks This worked. I agree we should fix the psql command. Maybe @Jibec and @maniackcrudelis can have a look at it?

Jibec commented 6 years ago

I'm unsure all commands needs a database, but I'm fine if you fix this either by telling how to select the db if relevant or by adding the $db parameter.

Btw, this helper is now part of core, but there were no public announce because of lack of enough testing (this is quite an important helper): https://github.com/YunoHost/yunohost/blob/stretch-unstable/data/helpers.d/psql

yalh76 commented 5 years ago

ynh_psql_execute_as_root is now an official helper and include a database argument ynh_psql_execute_as_root --sql=sql [--database=database]

Issue can be closed ^^

anmol26s commented 5 years ago

Thanks for the information. Closing this.