All Projects → deprecated-packages → Doctrinemigrations

deprecated-packages / Doctrinemigrations

Licence: mit
[DEPRECATED] Use Phinx instead

Projects that are alternatives of or similar to Doctrinemigrations

Express Typescript Boilerplate
A delightful way to building a RESTful API with NodeJs & TypeScript by @w3tecch
Stars: ✭ 2,293 (+9454.17%)
Mutual labels:  migrations, database
Django Migration Linter
🚀 Detect backward incompatible migrations for your django project
Stars: ✭ 231 (+862.5%)
Mutual labels:  migrations, database
Postgres Migrations
🐦 A Stack Overflow-inspired PostgreSQL migration library with strict ordering and immutable migrations
Stars: ✭ 161 (+570.83%)
Mutual labels:  migrations, database
Migration
Simple and pragmatic migrations for Go applications.
Stars: ✭ 66 (+175%)
Mutual labels:  migrations, database
Zero downtime migrations
Zero downtime migrations with ActiveRecord 3+ and PostgreSQL
Stars: ✭ 513 (+2037.5%)
Mutual labels:  migrations, database
Lol dba
lol_dba is a small package of rake tasks that scan your application models and displays a list of columns that probably should be indexed. Also, it can generate .sql migration scripts.
Stars: ✭ 1,363 (+5579.17%)
Mutual labels:  migrations, database
Migrate
Database migrations. CLI and Golang library.
Stars: ✭ 2,315 (+9545.83%)
Mutual labels:  migrations, database
Laravel Migrate Fresh
An artisan command to build up a database from scratch
Stars: ✭ 179 (+645.83%)
Mutual labels:  migrations, database
Migrate Mongo
A database migration tool for MongoDB in Node
Stars: ✭ 481 (+1904.17%)
Mutual labels:  migrations, database
Etlalchemy
Extract, Transform, Load: Any SQL Database in 4 lines of Code.
Stars: ✭ 460 (+1816.67%)
Mutual labels:  migrations, database
Node Pg Migrate
Node.js database migration management for Postgresql
Stars: ✭ 838 (+3391.67%)
Mutual labels:  migrations, database
Node Sqlite
SQLite client for Node.js applications with SQL-based migrations API written in Typescript
Stars: ✭ 642 (+2575%)
Mutual labels:  migrations, database
Goose
A database migration tool. Supports SQL migrations and Go functions.
Stars: ✭ 2,112 (+8700%)
Mutual labels:  database, migrations
Flask Migrate
SQLAlchemy database migrations for Flask applications using Alembic
Stars: ✭ 1,971 (+8112.5%)
Mutual labels:  migrations, database
Doctrine Postgis
Spatial and Geographic Data with PostGIS and Doctrine.
Stars: ✭ 161 (+570.83%)
Mutual labels:  doctrine, database
Ragtime
Database-independent migration library
Stars: ✭ 519 (+2062.5%)
Mutual labels:  migrations, database
Migrate
Database migrations. CLI and Golang library.
Stars: ✭ 7,712 (+32033.33%)
Mutual labels:  migrations, database
Storagedone Android
Kotlin library to make easy using local document-oriented database in Android apps.
Stars: ✭ 18 (-25%)
Mutual labels:  database
Redix
a persistent real-time key-value store, with the same redis protocol with powerful features
Stars: ✭ 907 (+3679.17%)
Mutual labels:  database
Hana sql exporter
SAP Hana SQL Exporter for Prometheus
Stars: ✭ 18 (-25%)
Mutual labels:  database

Doctrine Migrations

Build Status Quality Score Code Coverage Downloads this Month Latest stable

Implementation of Doctrine\Migrations to Nette.

Install

composer require zenify/doctrine-migrations

Register extensions in config.neon:

extensions:
	- Arachne\ContainerAdapter\DI\ContainerAdapterExtension
	- Arachne\EventDispatcher\DI\EventDispatcherExtension
	migrations: Zenify\DoctrineMigrations\DI\MigrationsExtension

	# Kdyby\Doctrine or another Doctrine integration
	doctrine: Kdyby\Doctrine\DI\OrmExtension

Configuration

config.neon with default values

migrations:
	table: doctrine_migrations # database table for applied migrations
	column: version # database column for applied migrations
	directory: %appDir%/../migrations # directory, where all migrations are stored
	namespace: Migrations # namespace of migration classes
	codingStandard: tabs # or "spaces", coding style for generated classes
	versionsOrganization: null # null, "year" or "year_and_month", organizes migrations to subdirectories

Usage

Open your CLI and run command (based on Kdyby\Console integration):

php www/index.php

And then you should see all available commands:

CLI commands

Migrate changes to database

If you want to migrate existing migration to your database, just run migrate commmand:

php www/index.php migrations:migrate

If you get lost, just use -h option for help:

php www/index.php migrations:migrate -h

Create new migration

To create new empty migration, just run:

php www/index.php migrations:generate

A new empty migration will be created at your migrations directory. You can add your sql there then.

Migration that would add new role "superadmin" to user_role table would look like this:

namespace Migrations;

use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;

/**
 * New role "superadmin" added.
 */
final class Version20151015000003 extends AbstractMigration
{

	public function up(Schema $schema)
	{
		$this->addSql("INSERT INTO 'user_role' (id, value, name) VALUES (3, 'superadmin', 'Super Admin')");
	}
	

	public function down(Schema $schema)
	{
		$this->addSql("DELETE FROM 'user_role' WHERE ('id' = 3);");
	}

}

Simple as that!

For further use, please check docs in Symfony bundle.

Features

Migrations organization

If you have over 100 migrations in one directory, it might get messy. Fortunately doctrine migrations can organize your migrations to directories by year or by year and month. You can configure it in your config.neon (see above).

/migrations/2015/11
	- VersionXXX.php
/migrations/2015/12
	- VersionYYY.php
/migrations/2016/01
	- VersionZZZ.php

Injected migrations

Note: this is not really best practise, so try to use it only if there is no other way.

namespace Migrations;

final class Version20140801152432 extends AbstractMigration
{

	/**
	 * @inject
	 * @var Doctrine\ORM\EntityManagerInterface
	 */
	public $entityManager;


	public function up(Schema $schema)
	{
		// ...
	}

	// ...

}

Testing

composer check-cs
vendor/bin/phpunit

Contributing

Rules are simple:

  • new feature needs tests
  • all tests must pass
  • 1 feature per PR

We would be happy to merge your feature then!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].