Retrieving PR #14272 (and #10991) to fix the PostgreSQL exporter and importer bugs.
This PR can be tested with any database driver supported by Joomla.
This is about exporting and importing any database with a command-line interface (it can be placed in cronjob to schedule the database backup).
Summary of Changes
Fix folder path.
Fix postgresql issues :
Fix the default value of the table.
Gets, sets the last_value and is_called sequence attributes.
Fix key query.
Fix text default value.
Apply changes to unit tests.
Fix the execution of queries (xmlToCreate) with the pgsql (PDO) driver.
Add unique constraints.
Convert PostgreSQL BLOB data (bytea).
Testing Instructions
Select a database driver and save it in System -> Global Configuration -> Server ->Database Type
Go to the cli folder of your website.
Export all tables and data to the folder : php exporter.php --all --folder <folder_path>
Delete and create an empty database with the same name.
Overwriting the database can also be done. Verify that changes are applied.
Import all from folder: php importer.php --all --folder <folder_path>
You can also :
Export all tables and data in zip file : php exporter.php --all --mode zip
Export a table : php exporter.php --table <table_name>
Export a table as a .zip file : php exporter.php --table <table_name> --mode zip
Import a table : php importer.php --table <table_name>
Expected result
Export/import tables with structure (keys, constraints, sequences) and data.
Actual result
Does not export/import views, stored procedures and triggers (optional for the Joomla database).
PostgreSQL automatically creates a unique index when a unique constraint or primary key is defined for a table. We need to modify table by adding a unique constraint on a column, instead of creating a unique index.
This query creates unique index:
The test can be performed with the postgresql PDO or "native" driver.
I suppose that the test with the mysql driver has already been successfully passed in PR #14272, @BombatiK should test again (the folder path has been fixed), and has not yet been tested with sqlsrv.
PostgreSQL automatically creates a unique index when a unique constraint or primary key is defined for a table. We need to modify table by adding a unique constraint on a column, instead of creating a unique index.
This query creates unique index:
joomla-cms/libraries/joomla/database/importer/postgresql.php
Line 152 in be51ebe
Here, a unique constraint is defined for a table:
joomla-cms/libraries/joomla/database/importer/mysqli.php
Line 114 in be51ebe