From 3bb697888bc26cea0309c512aaf434890767c1aa Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Fri, 22 May 2020 09:10:20 +0200 Subject: [PATCH] move to postgres --- conf/.sequelizerc.example | 2 +- conf/config.json.example | 6 +++--- scripts/_common.sh | 2 +- scripts/backup | 4 ++-- scripts/install | 4 +++- scripts/remove | 6 +++--- scripts/restore | 10 +++++----- scripts/upgrade | 2 +- 8 files changed, 19 insertions(+), 17 deletions(-) diff --git a/conf/.sequelizerc.example b/conf/.sequelizerc.example index 29b59f2..45ef120 100644 --- a/conf/.sequelizerc.example +++ b/conf/.sequelizerc.example @@ -4,5 +4,5 @@ module.exports = { 'config': path.resolve('config.json'), 'migrations-path': path.resolve('lib', 'migrations'), 'models-path': path.resolve('lib', 'models'), - 'url': 'mysql://__DB_USER__:__DB_PASS__@localhost:3306/__DB_NAME__' + 'url': 'postgres://__DB_USER__:__DB_PASS__@localhost:5432/__DB_NAME__' } diff --git a/conf/config.json.example b/conf/config.json.example index 52a4cd3..a6dc5a0 100644 --- a/conf/config.json.example +++ b/conf/config.json.example @@ -27,8 +27,8 @@ "password": "__DB_PASS__", "database": "__DB_NAME__", "host": "localhost", - "port": "3306", - "dialect": "mysql" + "port": "5432", + "dialect": "postgres" } } -} \ No newline at end of file +} diff --git a/scripts/_common.sh b/scripts/_common.sh index 53e412e..b113120 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,7 @@ #================================================= # dependencies used by the app -pkg_dependencies="apt-transport-https" +pkg_dependencies="postgresql apt-transport-https" nodejs_version="10" diff --git a/scripts/backup b/scripts/backup index 5dff667..1033992 100644 --- a/scripts/backup +++ b/scripts/backup @@ -50,11 +50,11 @@ ynh_backup --src_path="$final_path" ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= -# BACKUP THE MYSQL DATABASE +# BACKUP THE DATABASE #================================================= ynh_print_info --message="Backing up the database..." -ynh_mysql_dump_db --database="$db_name" > db.sql +ynh_psql_dump_db --database="$db_name" > db.sql #================================================= # SPECIFIC BACKUP diff --git a/scripts/install b/scripts/install index 050bd6a..83fdb4d 100644 --- a/scripts/install +++ b/scripts/install @@ -80,8 +80,10 @@ ynh_script_progression --message="Creating a database..." --weight=2 db_name=$(ynh_sanitize_dbid --db_name=$app) db_user=$db_name + +ynh_psql_test_if_first_run ynh_app_setting_set --app="$app" --key="db_name" --value="$db_name" -ynh_mysql_setup_db --db_user="$db_user" --db_name="$db_name" +ynh_psql_setup_db --db_user="$db_user" --db_name="$db_name" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE diff --git a/scripts/remove b/scripts/remove index f00aabe..512eea8 100644 --- a/scripts/remove +++ b/scripts/remove @@ -34,12 +34,12 @@ ynh_script_progression --message="Stopping and removing the systemd service..." ynh_remove_systemd_config #================================================= -# REMOVE THE MYSQL DATABASE +# REMOVE THE DATABASE #================================================= -ynh_script_progression --message="Removing the MySQL database..." --weight=2 +ynh_script_progression --message="Removing the database..." --weight=2 # Remove a database if it exists, along with the associated user -ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name +ynh_psql_remove_db --db_user=$db_user --db_name=$db_name #================================================= # REMOVE DEPENDENCIES diff --git a/scripts/restore b/scripts/restore index 10c5513..caf90d2 100644 --- a/scripts/restore +++ b/scripts/restore @@ -89,13 +89,13 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st ynh_exec_warn_less ynh_install_nodejs --nodejs_version="$nodejs_version" #================================================= -# RESTORE THE MYSQL DATABASE +# RESTORE THE DATABASE #================================================= -ynh_script_progression --message="Restoring the MySQL database..." --weight=6 +ynh_script_progression --message="Restoring the database..." --weight=6 -db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) -ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd -ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql +db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) +ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd +ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql #================================================= # RESTORE SYSTEMD diff --git a/scripts/upgrade b/scripts/upgrade index 440d42f..b275458 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -24,7 +24,7 @@ port=$(ynh_app_setting_get --app=$app --key=port) db_name=$(ynh_app_setting_get --app=$app --key=app) db_user=$(ynh_app_setting_get --app=$app --key=app) -db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) +db_pwd=$(ynh_app_setting_get --app=$app --key=psqlwd) #================================================= # CHECK VERSION