diff --git a/.docs/README.md b/.docs/README.md index 01b1e8a..19350f3 100755 --- a/.docs/README.md +++ b/.docs/README.md @@ -1,91 +1,58 @@ # Contributte Doctrine Migrations -[Doctrine/Migrations](https://www.doctrine-project.org/projects/migrations.html) for Nette Framework. +Integration of [Doctrine Migrations](https://www.doctrine-project.org/projects/migrations.html) for Nette Framework. ## Content -- [Setup](#setup) -- [Relying](#relying) +- [Installation](#installation) - [Configuration](#configuration) + - [Minimal configuration](#minimal-configuration) + - [Advanced configuration](#advanced-configuration) - [Usage](#usage) -- [3rd party](#3rd-party) +- [DBAL & ORM](#dbal--orm) - [Examples](#examples) -## Setup +## Installation -Install package +Install package using composer. ```bash composer require nettrine/migrations ``` -Configure extension +Register prepared [compiler extension](https://doc.nette.org/en/dependency-injection/nette-container) in your `config.neon` file. -```yaml +```neon extensions: nettrine.migrations: Nettrine\Migrations\DI\MigrationsExtension ``` +> [!NOTE] +> This is just **Migrations**, for **ORM** use [nettrine/orm](https://github.com/contributte/doctrine-orm) or **DBAL** use [nettrine/dbal](https://github.com/contributte/doctrine-dbal). -## Relying - -Take advantage of enpowering this package with 2 extra packages: - -- `doctrine/orm` -- `symfony/console` - - -### `doctrine/orm` - -This package relies on `doctrine/orm`, use prepared [contributte/doctrine-orm](https://github.com/contributte/doctrine-orm) integration. -Doctrine ORM depends on Doctrine DBAL, use prepared [contributte/doctrine-dbal](https://github.com/contributte/doctrine-dbal) integration - -```bash -composer require nettrine/dbal -composer require nettrine/orm -``` - -Without these packages the migrations can't be processed, because they need a database connection and entities information. Don't forget to configure Doctrine DBAL & ORM properly with [console bridge](https://github.com/contributte/doctrine-orm/tree/master/.docs#console-bridge). Some commands need special treatment. - - -### `symfony/console` - -This package relies on `symfony/console`, use prepared [contributte/console](https://github.com/contributte/console) integration. +## Configuration -```bash -composer require contributte/console -``` +### Minimal configuration -```yaml -extensions: - console: Contributte\Console\DI\ConsoleExtension(%consoleMode%) +```neon +nettrine.migrations: + directories: + App\Migrations: %appDir%/migrations ``` +### Advanced configuration -## Configuration - -**Schema definition** +Here is the list of all available options with their types. ```yaml nettrine.migrations: table: column: - directories: + directories: array versionsOrganization: customTemplate: ``` -**Under the hood** - -Minimal configuration: - -```yaml -nettrine.migrations: - directories: - App\Migrations: %appDir%/migrations -``` - - ## Usage Type `bin/console` in your terminal and there should be a `migrations` command group. @@ -99,17 +66,17 @@ Type `bin/console` in your terminal and there should be a `migrations` command g - `migrations:up-to-date` - `migrations:version` -![Console Commands](https://raw.githubusercontent.com/nettrine/migrations/master/.docs/assets/console.png) - You are mostly going to need `migrations:diff` and `migrations:migrate`. - ### Migration -This is an example of a migration class. +You can create a new migration by running the following command. -You can count on [Nette Dependency Injection](https://doc.nette.org/en/3.0/dependency-injection). -Injecting into properties or via `inject<>` method is also supported. +```bash +bin/console migrations:generate +``` + +In the migration file, you can use [dependency injection](https://doc.nette.org/en/3.0/dependency-injection). Injecting into properties or via `inject<>` method is also supported. ```php [!TIP] +> Doctrine Migrations needs a database connection and entities information. +> Take a look at [nettrine/dbal](https://github.com/contributte/doctrine-dbal) and [nettrine/orm](https://github.com/contributte/doctrine-orm). + +```bash +composer require nettrine/dbal +composer require nettrine/orm +``` + +### Console + +> [!TIP] +> Doctrine DBAL needs Symfony Console to work. You can use `symfony/console` or [contributte/console](https://github.com/contributte/console). -## 3rd party +```bash +composer require contributte/console +``` -**kdyby/doctrine** +```neon +extensions: + console: Contributte\Console\DI\ConsoleExtension(%consoleMode%) -```yaml -decorator: - Symfony\Component\Console\Command\Command: - tags: [kdyby.console.command] - Symfony\Component\Console\Helper\Helper: - tags: [kdyby.console.helper] + nettrine.dbal: Nettrine\DBAL\DI\DbalExtension ``` +Since this moment when you type `bin/console`, there'll be registered commands from Doctrine DBAL. + +![Console Commands](https://raw.githubusercontent.com/nettrine/dbal/master/.docs/assets/console.png) ## Examples -- https://github.com/contributte/playground (playground) -- https://contributte.org/examples.html (more examples) +> [!TIP] +> Take a look at more examples in [contributte/doctrine](https://github.com/contributte/doctrine/tree/master/.docs). +