CLI to export/import any database to/from SQLite (#2496)

* CLI to export/import any database to/from SQLite

Require PHP 5.5+ https://github.com/FreshRSS/FreshRSS/pull/2495

* Travis

* Execution rights

* Fix wrong static fields

* Fix MySQL bad default buffering

https://stackoverflow.com/questions/6895098/pdo-mysql-memory-consumption-with-large-result-set/6935271#6935271
https://php.net/manual/ref.pdo-mysql

* Fix count on progression

* Avoid static DB information

To ease working with two DBs at the same time

* Less static, simplify

Needs some testing

* Small corrections

* Special case for SQLite to SQLite

* Modify special case for SQLite

* Remove special case for SQLite

More uniform logic for the 3 databases.
Fix wrong DROP TABLE for SQLite.

* Drop indexes

* Revert "Drop indexes"

This reverts commit f28d2bae09.

* Fix deletion

* Fix classic export

* Update cli/README.md

Co-Authored-By: Marien Fressinaud <dev@marienfressinaud.fr>

* Addressing part of review

* Remove goto 😢

* Travis

* Comment for SQLite case

* Fix missing fields when inserting
This commit is contained in:
Alexandre Alapetite
2019-09-15 21:36:53 +02:00
committed by GitHub
parent acec70fdbc
commit c76a318193
16 changed files with 421 additions and 83 deletions

View File

@@ -91,7 +91,7 @@ $SQL_CREATE_TABLE_TAGS = array(
);',
'CREATE TABLE IF NOT EXISTS `entrytag` (
`id_tag` SMALLINT,
`id_entry` SMALLINT,
`id_entry` BIGINT,
PRIMARY KEY (`id_tag`,`id_entry`),
FOREIGN KEY (`id_tag`) REFERENCES `tag` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY (`id_entry`) REFERENCES `entry` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
@@ -105,4 +105,12 @@ define(
VALUES(:url, 1, :name, :website, :description, 86400);'
);
define('SQL_DROP_TABLES', 'DROP TABLE IF EXISTS `entrytag`, `tag`, `entrytmp`, `entry`, `feed`, `category`');
global $SQL_DROP_TABLES;
$SQL_DROP_TABLES = [
'DROP TABLE IF EXISTS `entrytag`',
'DROP TABLE IF EXISTS `tag`',
'DROP TABLE IF EXISTS `entrytmp`',
'DROP TABLE IF EXISTS `entry`',
'DROP TABLE IF EXISTS `feed`',
'DROP TABLE IF EXISTS `category`',
];