Giter Club home page Giter Club logo

migrations-bundle's Introduction

Migrations Bundle

Symfony framework integration for davedevelopment/phpmig

Setup

# config/bundles.php

return [
    PhiSYS\MigrationsBundle\PhiSYSMigrationsBundle::class => ['dev' => true, 'test' => true],
];
# services.yaml

parameters:
  phisys.migrations.migrations_directory: '%kernel.project_dir%/migrations/postgresql/'
  phisys.migrations.migration_template: '%kernel.project_dir%/vendor/phisys/migrations-bundle/src/Resources/templates/dbalSql.php.twig'
  phisys.migrations.control_table: 'serviceschema.migrations'

services:
  PhiSYS\MigrationsBundle\Infrastructure\Service\Phpmig\Adapter\Adapter:
    class: PhiSYS\MigrationsBundle\Infrastructure\Service\Phpmig\Adapter\DbalAdapter
    public: false
    autoconfigure: true
    arguments:
      $connection: '@connection.dbal.myservice' # Doctrine DBAL Connection
      $tableName: '%phisys.migrations.control_table%'

  PhiSYS\MigrationsBundle\Infrastructure\Service\Phpmig\ConfigurationContainer:
    public: true
    class: PhiSYS\MigrationsBundle\Infrastructure\Service\Phpmig\ConfigurationContainer
    autoconfigure: true
    factory: PhiSYS\MigrationsBundle\Infrastructure\Service\Phpmig\ConfigurationContainer::from
    arguments:
      $adapter: '@PhiSYS\MigrationsBundle\Infrastructure\Service\Phpmig\Adapter\Adapter'
      $directory: '%phisys.migrations.migrations_directory%'
      $template: '%phisys.migrations.migration_template%'

Usage

  • Initialize the control table (needed just once):
    $ console migrations:init
    
  • View current migrations status:
    $ console migrations:status
    
    To use in batch scripts requiring non-zero return values on error, use:
    $ console migrations:check
    
  • Generate a new migration from template:
    $ console migrations:generate ThisIsTheMigrationSubject
    
  • Do pending migrations:
    $ console migrations:migrate
    
    To do migrations up to (stop in) specified migration id:
    $ console migrations:migrate --target 20201014114643
    
  • Rollback the last migration:
    $ console migrations:rollback
    
    To rollback down to specified migration id, use:
    $ console migrations:rollback --target 20201014114643
    
  • Up a migration id:
    $ console migrations:up 20201014114643
    
  • Down a migration id:
    $ console migrations:down 20201014114643
    
    To Re-Do (down and up) an already migrated id, you may use a single command:
    $ console migrations:redo 20201014114643
    

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.