| @@ 35-87 (lines=53) @@ | ||
| 32 | /** @var string */ |
|
| 33 | protected static $defaultName = 'migrations:diff'; |
|
| 34 | ||
| 35 | protected function configure() : void |
|
| 36 | { |
|
| 37 | parent::configure(); |
|
| 38 | ||
| 39 | $this |
|
| 40 | ->setAliases(['diff']) |
|
| 41 | ->setDescription('Generate a migration by comparing your current database to your mapping information.') |
|
| 42 | ->setHelp(<<<EOT |
|
| 43 | The <info>%command.name%</info> command generates a migration by comparing your current database to your mapping information: |
|
| 44 | ||
| 45 | <info>%command.full_name%</info> |
|
| 46 | ||
| 47 | EOT |
|
| 48 | ) |
|
| 49 | ->addOption( |
|
| 50 | 'namespace', |
|
| 51 | null, |
|
| 52 | InputOption::VALUE_REQUIRED, |
|
| 53 | 'The namespace to use for the migration (must be in the list of configured namespaces)' |
|
| 54 | ) |
|
| 55 | ->addOption( |
|
| 56 | 'filter-expression', |
|
| 57 | null, |
|
| 58 | InputOption::VALUE_REQUIRED, |
|
| 59 | 'Tables which are filtered by Regular Expression.' |
|
| 60 | ) |
|
| 61 | ->addOption( |
|
| 62 | 'formatted', |
|
| 63 | null, |
|
| 64 | InputOption::VALUE_NONE, |
|
| 65 | 'Format the generated SQL.' |
|
| 66 | ) |
|
| 67 | ->addOption( |
|
| 68 | 'line-length', |
|
| 69 | null, |
|
| 70 | InputOption::VALUE_REQUIRED, |
|
| 71 | 'Max line length of unformatted lines.', |
|
| 72 | 120 |
|
| 73 | ) |
|
| 74 | ->addOption( |
|
| 75 | 'check-database-platform', |
|
| 76 | null, |
|
| 77 | InputOption::VALUE_OPTIONAL, |
|
| 78 | 'Check Database Platform to the generated code.', |
|
| 79 | false |
|
| 80 | ) |
|
| 81 | ->addOption( |
|
| 82 | 'allow-empty-diff', |
|
| 83 | null, |
|
| 84 | InputOption::VALUE_NONE, |
|
| 85 | 'Do not throw an exception when no changes are detected.' |
|
| 86 | ); |
|
| 87 | } |
|
| 88 | ||
| 89 | /** |
|
| 90 | * @throws InvalidOptionUsage |
|
| @@ 28-101 (lines=74) @@ | ||
| 25 | /** @var string */ |
|
| 26 | protected static $defaultName = 'migrations:execute'; |
|
| 27 | ||
| 28 | protected function configure() : void |
|
| 29 | { |
|
| 30 | $this |
|
| 31 | ->setAliases(['execute']) |
|
| 32 | ->setDescription( |
|
| 33 | 'Execute one or more migration versions up or down manually.' |
|
| 34 | ) |
|
| 35 | ->addArgument( |
|
| 36 | 'versions', |
|
| 37 | InputArgument::REQUIRED|InputArgument::IS_ARRAY, |
|
| 38 | 'The versions to execute.', |
|
| 39 | null |
|
| 40 | ) |
|
| 41 | ->addOption( |
|
| 42 | 'write-sql', |
|
| 43 | null, |
|
| 44 | InputOption::VALUE_OPTIONAL, |
|
| 45 | 'The path to output the migration SQL file. Defaults to current working directory.', |
|
| 46 | false |
|
| 47 | ) |
|
| 48 | ->addOption( |
|
| 49 | 'dry-run', |
|
| 50 | null, |
|
| 51 | InputOption::VALUE_NONE, |
|
| 52 | 'Execute the migration as a dry run.' |
|
| 53 | ) |
|
| 54 | ->addOption( |
|
| 55 | 'up', |
|
| 56 | null, |
|
| 57 | InputOption::VALUE_NONE, |
|
| 58 | 'Execute the migration up.' |
|
| 59 | ) |
|
| 60 | ->addOption( |
|
| 61 | 'down', |
|
| 62 | null, |
|
| 63 | InputOption::VALUE_NONE, |
|
| 64 | 'Execute the migration down.' |
|
| 65 | ) |
|
| 66 | ->addOption( |
|
| 67 | 'query-time', |
|
| 68 | null, |
|
| 69 | InputOption::VALUE_NONE, |
|
| 70 | 'Time all the queries individually.' |
|
| 71 | ) |
|
| 72 | ->setHelp(<<<EOT |
|
| 73 | The <info>%command.name%</info> command executes migration versions up or down manually: |
|
| 74 | ||
| 75 | <info>%command.full_name% FQCN</info> |
|
| 76 | ||
| 77 | If no <comment>--up</comment> or <comment>--down</comment> option is specified it defaults to up: |
|
| 78 | ||
| 79 | <info>%command.full_name% FQCN --down</info> |
|
| 80 | ||
| 81 | You can also execute the migration as a <comment>--dry-run</comment>: |
|
| 82 | ||
| 83 | <info>%command.full_name% FQCN --dry-run</info> |
|
| 84 | ||
| 85 | You can output the prepared SQL statements to a file with <comment>--write-sql</comment>: |
|
| 86 | ||
| 87 | <info>%command.full_name% FQCN --write-sql</info> |
|
| 88 | ||
| 89 | Or you can also execute the migration without a warning message which you need to interact with: |
|
| 90 | ||
| 91 | <info>%command.full_name% FQCN --no-interaction</info> |
|
| 92 | ||
| 93 | All the previous commands accept multiple migration versions, allowing you run execute more than |
|
| 94 | one migration at once: |
|
| 95 | <info>%command.full_name% FQCN-1 FQCN-2 ...FQCN-n </info> |
|
| 96 | ||
| 97 | EOT |
|
| 98 | ); |
|
| 99 | ||
| 100 | parent::configure(); |
|
| 101 | } |
|
| 102 | ||
| 103 | protected function execute(InputInterface $input, OutputInterface $output) : int |
|
| 104 | { |
|
| @@ 33-100 (lines=68) @@ | ||
| 30 | /** @var bool */ |
|
| 31 | private $markMigrated; |
|
| 32 | ||
| 33 | protected function configure() : void |
|
| 34 | { |
|
| 35 | $this |
|
| 36 | ->setAliases(['version']) |
|
| 37 | ->setDescription('Manually add and delete migration versions from the version table.') |
|
| 38 | ->addArgument( |
|
| 39 | 'version', |
|
| 40 | InputArgument::OPTIONAL, |
|
| 41 | 'The version to add or delete.', |
|
| 42 | null |
|
| 43 | ) |
|
| 44 | ->addOption( |
|
| 45 | 'add', |
|
| 46 | null, |
|
| 47 | InputOption::VALUE_NONE, |
|
| 48 | 'Add the specified version.' |
|
| 49 | ) |
|
| 50 | ->addOption( |
|
| 51 | 'delete', |
|
| 52 | null, |
|
| 53 | InputOption::VALUE_NONE, |
|
| 54 | 'Delete the specified version.' |
|
| 55 | ) |
|
| 56 | ->addOption( |
|
| 57 | 'all', |
|
| 58 | null, |
|
| 59 | InputOption::VALUE_NONE, |
|
| 60 | 'Apply to all the versions.' |
|
| 61 | ) |
|
| 62 | ->addOption( |
|
| 63 | 'range-from', |
|
| 64 | null, |
|
| 65 | InputOption::VALUE_OPTIONAL, |
|
| 66 | 'Apply from specified version.' |
|
| 67 | ) |
|
| 68 | ->addOption( |
|
| 69 | 'range-to', |
|
| 70 | null, |
|
| 71 | InputOption::VALUE_OPTIONAL, |
|
| 72 | 'Apply to specified version.' |
|
| 73 | ) |
|
| 74 | ->setHelp(<<<EOT |
|
| 75 | The <info>%command.name%</info> command allows you to manually add, delete or synchronize migration versions from the version table: |
|
| 76 | ||
| 77 | <info>%command.full_name% MIGRATION-FQCN --add</info> |
|
| 78 | ||
| 79 | If you want to delete a version you can use the <comment>--delete</comment> option: |
|
| 80 | ||
| 81 | <info>%command.full_name% MIGRATION-FQCN --delete</info> |
|
| 82 | ||
| 83 | If you want to synchronize by adding or deleting all migration versions available in the version table you can use the <comment>--all</comment> option: |
|
| 84 | ||
| 85 | <info>%command.full_name% --add --all</info> |
|
| 86 | <info>%command.full_name% --delete --all</info> |
|
| 87 | ||
| 88 | If you want to synchronize by adding or deleting some range of migration versions available in the version table you can use the <comment>--range-from/--range-to</comment> option: |
|
| 89 | ||
| 90 | <info>%command.full_name% --add --range-from=MIGRATION-FQCN --range-to=MIGRATION-FQCN</info> |
|
| 91 | <info>%command.full_name% --delete --range-from=MIGRATION-FQCN --range-to=MIGRATION-FQCN</info> |
|
| 92 | ||
| 93 | You can also execute this command without a warning message which you need to interact with: |
|
| 94 | ||
| 95 | <info>%command.full_name% --no-interaction</info> |
|
| 96 | EOT |
|
| 97 | ); |
|
| 98 | ||
| 99 | parent::configure(); |
|
| 100 | } |
|
| 101 | ||
| 102 | /** |
|
| 103 | * @throws InvalidOptionUsage |
|