Improve migration script

This commit is contained in:
Frédéric Guillot 2017-12-29 15:17:38 -08:00
parent d2301e6677
commit 88767d130b
3 changed files with 8 additions and 7 deletions

3
.gitattributes vendored
View File

@ -10,7 +10,8 @@ app/constants.php export-subst
# core
data/*.sqlite export-ignore
scripts export-ignore
scripts/find-locales.php export-ignore
scripts/sync-locales.php export-ignore
Dockerfile export-ignore
.travis.yml export-ignore
hooks export-ignore

View File

@ -1,7 +1,7 @@
Miniflux - Minimalist News Reader
=================================
[![Build Status](https://travis-ci.org/miniflux/miniflux.svg?branch=master)](https://travis-ci.org/miniflux/miniflux)
[![Build Status](https://travis-ci.org/miniflux/miniflux-legacy.svg?branch=master)](https://travis-ci.org/miniflux/miniflux-legacy)
Miniflux is a minimalist and web-based RSS reader.

View File

@ -27,7 +27,7 @@ function migrate_user(PDO $dst, array $user, array $settings)
language
) VALUES (?, ?, ?, ?) RETURNING id');
$rq->execute(array(
$user['username'],
strtolower($user['username']),
$user['password'],
$user['is_admin'] == 1 ? 1 : 0,
isset($settings['language']) && $settings['language'] == 'fr_FR' ? 'fr_FR' : 'en_US',
@ -76,9 +76,9 @@ function migrate_integrations(PDO $dst, $dst_user_id, array $user, array $settin
isset($settings['wallabag_username']) ? $settings['wallabag_username'] : '',
isset($settings['wallabag_password']) ? $settings['wallabag_password'] : '',
1,
$user['username'],
isset($settings['fever_token']) ? $settings['fever_token'] : '',
isset($settings['fever_api_key']) ? $settings['fever_api_key'] : '',
strtolower($user['username']),
isset($user['fever_token']) ? $user['fever_token'] : '',
isset($user['fever_api_key']) ? $user['fever_api_key'] : '',
));
}
@ -214,7 +214,7 @@ $srcDB = PicoDb\Database::getInstance('db')->getConnection();
try {
$dstDB->beginTransaction();
$rq = $srcDB->prepare('SELECT id, username, password, is_admin, fever_token FROM users');
$rq = $srcDB->prepare('SELECT id, username, password, is_admin, fever_token, fever_api_key FROM users');
$rq->execute();
$users = $rq->fetchAll(PDO::FETCH_ASSOC);
echo '* '.count($users).' user(s) to migrate'.PHP_EOL;