itx/doctrine-migrations
最新稳定版本:1.0.2
Composer 安装命令:
composer require itx/doctrine-migrations
包简介
TYPO3 extension for versioned migration files, integrating doctrine/migrations
README 文档
README
This extension provides a CLI for doctrine migrations to manage database migrations in TYPO3. Migrations are defined in versioned files, which can be created and executed via the CLI.
Installation (Composer)
- Add the extension by executing
composer req itx/doctrine-migrations - Create a folder e.g.
Classes/Migrationsinside your extension's folder - In the TYPO3 Backend, add the path where you want to save your version files and the appropriate namespace at
Settings > Extension Configuration > doctrine_migrations - Alternatively you can configure these paths inside your additional.php file e.g.
$GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['doctrine_migrations']['migrationFilesLocation'] = 'EXT:your_extension/Migrations'; $GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['doctrine_migrations']['migrationFilesNamespace'] = 'YourVendor\YourExtension\Migrations';
Optionally you can override the default doctrine migrations configuration by providing an array like so in your additional.php file:
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['doctrine_migrations']['overrideConfiguration'] = [ 'table_storage' => [ 'table_name' => 'different_table_name_xyz', ], ];
Usage
- The extension is controlled via CLI
- You can use commands with
vendor/bin/typo3 migrations:<command> <option>
Walkthrough
Creating a version file
- To generate a version file at your chosen location, use
vendor/bin/typo3 migrations:generate - The created file is named Version{date}, {date} being its' time of creation in
YmdHisformat - This file comes with three pregenerated, empty functions:
getDescription(),up()anddown() - Enter the necessary SQL Code for your desired migration into the
up()function, and the code which can revert the migration into thedown()function like this:$this->addSql('<your sql goes here>'); - Take care to escape any single quotes inside the
addSql()function
Working with version files
vendor/bin/typo3 migrations:statusshow the current status of the migrations: which version is currently in use, which is previous/next/latest one etc.- Once you have a migration file prepared with the desired changes to your database, you can execute it by running either:
vendor/bin/typo3 migrations:migrateto automatically run every version file from your current state to the latest one, orvendor/bin/typo3 migrations:execute "Path\To\Your\File" --upto only run theup()method of your selected version file- Using
--downinstead of--upin the above command executes the version file'sdown()function instead
- Alternatively, you can use the keywords
first,latest,prevornextaftervendor/bin/typo3 migrations:migrateto migrate to the first, latest, previous or next migration file respectively - For more information on these and some more commands and their options refer to this
Troubleshooting
- If you get permission errors while trying to save your modified version files, try running
chmod g+w -R *in the container bash
Further Info
- For more information on doctrine migrations, refer to the official doctrine documentation
统计信息
- 总下载量: 4.89k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0-or-later
- 更新时间: 2024-09-27