mirror of
https://github.com/wallabag/wallabag.git
synced 2024-12-15 09:57:41 +01:00
Merge pull request #3088 from wallabag/execute-migrations-after-install
Added migrations execution after fresh install
This commit is contained in:
commit
43f81a62e9
@ -63,6 +63,7 @@ class InstallCommand extends ContainerAwareCommand
|
|||||||
->setupDatabase()
|
->setupDatabase()
|
||||||
->setupAdmin()
|
->setupAdmin()
|
||||||
->setupConfig()
|
->setupConfig()
|
||||||
|
->runMigrations()
|
||||||
;
|
;
|
||||||
|
|
||||||
$output->writeln('<info>wallabag has been successfully installed.</info>');
|
$output->writeln('<info>wallabag has been successfully installed.</info>');
|
||||||
@ -71,7 +72,7 @@ class InstallCommand extends ContainerAwareCommand
|
|||||||
|
|
||||||
protected function checkRequirements()
|
protected function checkRequirements()
|
||||||
{
|
{
|
||||||
$this->defaultOutput->writeln('<info><comment>Step 1 of 4.</comment> Checking system requirements.</info>');
|
$this->defaultOutput->writeln('<info><comment>Step 1 of 5.</comment> Checking system requirements.</info>');
|
||||||
$doctrineManager = $this->getContainer()->get('doctrine')->getManager();
|
$doctrineManager = $this->getContainer()->get('doctrine')->getManager();
|
||||||
|
|
||||||
$rows = [];
|
$rows = [];
|
||||||
@ -175,11 +176,11 @@ class InstallCommand extends ContainerAwareCommand
|
|||||||
|
|
||||||
protected function setupDatabase()
|
protected function setupDatabase()
|
||||||
{
|
{
|
||||||
$this->defaultOutput->writeln('<info><comment>Step 2 of 4.</comment> Setting up database.</info>');
|
$this->defaultOutput->writeln('<info><comment>Step 2 of 5.</comment> Setting up database.</info>');
|
||||||
|
|
||||||
// user want to reset everything? Don't care about what is already here
|
// user want to reset everything? Don't care about what is already here
|
||||||
if (true === $this->defaultInput->getOption('reset')) {
|
if (true === $this->defaultInput->getOption('reset')) {
|
||||||
$this->defaultOutput->writeln('Droping database, creating database and schema, clearing the cache');
|
$this->defaultOutput->writeln('Dropping database, creating database and schema, clearing the cache');
|
||||||
|
|
||||||
$this
|
$this
|
||||||
->runCommand('doctrine:database:drop', ['--force' => true])
|
->runCommand('doctrine:database:drop', ['--force' => true])
|
||||||
@ -211,7 +212,7 @@ class InstallCommand extends ContainerAwareCommand
|
|||||||
$question = new ConfirmationQuestion('It appears that your database already exists. Would you like to reset it? (y/N)', false);
|
$question = new ConfirmationQuestion('It appears that your database already exists. Would you like to reset it? (y/N)', false);
|
||||||
|
|
||||||
if ($questionHelper->ask($this->defaultInput, $this->defaultOutput, $question)) {
|
if ($questionHelper->ask($this->defaultInput, $this->defaultOutput, $question)) {
|
||||||
$this->defaultOutput->writeln('Droping database, creating database and schema');
|
$this->defaultOutput->writeln('Dropping database, creating database and schema');
|
||||||
|
|
||||||
$this
|
$this
|
||||||
->runCommand('doctrine:database:drop', ['--force' => true])
|
->runCommand('doctrine:database:drop', ['--force' => true])
|
||||||
@ -221,7 +222,7 @@ class InstallCommand extends ContainerAwareCommand
|
|||||||
} elseif ($this->isSchemaPresent()) {
|
} elseif ($this->isSchemaPresent()) {
|
||||||
$question = new ConfirmationQuestion('Seems like your database contains schema. Do you want to reset it? (y/N)', false);
|
$question = new ConfirmationQuestion('Seems like your database contains schema. Do you want to reset it? (y/N)', false);
|
||||||
if ($questionHelper->ask($this->defaultInput, $this->defaultOutput, $question)) {
|
if ($questionHelper->ask($this->defaultInput, $this->defaultOutput, $question)) {
|
||||||
$this->defaultOutput->writeln('Droping schema and creating schema');
|
$this->defaultOutput->writeln('Dropping schema and creating schema');
|
||||||
|
|
||||||
$this
|
$this
|
||||||
->runCommand('doctrine:schema:drop', ['--force' => true])
|
->runCommand('doctrine:schema:drop', ['--force' => true])
|
||||||
@ -246,7 +247,7 @@ class InstallCommand extends ContainerAwareCommand
|
|||||||
|
|
||||||
protected function setupAdmin()
|
protected function setupAdmin()
|
||||||
{
|
{
|
||||||
$this->defaultOutput->writeln('<info><comment>Step 3 of 4.</comment> Administration setup.</info>');
|
$this->defaultOutput->writeln('<info><comment>Step 3 of 5.</comment> Administration setup.</info>');
|
||||||
|
|
||||||
$questionHelper = $this->getHelperSet()->get('question');
|
$questionHelper = $this->getHelperSet()->get('question');
|
||||||
$question = new ConfirmationQuestion('Would you like to create a new admin user (recommended) ? (Y/n)', true);
|
$question = new ConfirmationQuestion('Would you like to create a new admin user (recommended) ? (Y/n)', true);
|
||||||
@ -285,7 +286,7 @@ class InstallCommand extends ContainerAwareCommand
|
|||||||
|
|
||||||
protected function setupConfig()
|
protected function setupConfig()
|
||||||
{
|
{
|
||||||
$this->defaultOutput->writeln('<info><comment>Step 4 of 4.</comment> Config setup.</info>');
|
$this->defaultOutput->writeln('<info><comment>Step 4 of 5.</comment> Config setup.</info>');
|
||||||
$em = $this->getContainer()->get('doctrine.orm.entity_manager');
|
$em = $this->getContainer()->get('doctrine.orm.entity_manager');
|
||||||
|
|
||||||
// cleanup before insert new stuff
|
// cleanup before insert new stuff
|
||||||
@ -464,6 +465,14 @@ class InstallCommand extends ContainerAwareCommand
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function runMigrations()
|
||||||
|
{
|
||||||
|
$this->defaultOutput->writeln('<info><comment>Step 5 of 5.</comment> Run migrations.</info>');
|
||||||
|
|
||||||
|
$this
|
||||||
|
->runCommand('doctrine:migrations:migrate', ['--no-interaction' => true]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run a command.
|
* Run a command.
|
||||||
*
|
*
|
||||||
|
@ -766,10 +766,9 @@ class EntryRestControllerTest extends WallabagApiTestCase
|
|||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->client->request('DELETE', '/api/entries/tags/list?list=' . json_encode($list));
|
$this->client->request('DELETE', '/api/entries/tags/list?list='.json_encode($list));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function testPostEntriesListAction()
|
public function testPostEntriesListAction()
|
||||||
{
|
{
|
||||||
$list = [
|
$list = [
|
||||||
|
@ -87,6 +87,7 @@ class InstallCommandTest extends WallabagCoreTestCase
|
|||||||
$this->assertContains('Setting up database.', $tester->getDisplay());
|
$this->assertContains('Setting up database.', $tester->getDisplay());
|
||||||
$this->assertContains('Administration setup.', $tester->getDisplay());
|
$this->assertContains('Administration setup.', $tester->getDisplay());
|
||||||
$this->assertContains('Config setup.', $tester->getDisplay());
|
$this->assertContains('Config setup.', $tester->getDisplay());
|
||||||
|
$this->assertContains('Run migrations.', $tester->getDisplay());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRunInstallCommandWithReset()
|
public function testRunInstallCommandWithReset()
|
||||||
@ -115,12 +116,13 @@ class InstallCommandTest extends WallabagCoreTestCase
|
|||||||
|
|
||||||
$this->assertContains('Checking system requirements.', $tester->getDisplay());
|
$this->assertContains('Checking system requirements.', $tester->getDisplay());
|
||||||
$this->assertContains('Setting up database.', $tester->getDisplay());
|
$this->assertContains('Setting up database.', $tester->getDisplay());
|
||||||
$this->assertContains('Droping database, creating database and schema, clearing the cache', $tester->getDisplay());
|
$this->assertContains('Dropping database, creating database and schema, clearing the cache', $tester->getDisplay());
|
||||||
$this->assertContains('Administration setup.', $tester->getDisplay());
|
$this->assertContains('Administration setup.', $tester->getDisplay());
|
||||||
$this->assertContains('Config setup.', $tester->getDisplay());
|
$this->assertContains('Config setup.', $tester->getDisplay());
|
||||||
|
$this->assertContains('Run migrations.', $tester->getDisplay());
|
||||||
|
|
||||||
// we force to reset everything
|
// we force to reset everything
|
||||||
$this->assertContains('Droping database, creating database and schema, clearing the cache', $tester->getDisplay());
|
$this->assertContains('Dropping database, creating database and schema, clearing the cache', $tester->getDisplay());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRunInstallCommandWithDatabaseRemoved()
|
public function testRunInstallCommandWithDatabaseRemoved()
|
||||||
@ -168,6 +170,7 @@ class InstallCommandTest extends WallabagCoreTestCase
|
|||||||
$this->assertContains('Setting up database.', $tester->getDisplay());
|
$this->assertContains('Setting up database.', $tester->getDisplay());
|
||||||
$this->assertContains('Administration setup.', $tester->getDisplay());
|
$this->assertContains('Administration setup.', $tester->getDisplay());
|
||||||
$this->assertContains('Config setup.', $tester->getDisplay());
|
$this->assertContains('Config setup.', $tester->getDisplay());
|
||||||
|
$this->assertContains('Run migrations.', $tester->getDisplay());
|
||||||
|
|
||||||
// the current database doesn't already exist
|
// the current database doesn't already exist
|
||||||
$this->assertContains('Creating database and schema, clearing the cache', $tester->getDisplay());
|
$this->assertContains('Creating database and schema, clearing the cache', $tester->getDisplay());
|
||||||
@ -205,8 +208,9 @@ class InstallCommandTest extends WallabagCoreTestCase
|
|||||||
$this->assertContains('Setting up database.', $tester->getDisplay());
|
$this->assertContains('Setting up database.', $tester->getDisplay());
|
||||||
$this->assertContains('Administration setup.', $tester->getDisplay());
|
$this->assertContains('Administration setup.', $tester->getDisplay());
|
||||||
$this->assertContains('Config setup.', $tester->getDisplay());
|
$this->assertContains('Config setup.', $tester->getDisplay());
|
||||||
|
$this->assertContains('Run migrations.', $tester->getDisplay());
|
||||||
|
|
||||||
$this->assertContains('Droping schema and creating schema', $tester->getDisplay());
|
$this->assertContains('Dropping schema and creating schema', $tester->getDisplay());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRunInstallCommandChooseNothing()
|
public function testRunInstallCommandChooseNothing()
|
||||||
@ -259,6 +263,7 @@ class InstallCommandTest extends WallabagCoreTestCase
|
|||||||
$this->assertContains('Setting up database.', $tester->getDisplay());
|
$this->assertContains('Setting up database.', $tester->getDisplay());
|
||||||
$this->assertContains('Administration setup.', $tester->getDisplay());
|
$this->assertContains('Administration setup.', $tester->getDisplay());
|
||||||
$this->assertContains('Config setup.', $tester->getDisplay());
|
$this->assertContains('Config setup.', $tester->getDisplay());
|
||||||
|
$this->assertContains('Run migrations.', $tester->getDisplay());
|
||||||
|
|
||||||
$this->assertContains('Creating schema', $tester->getDisplay());
|
$this->assertContains('Creating schema', $tester->getDisplay());
|
||||||
}
|
}
|
||||||
@ -291,5 +296,6 @@ class InstallCommandTest extends WallabagCoreTestCase
|
|||||||
$this->assertContains('Setting up database.', $tester->getDisplay());
|
$this->assertContains('Setting up database.', $tester->getDisplay());
|
||||||
$this->assertContains('Administration setup.', $tester->getDisplay());
|
$this->assertContains('Administration setup.', $tester->getDisplay());
|
||||||
$this->assertContains('Config setup.', $tester->getDisplay());
|
$this->assertContains('Config setup.', $tester->getDisplay());
|
||||||
|
$this->assertContains('Run migrations.', $tester->getDisplay());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user