-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2409 from skaut/2396-novy-docker
2396-novy-docker
- Loading branch information
Showing
53 changed files
with
1,165 additions
and
371 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
DB_HOST=mysql | ||
DB_USER=hskauting | ||
DB_PASSWORD=hskauting | ||
DB_NAME=hskauting | ||
DEVELOPMENT_MACHINE=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
DB_HOST=mysql-test | ||
DB_USER=hskauting | ||
DB_PASSWORD=hskauting | ||
DB_NAME=hskauting | ||
DB_TEST=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
CONTAINER_PHP=hskauting.app | ||
CONTAINER_PHP_TEST=hskauting.app-test | ||
CONTAINER_DB=hskauting.mysql | ||
CONTAINER_DB_TEST=hskauting.mysql-test | ||
|
||
COMPOSE_FILE=-f docker/docker-compose.yml | ||
|
||
CONSOLE?= | ||
|
||
up: down | ||
docker compose ${COMPOSE_FILE} up -d --force-recreate | ||
|
||
down: | ||
docker compose ${COMPOSE_FILE} down --remove-orphans | ||
|
||
enter: | ||
@docker exec -it ${CONTAINER_PHP} bash | ||
|
||
init: | ||
docker exec -it $(CONTAINER_PHP) composer install | ||
docker exec -it $(CONTAINER_PHP) /app/vendor/bin/phing app-init | ||
|
||
tests-all: | ||
docker exec -it ${CONTAINER_PHP_TEST} /app/vendor/bin/phing tests | ||
|
||
tests-unit: | ||
docker exec -it ${CONTAINER_PHP_TEST} /app/vendor/bin/phing tests-unit | ||
|
||
tests-integration: | ||
docker exec -it ${CONTAINER_PHP_TEST} /app/vendor/bin/phing tests-integration | ||
|
||
tests-acceptance: | ||
docker exec -it ${CONTAINER_PHP_TEST} /app/vendor/bin/phing tests-acceptance | ||
|
||
static-analysis: | ||
docker exec -it ${CONTAINER_PHP} /app/vendor/bin/phing static-analysis | ||
|
||
coding-standard: | ||
docker exec -it ${CONTAINER_PHP} /app/vendor/bin/phing coding-standard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Console; | ||
|
||
use Doctrine\DBAL\Exception; | ||
use Doctrine\ORM\EntityManagerInterface; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
use function getenv; | ||
use function sprintf; | ||
|
||
class MigrationsDropCommand extends Command | ||
{ | ||
// phpcs:disable SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingNativeTypeHint | ||
/** @var string|null $defaultName The default command name */ | ||
protected static $defaultName = 'migrations:drop-all-tables-views'; | ||
|
||
public function __construct(private EntityManagerInterface $em) | ||
{ | ||
parent::__construct(); | ||
} | ||
|
||
protected function configure(): void | ||
{ | ||
$this->setName(self::$defaultName) | ||
->setDescription('Drops all tables from the database'); | ||
} | ||
|
||
/** @throws Exception */ | ||
protected function execute(InputInterface $input, OutputInterface $output): int | ||
{ | ||
if (getenv('DB_TEST') !== 'true') { | ||
$output->writeln('Cannot run on non testing environment'); | ||
|
||
return Command::FAILURE; | ||
} | ||
|
||
$conn = $this->em->getConnection(); | ||
$schemaManager = $conn->getSchemaManager(); | ||
|
||
// Drop tables | ||
$tables = $schemaManager->listTables(); | ||
$conn->executeStatement('SET foreign_key_checks = 0'); | ||
foreach ($tables as $table) { | ||
$tableName = $table->getName(); | ||
$conn->executeStatement(sprintf('DROP TABLE %s', $tableName)); | ||
$output->writeln(sprintf('Dropped table %s', $tableName)); | ||
} | ||
|
||
// Drop views | ||
$views = $schemaManager->listViews(); | ||
foreach ($views as $view) { | ||
$viewName = $view->getName(); | ||
$conn->executeStatement(sprintf('DROP VIEW %s', $viewName)); | ||
$output->writeln(sprintf('Dropped view %s', $viewName)); | ||
} | ||
|
||
return Command::SUCCESS; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.