1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/wikijs_ynh.git synced 2024-09-03 20:36:09 +02:00

switch from MySQL to PostgreSQL

MySQL version not compatible. version provided: 10.1.37 / version requested: 10.2.7
This commit is contained in:
Yalh 2019-01-30 00:59:43 +01:00
parent f842945c5f
commit 8a1f103115
6 changed files with 23 additions and 18 deletions

View file

@ -30,8 +30,8 @@ bindIP: 0.0.0.0
db: db:
type: mysql type: mysql
# PostgreSQL / MySQL / MariaDB / MS SQL Server only: # PostgreSQL / MySQL / MariaDB / MS SQL Server only:
host: localhost host: postgres
port: 3306 port: 5432
user: __DB_NAME__ user: __DB_NAME__
pass: __DB_PWD__ pass: __DB_PWD__
db: __DB_NAME__ db: __DB_NAME__

View file

@ -19,8 +19,7 @@
}, },
"multi_instance": true, "multi_instance": true,
"services": [ "services": [
"nginx", "nginx"
"mysql"
], ],
"arguments": { "arguments": {
"install" : [ "install" : [

View file

@ -51,10 +51,10 @@ ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
#ynh_backup "/etc/php5/fpm/pool.d/$app.conf" #ynh_backup "/etc/php5/fpm/pool.d/$app.conf"
#================================================= #=================================================
# BACKUP THE MYSQL DATABASE # BACKUP THE POSTGRESQL DATABASE
#================================================= #=================================================
ynh_mysql_dump_db "$db_name" > db.sql ynh_psql_dump_db "$db_name" > db.sql
#================================================= #=================================================
# SPECIFIC BACKUP # SPECIFIC BACKUP

View file

@ -100,7 +100,7 @@ ynh_install_app_dependencies redis-server
ynh_install_nodejs 10 ynh_install_nodejs 10
#================================================= #=================================================
# CREATE A MYSQL DATABASE # CREATE A POSTGRESQL DATABASE
#================================================= #=================================================
### Use these lines if you need a database for the application. ### Use these lines if you need a database for the application.
@ -108,13 +108,17 @@ ynh_install_nodejs 10
### The password will be stored as 'mysqlpwd' into the app settings, ### The password will be stored as 'mysqlpwd' into the app settings,
### and will be available as $db_pwd ### and will be available as $db_pwd
### If you're not using these lines: ### If you're not using these lines:
### - Remove the section "BACKUP THE MYSQL DATABASE" in the backup script ### - Remove the section "BACKUP THE POSTGRESQL DATABASE" in the backup script
### - Remove also the section "REMOVE THE MYSQL DATABASE" in the remove script ### - Remove also the section "REMOVE THE POSTGRESQL DATABASE" in the remove script
### - As well as the section "RESTORE THE MYSQL DATABASE" in the restore script ### - As well as the section "RESTORE THE POSTGRESQL DATABASE" in the restore script
db_name=$(ynh_sanitize_dbid $app) db_name=$(ynh_sanitize_dbid $app)
ynh_app_setting_set $app db_name $db_name db_pwd=$(ynh_string_random 30)
ynh_mysql_setup_db $db_name $db_name ynh_app_setting_set "$app" psql_db "$db_name"
ynh_app_setting_set "$app" psqlpwd "$db_pwd"
ynh_psql_test_if_first_run
ynh_psql_create_user "$db_name" "$db_pwd"
ynh_psql_create_db "$db_name" "$db_name" "$db_pwd"
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE

View file

@ -51,11 +51,11 @@ ynh_use_nodejs
ynh_remove_nodejs ynh_remove_nodejs
#================================================= #=================================================
# REMOVE THE MYSQL DATABASE # REMOVE THE POSTGRESQL DATABASE
#================================================= #=================================================
# Remove a database if it exists, along with the associated user # Remove a database if it exists, along with the associated user
ynh_mysql_remove_db $db_user $db_name ynh_psql_remove_db "$db_name" "$db_name"
#================================================= #=================================================
# REMOVE APP MAIN DIR # REMOVE APP MAIN DIR

View file

@ -55,12 +55,14 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore_file "$final_path" ynh_restore_file "$final_path"
#================================================= #=================================================
# RESTORE THE MYSQL DATABASE # RESTORE THE POSTGRESQL DATABASE
#================================================= #=================================================
db_pwd=$(ynh_app_setting_get $app mysqlpwd) ynh_install_app_dependencies postgresql postgresql-contrib
ynh_mysql_setup_db $db_name $db_name $db_pwd ynh_psql_test_if_first_run
ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql ynh_psql_create_user "$db_name" "$db_pwd"
ynh_psql_create_db "$db_name" "$db_name" "$db_pwd"
ynh_psql_execute_file_as_root ./db.sql "$db_name"
#================================================= #=================================================
# RECREATE THE DEDICATED USER # RECREATE THE DEDICATED USER