Giter Club home page Giter Club logo

doctrinemigrations's Introduction

Doctrine Migrations

Build Status Quality Score Code Coverage Downloads this Month Latest stable

Implementation of Doctrine\Migrations to Nette.

Install

Add to your composer.json:

"require": {
    "doctrine/migrations": "@dev",
    "zenify/doctrine-migrations": "~2.0"
}

and run composer update.

This is due to doctrine/migrations, that hasn't been tagged for a long time.

Register extensions in config.neon (includes Kdyby/Doctrine configuration):

extensions:
    - Kdyby\Annotations\DI\AnnotationsExtension
    - Kdyby\Events\DI\EventsExtension
    - Kdyby\Console\DI\ConsoleExtension
    doctrine: Kdyby\Doctrine\DI\OrmExtension
    migrations: Zenify\DoctrineMigrations\DI\MigrationsExtension

doctrine:
	host: localhost
	user: root
	password: 
	dbname: database

Configuration

config.neon with default values

migrations:
	table: doctrine_migrations # database table for applied migrations
	dirs: # list of dirs to load migrations from
		- %appDir%/../migrations # first dir is used for generating migrations
	namespace: Migrations # namespace of migration classes
	enabled: FALSE # cli based loading; set TRUE to force loading in non-cli
	codingStandard: tabs # or "spaces", cs for generated classes

Usage

Open your CLI and run command:

php www/index.php

And then you should see all available commands:

CLI commands

And then you can run any command you need, e.g. migrate command:

php www/index.php migrations:migrate

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

php www/index.php migrations:migrate -h

For further use, please check docs in Symfony bundle.

Features

Multiple directories

In case you have plenty of migrations and you want to store them in another directory, just add them to dirs.

Only the first one (here %appDir%/../migrations) will be used to create migrations from command line.

migrations:
	dirs:
		- %appDir%/../migrations
		- %appDir%/../migrations/2013
		- %appDir%/../migrations/2012

Injected migrations

namespace Migrations;


class Version20140801152432 extends AbstractMigration
{

	/**
	 * @inject
	 * @var Doctrine\ORM\EntityManager
	 */
	public $em;


	public function up(Schema $schema)
	{
		$product = new Product;
		$product->setName('Chips without fish')
		$this->em->persist(product);
		$this->em->flush();
	}

	// ...

}

doctrinemigrations's People

Contributors

tomasvotruba avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.