All Projects → maxim-oleinik → Blade Migrations Laravel

maxim-oleinik / Blade Migrations Laravel

Licence: mit
An intelligent alternative version of Laravel 5/6 Database Migrations - uses raw-sql syntax, transactions, auto-rollback, UP-DOWN-UP testing

Projects that are alternatives of or similar to Blade Migrations Laravel

Laravel Email Verification
Laravel package to handle user verification using an activation mail
Stars: ✭ 63 (+152%)
Mutual labels:  laravel, laravel-package, laravel5
Laravel User Verification
PHP package built for Laravel 5.* to easily handle a user email verification and validate the email
Stars: ✭ 755 (+2920%)
Mutual labels:  laravel, laravel-package, laravel5
Laravel Opcache
Laravel Package for OPcache
Stars: ✭ 1,116 (+4364%)
Mutual labels:  laravel, laravel-package, artisan
Laravel Settings
Simple Settings package for a laravel application
Stars: ✭ 45 (+80%)
Mutual labels:  laravel, laravel-package, laravel5
Auth Tests
Always-current tests for Laravel's authentication system. Curated by the community.
Stars: ✭ 230 (+820%)
Mutual labels:  laravel, laravel-package, laravel5
Laravel Pdf
A Simple package for easily generating PDF documents from HTML. This package is specially for laravel but you can use this without laravel.
Stars: ✭ 79 (+216%)
Mutual labels:  laravel, laravel-package, laravel5
Twitter
Twitter API for Laravel 5.5+, 6.x, 7.x & 8.x
Stars: ✭ 755 (+2920%)
Mutual labels:  laravel, laravel-package, laravel5
Generator
Laravel 5.3+ Scaffold Generator, Support both bootstrap and Semantic UI
Stars: ✭ 327 (+1208%)
Mutual labels:  laravel, laravel-package, artisan
Laravel Short Url
A Laravel package to shorten urls
Stars: ✭ 127 (+408%)
Mutual labels:  laravel, laravel-package, laravel5
Eye
Eyewitness.io package for Laravel 5 applications
Stars: ✭ 114 (+356%)
Mutual labels:  laravel, laravel-package, laravel5
Laravel Sync Migration
Developer tool helps to sync migrations without refreshing the database
Stars: ✭ 89 (+256%)
Mutual labels:  database-migrations, laravel, laravel-package
Framework
The truly Laravel E-commerce Framework
Stars: ✭ 456 (+1724%)
Mutual labels:  laravel, laravel-package, laravel5
Sweet Alert
A BEAUTIFUL, RESPONSIVE, CUSTOMIZABLE, ACCESSIBLE (WAI-ARIA) REPLACEMENT FOR JAVASCRIPT'S POPUP BOXES FOR LARAVEL
Stars: ✭ 696 (+2684%)
Mutual labels:  laravel, laravel-package
Laravel Terminal
Runs artisan command in web application
Stars: ✭ 682 (+2628%)
Mutual labels:  laravel, artisan
Artisan View
👀 Manage your views in Laravel projects through artisan
Stars: ✭ 708 (+2732%)
Mutual labels:  laravel, artisan
Orm
A drop-in Doctrine ORM 2 implementation for Laravel 5+ and Lumen
Stars: ✭ 712 (+2748%)
Mutual labels:  laravel, laravel-package
Laravel Heyman
Declarative style of authorization and validation in laravel.
Stars: ✭ 677 (+2608%)
Mutual labels:  laravel, laravel-package
Chat
A Laravel chat package. You can use this package to create a chat/messaging Laravel application.
Stars: ✭ 710 (+2740%)
Mutual labels:  laravel, laravel-package
Laravel Aws Sns
Laravel package for the AWS SNS Events
Stars: ✭ 24 (-4%)
Mutual labels:  laravel, laravel-package
Laravel Open Source Projects
A Web Artisan list of categorized OPEN SOURCE PROJECTS built with Laravel PHP Framework.
Stars: ✭ 676 (+2604%)
Mutual labels:  laravel, laravel-package

Database Migrations - Laravel

rus / Latest Stable Version Total Downloads License

An intelligent alternative version of Laravel 5 Database Migrations

Features

  • Using raw SQL queries
    • you can use all the capabilities of your database to describe the structure and changes
    • easy work with procedures and functions
    • safe data migrations (INSERT/UPDATE)
    • IDE native syntax support
  • Running migrations within a transaction with automatic rollback in case of an error (if your database supports it, PostgreSQL for example)
  • Dynamic output running the SQL-queries
  • Automatic rollback after switching the branch (for reviewing, testing, demo, building at permanent/staging database)
  • Auto-update the migration after editing (version change in the name of the migration file)
  • Apply with rollback testing - UD-DOWN-UP
  • Rollback or Reload any selected migration

Requirements

  • PHP >= 7.0
  • Laravel >= 5.1/6.X (supports all versions 5.1 - 6.X)

Syntax

  • --TRANSACTION - if specified, the migration will be launched within a transaction
  • Instructions are separated by --UP and--DOWN tags.
  • The SQL queries are separated by ";" (the last character at the end of the line)
--TRANSACTION
--UP
ALTER TABLE authors ADD COLUMN code INT;
ALTER TABLE posts   ADD COLUMN slug TEXT;

--DOWN
ALTER TABLE authors DROP COLUMN code;
ALTER TABLE posts   DROP COLUMN slug;

If you need to change the delimiter (when in SQL you have to use ";")

[email protected]
--UP
    ... some sql [email protected]
    ... some sql [email protected]

--DOWN
    ... some sql [email protected]
    ... some sql [email protected]

Install

  1. Require this package with composer using the following command:

        composer require maxim-oleinik/blade-migrations-laravel
    
  2. Update config/database.php

        'migrations' => [
            // migrations table name
            'table' => 'migrations',
    
            // path to migrations dir
            'dir'   => __DIR__ . '/../database/migrations',
        ],
    
  3. Register ServiceProvider at config/app.php for Laravel < 5.5

       'providers' => [
            ...
            Blade\Migrations\Laravel\MigrationsServiceProvider::class,
        ],
    

    for Laravel 6.X replace

        Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class
        # with
        Illuminate\Foundation\Providers\ComposerServiceProvider::class,
        Illuminate\Foundation\Providers\ArtisanServiceProvider::class
    
  4. Create migration table

        php artisan migrate:install
    

Usage

Create Migration file

    php artisan make:migration NAME

Status

    php artisan migrate:status

    +---+----+---------------------+------------------------+
    |   | ID | Date                | Name                   |
    +---+----+---------------------+------------------------+
    | Y | 6  | 28.08.2018 20:17:01 | 20180828_195348_M1.sql |
    | D | 7  | 28.08.2018 20:17:21 | 20180828_201639_M3.sql |
    | A |    |                     | 20180828_200950_M2.sql |
    +---+----+---------------------+------------------------+
  • Y - applied migration
  • D - have to rollback (no this migration in the current branch/revision)
  • A - not applied yet, next to be run

Migrate

    # Apply next А-migration
    php artisan migrate

    # Apply the migration without a prompt
    php artisan migrate -f

    # Apply with rollback testing: UP-DOWN-UP
    php artisan migrate -t

    # Auto-migrate all - rollback all D-migrations and appply all А-migrations
    php artisan migrate --auto

    # Apply migration from the specified file
    php artisan migrate FILE_NAME

Rollback

The migrate file with SQL-commands is saved to DB after applying the migration. So the rollback is processing from this saved instructions. This is done to be able to rollback the migration when project switches to another branch which does not contains this file.

    # Rollback the latest Y-migration
    php artisan migrate:rollback

    # To force the rollback without a prompt
    php artisan migrate:rollback -f

    # Rollback migration by its ID
    php artisan migrate:rollback --id=N

    # Rollback migration with commands taken from migration file, not from DB (if saved version contains error)
    php artisan migrate:rollback --load-file

Reload

Rollback migration and run it again

    php artisan migrate:reload

    # the same options as rollback
    php artisan migrate:reload -f --id=N --load-file
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].