mirror of
https://github.com/YunoHost-Apps/moncycle_ynh.git
synced 2024-09-03 19:46:16 +02:00
Add table migration
This commit is contained in:
parent
bfa1ba2f37
commit
7483cebcca
2 changed files with 28 additions and 0 deletions
17
conf/migrate_7.0.5.sql
Normal file
17
conf/migrate_7.0.5.sql
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
SET NAMES utf8mb4;
|
||||||
|
|
||||||
|
CREATE TABLE `jetton` (
|
||||||
|
`no_jetton` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`no_compte` mediumint(8) unsigned DEFAULT NULL,
|
||||||
|
`nom` varchar(256) COLLATE utf8mb4_bin NOT NULL,
|
||||||
|
`expire` tinyint(1) unsigned NOT NULL DEFAULT 0,
|
||||||
|
`pays` varchar(2) COLLATE utf8mb4_bin DEFAULT NULL,
|
||||||
|
`date_creation` timestamp NOT NULL DEFAULT current_timestamp(),
|
||||||
|
`date_use` timestamp NULL DEFAULT NULL,
|
||||||
|
`jetton_str` varchar(512) COLLATE utf8mb4_bin NOT NULL,
|
||||||
|
`captcha` varchar(16) COLLATE utf8mb4_bin DEFAULT NULL,
|
||||||
|
PRIMARY KEY (`no_jetton`),
|
||||||
|
UNIQUE KEY `jetton_str` (`jetton_str`),
|
||||||
|
KEY `no_compte` (`no_compte`),
|
||||||
|
CONSTRAINT `observation_ibfk_2` FOREIGN KEY (`no_compte`) REFERENCES `compte` (`no_compte`) ON DELETE CASCADE
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
|
|
@ -40,6 +40,17 @@ chown -R $app:www-data "$install_dir"
|
||||||
pushd "$install_dir"
|
pushd "$install_dir"
|
||||||
ynh_exec_warn_less mv ./www_data/* .
|
ynh_exec_warn_less mv ./www_data/* .
|
||||||
ynh_exec_warn_less mv /tmp/config.php .
|
ynh_exec_warn_less mv /tmp/config.php .
|
||||||
|
|
||||||
|
ynh_script_progression --message="Checking if a database migration is needed"
|
||||||
|
if ynh_compare_current_package_version --comparison le --version 7.0~ynh5
|
||||||
|
then
|
||||||
|
ynh_script_progression --message="Database migration required, migrating"
|
||||||
|
ynh_add_config --template="../conf/migrate_7.0.5.sql" --destination="$install_dir/migrate.sql"
|
||||||
|
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < migrate.sql
|
||||||
|
else
|
||||||
|
ynh_script_progression --message="Database migration not required"
|
||||||
|
fi
|
||||||
|
|
||||||
popd
|
popd
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
Loading…
Add table
Reference in a new issue