Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Allow to import databases different than the default one - db-import command #49

Conversation

rigoucr
Copy link
Contributor

@rigoucr rigoucr commented Apr 4, 2022

This PR provide a new option to allow users to import databases different than the default one.

Issue Reference

Issue Number: #

What does this Pull Request do?

How can this Pull Request be tested?

Any additional notes/comments?

@rigoucr rigoucr changed the title Initial implementation for new optional parameter for the import db c… Feature: Allow to import databases different than the default one - db-import command Apr 5, 2022
@rigoucr rigoucr self-assigned this Apr 5, 2022
@rigoucr rigoucr requested a review from kporras07 April 5, 2022 15:42
@rigoucr rigoucr marked this pull request as ready for review April 5, 2022 15:43
Copy link
Contributor

@kporras07 kporras07 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of minor changes but overall looks good!

@@ -23,27 +24,32 @@ protected function configure()
$this->setName('db-import')
->setDescription('Executes db import command')
->setHelp('Import given db into default database.')
->addArgument('filepath', InputArgument::OPTIONAL, 'File to import');
->addArgument('filepath', InputArgument::OPTIONAL, 'File to import')
->addOption('dbname', NULL, InputOption::VALUE_OPTIONAL, 'The database in that we want to import the data');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The database that you want to import the data in

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx

@@ -23,27 +24,32 @@ protected function configure()
$this->setName('db-import')
->setDescription('Executes db import command')
->setHelp('Import given db into default database.')
->addArgument('filepath', InputArgument::OPTIONAL, 'File to import');
->addArgument('filepath', InputArgument::OPTIONAL, 'File to import')
->addOption('dbname', NULL, InputOption::VALUE_OPTIONAL, 'The database in that we want to import the data');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lowercase null please

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx

$databaseName = $_SERVER['MYSQL_DATABASE'];
if ($optionalDatabaseName = $input->getOption('dbname')) {
$databaseName = $optionalDatabaseName;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$databaseName = $input->getOption('dbname') ?? $_SERVER['MYSQL_DATABASE'];

Please try before making the code change but I think this should work

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx, you right , that's better

@rigoucr rigoucr added the enhancement New feature or request label Apr 6, 2022
Copy link
Contributor

@kporras07 kporras07 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@rigoucr rigoucr merged commit 4e133ab into chirripo:master Apr 7, 2022
@rigoucr rigoucr deleted the feature/optional-database-name-importdb-command branch April 7, 2022 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants