? ? Pending

User tests: Successful: Unsuccessful:

avatar alikon
alikon
28 Feb 2017

Summary of Changes

this is the continuation of the work made by @Hackwar #10991

  • added the driver pdomysql,postgresql,sqlsrv
  • added a cli script for testing purpose and as an example of how to use

Testing Instruction

you can run the cli script to export tables

  • php exporter.php --all --folder <folder_path>
    export all tables and data to the folder

  • php exporter.php --all --mode zip
    export all tables and data in zip file

  • php exporter.php --table <table_name>
    export table name

  • php exporter.php --table <table_name> --mode zip
    export table name as a .zip file

you can run the cli script to import tables

  • php importer.php --all --folder <folder_path>
    import all from folder
  • php importer.php --table <table_name>
    import table
avatar alikon alikon - open - 28 Feb 2017
avatar alikon alikon - change - 28 Feb 2017
Status New Pending
avatar alikon alikon - edited - 28 Feb 2017
avatar joomla-cms-bot joomla-cms-bot - change - 28 Feb 2017
Category CLI Libraries Postgresql MS SQL
avatar alikon alikon - change - 28 Feb 2017
The description was changed
Labels Added: ?
99a2e38 28 Feb 2017 avatar alikon cs
3b731b4 2 Mar 2017 avatar alikon typo
avatar alikon alikon - change - 5 Mar 2017
Title
[importer - exporter] - jdatabase importer exporter
[jdatabase] - importer exporter
avatar alikon alikon - edited - 5 Mar 2017
avatar alikon alikon - change - 5 Mar 2017
The description was changed
avatar alikon alikon - edited - 5 Mar 2017
avatar joomla-cms-bot joomla-cms-bot - change - 6 Mar 2017
Category CLI Libraries Postgresql MS SQL CLI Libraries Postgresql MS SQL Unit Tests
avatar alikon alikon - change - 6 Mar 2017
Labels Added: ?
avatar zero-24
zero-24 - comment - 6 Mar 2017

@alikon i have found a few more places ;)

avatar alikon
alikon - comment - 6 Mar 2017

@zero-24 should be fixed now

avatar zero-24
zero-24 - comment - 6 Mar 2017

@alikon i have fixed some missing deploy version things ;)

avatar infograf768
infograf768 - comment - 28 Mar 2017

Should #10991 be closed ?

avatar alikon
alikon - comment - 28 Mar 2017

can be closed cause this pr include all from #10991

avatar BombatiK BombatiK - test_item - 23 Jul 2018 - Tested unsuccessfully
avatar BombatiK
BombatiK - comment - 23 Jul 2018

I have tested this item ? unsuccessfully on 696715d

i have tested it giving my own folder_path, but it always create a folder dbdump where it sets the result.
Is it the right way?
@icampus


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/14272.

avatar jonasgonka jonasgonka - test_item - 24 Jul 2018 - Tested successfully
avatar jonasgonka
jonasgonka - comment - 24 Jul 2018

I have tested this item successfully on 696715d

Tested successfully on Windows.

Command php exporter.php --all --folder C:\Users\user\Desktop\tables\ created the folder tables as expected.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/14272.
avatar alikon
alikon - comment - 24 Jul 2018

@BombatiK can you show me the command that you have used ?

avatar BombatiK
BombatiK - comment - 24 Jul 2018

@alikon
php exporter.php --all --folder C:\xampp\htdocs\joomla2\cli\db

@icampus

avatar alikon
alikon - comment - 24 Jul 2018

sorry but don't understand is the same command issued by @jonasgonka

avatar jonasgonka
jonasgonka - comment - 24 Jul 2018

I think the problem is that he is missing the last backslash.
Maybe it would be better to switch to using actual directories in the script instead of just the strings.

avatar twister65
twister65 - comment - 9 Dec 2018

Exporter works fine (without error) when I include a slash (backslash with Window) at the end of the folder.
Importer gives no error.
But after all, when I try to write in the database, creating an article for example, I have this error :

Error
Save failed with the following error: ERROR: null value in column "id" violates not-null constraint

I did my test with the postgresql driver.

avatar twister65
twister65 - comment - 9 Dec 2018

Is it possible to use the importer directly with a zip file previously created by the exporter ?

avatar twister65
twister65 - comment - 9 Dec 2018

Importer failed with the PostgreSQL PDO driver :

DbImporterCli
============================
Importing gvcms_action_log_config from gvcms_action_log_config.xml
Reading data from gvcms_action_log_config.xml
Drop gvcms_action_log_config
Error on mergeStructuregvcms_action_log_config.xml JDatabaseExceptionExecuting: 00000, , in /var/www/html/avenirdurable/libraries/joomla/database/driver/pdo.php:475
Stack trace:
#0 /var/www/html/avenirdurable/libraries/joomla/database/importer.php(251): JDatabaseDriverPdo->execute()
#1 /var/www/html/avenirdurable/cli/importer.php(139): JDatabaseImporter->mergeStructure()
#2 /var/www/html/avenirdurable/libraries/src/Application/CliApplication.php(143): DbImporterCli->doExecute()
#3 /var/www/html/avenirdurable/cli/importer.php(170): Joomla\CMS\Application\CliApplication->execute()
#4 {main}

avatar twister65
twister65 - comment - 9 Dec 2018

@jonasgonka , could you specify which database driver you used ?

avatar twister65
twister65 - comment - 9 Dec 2018

#14272 (comment)

Structure parameters are missing.

gvcms_content_id_seq is incorrect in the postgresql database.
We should have yes (instead of no) for

Will increment last value before returning next value (is_called)?

Last value is 1 instead of 30 (in my test case).

In addition, the gvcms_content table is incomplete in the postgresql database. We have no default value. For id, this should be:

nextval('public.gvcms_content_id_seq'::regclass)

avatar twister65
twister65 - comment - 9 Dec 2018

Please, replace ($field->default):

(isset($field->default) ? ' Default="' . $field->default . '"' : '') . ' Comments="' . $field->comments . '"' .

by ($field->Default):
(isset($field->Default) ? ' Default="' . $field->Default . '"' : '') . ' Comments="' . $field->comments . '"' .

It fixes (#14272 (comment)):

We have no default value.

avatar twister65
twister65 - comment - 9 Dec 2018

We could add Is_called="YES at the sequence:

' Cycle_option="' . $sequence->cycle_option . '"' .

' Cycle_option="' . $sequence->cycle_option . '"' . ' Is_called="YES"' .

avatar twister65
twister65 - comment - 9 Dec 2018

We have to clean default value, adding:
$cDefault = strstr($field['Default'], '::', true);
if ($cDefault != false) { $field['Default'] = $cDefault; }
before:

$fDefault = (isset($field['Default']) && $field['Default'] != 'NULL') ?
preg_match('/^[0-9]$/', $field['Default']) ? $field['Default'] : $this->db->quote((string) $field['Default'])
: null;

avatar twister65
twister65 - comment - 10 Dec 2018

Modify :

return 'CREATE SEQUENCE ' . (string) $field['Name'] .

return 'CREATE SEQUENCE IF NOT EXISTS ' . (string) $field['Name'] .

avatar alikon
alikon - comment - 11 Dec 2018

@twister65 sorry for not be so responsive in these days,
yes the postgresql import/export need a little bit more care, hope i should be more free in the next weeks

avatar twister65
twister65 - comment - 13 Dec 2018

PostgreSQL.
The last value in the sequences is not defined (1). When a new row is added to a table, the id is incorrect (1).

avatar twister65
twister65 - comment - 16 Dec 2018

Thanks @alikon , could you modify the cli script to add a driver parameter ?
For example, migrate a PostgreSQL database (export) to a MySQL database (import).
I appreciate this PR, especially since Akeeba Backup does not support PostgreSQL.
In addition, I plan to migrate my PostgreSQL database to MySQL.
I hope it will work well someday. I expect a lot from this PR.
Regards.

avatar brianteeman
brianteeman - comment - 16 Dec 2018

I appreciate this PR, especially since Akeeba Backup does not support PostgreSQL.

It does

avatar twister65
twister65 - comment - 16 Dec 2018

Akeeba Database backup engine is :

  • Native MySQL backup engine
    or
  • Reverse engineering database dump engine.

There is no Native PostgreSQL engine. I never succeeded to make reverse engineering work.
Instead I use pg_dump to make a backup.

avatar alikon
alikon - comment - 13 Jan 2019

closed in favour of #23320

avatar alikon alikon - change - 13 Jan 2019
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2019-01-13 08:07:10
Closed_By alikon
avatar alikon alikon - close - 13 Jan 2019

Add a Comment

Login with GitHub to post a comment