Generate migrations from existing database structures

Overview

Laravel Migration Generator

Latest Version on Packagist

Generate migrations from existing database structures, an alternative to the schema dump provided by Laravel. A primary use case for this package would be a project that has many migrations that alter tables using ->change() from doctrine/dbal that SQLite doesn't support and need a way to get table structures updated for SQLite to use in tests. Another use case would be taking a project with a database and no migrations and turning that database into base migrations.

Installation

composer require --dev bennett-treptow/laravel-migration-generator
php artisan vendor:publish --provider="LaravelMigrationGenerator\LaravelMigrationGeneratorProvider"

Usage

Whenever you have database changes or are ready to squash your database structure down to migrations, run:

php artisan generate:migrations

By default, the migrations will be created in tests/database/migrations. You can specify a different path with the --path option:

php artisan generate:migrations --path=database/migrations

You can specify the connection to use as the database with the --connection option:

php artisan generate:migrations --connection=mysql2

You can also clear the directory with the --empty-path option:

php artisan generate:migrations --empty-path

This command can also be run by setting the LMG_RUN_AFTER_MIGRATIONS environment variable to true and running your migrations as normal. This will latch into the MigrationsEnded event and run this command using the default options specified via your environment variables. Note: it will only run when your app environment is set to local.

Configuration

Want to customize the migration stubs? Make sure you've published the vendor assets with the artisan command to publish vendor files above.

Environment Variables

Key Default Value Allowed Values Description
LMG_RUN_AFTER_MIGRATIONS false boolean Whether or not the migration generator should run after migrations have completed.
LMG_CLEAR_OUTPUT_PATH false boolean Whether or not to clear out the output path before creating new files. Same as specifying --empty-path on the command
LMG_TABLE_NAMING_SCHEME [Timestamp]_create_[TableName]_table.php string The string to be used to name table migration files
LMG_VIEW_NAMING_SCHEME [Timestamp]_create_[ViewName]_view.php string The string to be used to name view migration files
LMG_OUTPUT_PATH tests/database/migrations string The path (relative to the root of your project) to where the files will be output to. Same as specifying --path= on the command
LMG_SKIPPABLE_TABLES migrations comma delimited string The tables to be skipped
LMG_SKIP_VIEWS false boolean When true, skip all views
LMG_SKIPPABLE_VIEWS '' comma delimited string The views to be skipped
LMG_PREFER_UNSIGNED_PREFIX true boolean When true, uses unsigned variant methods instead of the ->unsigned() modifier.
LMG_USE_DEFINED_INDEX_NAMES true boolean When true, uses index names defined by the database as the name parameter for index methods
LMG_USE_DEFINED_FOREIGN_KEY_INDEX_NAMES true boolean When true, uses foreign key index names defined by the database as the name parameter for foreign key methods
LMG_USE_DEFINED_UNIQUE_KEY_INDEX_NAMES true boolean When true, uses unique key index names defined by the database as the name parameter for the unique methods
LMG_USE_DEFINED_PRIMARY_KEY_INDEX_NAMES true boolean When true, uses primary key index name defined by the database as the name parameter for the primary method
LMG_MYSQL_TABLE_NAMING_SCHEME null ?boolean When not null, this setting will override LMG_TABLE_NAMING_SCHEME when the database driver is mysql.
LMG_MYSQL_VIEW_NAMING_SCHEME null ?boolean When not null, this setting will override LMG_VIEW_NAMING_SCHEME when the database driver is mysql.
LMG_MYSQL_OUTPUT_PATH null ?boolean When not null, this setting will override LMG_OUTPUT_PATH when the database driver is mysql.
LMG_MYSQL_SKIPPABLE_TABLES null ?boolean When not null, this setting will override LMG_SKIPPABLE_TABLES when the database driver is mysql.
LMG_MYSQL_SKIPPABLE_VIEWS null comma delimited string The views to be skipped when driver is mysql
LMG_SQLITE_TABLE_NAMING_SCHEME null ?boolean When not null, this setting will override LMG_TABLE_NAMING_SCHEME when the database driver is sqlite.
LMG_SQLITE_VIEW_NAMING_SCHEME null ?boolean When not null, this setting will override LMG_VIEW_NAMING_SCHEME when the database driver is sqlite.
LMG_SQLITE_OUTPUT_PATH null ?boolean When not null, this setting will override LMG_OUTPUT_PATH when the database driver is sqlite.
LMG_SQLITE_SKIPPABLE_TABLES null ?boolean When not null, this setting will override LMG_SKIPPABLE_TABLES when the database driver is sqlite.
LMG_SQLITE_SKIPPABLE_VIEWS null comma delimited string The views to be skipped when driver is sqlite
LMG_PGSQL_TABLE_NAMING_SCHEME null ?boolean When not null, this setting will override LMG_TABLE_NAMING_SCHEME when the database driver is pgsql.
LMG_PGSQL_VIEW_NAMING_SCHEME null ?boolean When not null, this setting will override LMG_VIEW_NAMING_SCHEME when the database driver is pgsql.
LMG_PGSQL_OUTPUT_PATH null ?boolean When not null, this setting will override LMG_OUTPUT_PATH when the database driver is pgsql.
LMG_PGSQL_SKIPPABLE_TABLES null ?boolean When not null, this setting will override LMG_SKIPPABLE_TABLES when the database driver is pgsql.
LMG_PGSQL_SKIPPABLE_VIEWS null comma delimited string The views to be skipped when driver is pgsql
LMG_SQLSRV_TABLE_NAMING_SCHEME null ?boolean When not null, this setting will override LMG_TABLE_NAMING_SCHEME when the database driver is sqlsrc.
LMG_SQLSRV_VIEW_NAMING_SCHEME null ?boolean When not null, this setting will override LMG_VIEW_NAMING_SCHEME when the database driver is sqlsrv.
LMG_SQLSRV_OUTPUT_PATH null ?boolean When not null, this setting will override LMG_OUTPUT_PATH when the database driver is sqlsrv.
LMG_SQLSRV_SKIPPABLE_TABLES null ?boolean When not null, this setting will override LMG_SKIPPABLE_TABLES when the database driver is sqlsrv.
LMG_SQLSRV_SKIPPABLE_VIEWS null comma delimited string The views to be skipped when driver is sqlsrv

Stubs

There is a default stub for tables and views, found in resources/stubs/vendor/laravel-migration-generator/. Each database driver can be assigned a specific migration stub by creating a new stub file in resources/stubs/vendor/laravel-migration-generator/ with a driver-prefix, e.g. mysql-table.stub for a MySQL specific table stub.

Stub Naming

Table and view stubs can be named using the LMG_(TABLE|VIEW)_NAMING_SCHEME environment variables. Optionally, driver-specific naming schemes can be used as well by specifying LMG_{driver}_TABLE_NAMING_SCHEME environment vars using the same tokens. See below for available tokens that can be replaced.

Table Name Stub Tokens

Table stubs have the following tokens available for the naming scheme:

Token Example Description
[TableName] users Table's name, same as what is defined in the database
[TableName:Studly] Users Table's name with Str::studly() applied to it (useful for standardizing table names if they are inconsistent)
[TableName:Lowercase] users Table's name with strtolower applied to it (useful for standardizing table names if they are inconsistent)
[Timestamp] 2021_04_25_110000 The standard migration timestamp format, at the time of calling the command: Y_m_d_His

Table Schema Stub Tokens

Table schema stubs have the following tokens available:

Token Description
[TableName] Table's name, same as what is defined in the database
[TableName:Studly] Table's name with Str::studly() applied to it, for use with the class name
[Schema] The table's generated schema

View Name Stub Tokens

View stubs have the following tokens available for the naming scheme:

Token Example Description
[ViewName] user_earnings View's name, same as what is defined in the database
[ViewName:Studly] UserEarnings View's name with Str::studly() applied to it (useful for standardizing view names if they are inconsistent)
[ViewName:Lowercase] user_earnings View's name with strtolower applied to it (useful for standardizing view names if they are inconsistent)
[Timestamp] 2021_04_25_110000 The standard migration timestamp format, at the time of calling the command: Y_m_d_His

View Schema Stub Tokens

View schema stubs have the following tokens available:

Token Description
[ViewName] View's name, same as what is defined in the database
[ViewName:Studly] View's name with Str::studly() applied to it, for use with the class name
[Schema] The view's schema

Example Usage

Given a database structure for a users table of:

CREATE TABLE `users` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `username` varchar(128) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `password` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `first_name` varchar(45) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `last_name` varchar(45) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `timezone` varchar(45) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'America/New_York',
  `location_id` int(10) unsigned NOT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `remember_token` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `users_username_index` (`username`),
  KEY `users_first_name_index` (`first_name`),
  KEY `users_last_name_index` (`last_name`),
  KEY `users_email_index` (`email`),
  KEY `fk_users_location_id_index` (`location_id`)
  CONSTRAINT `users_location_id_foreign` FOREIGN KEY (`location_id`) REFERENCES `locations` (`id`) ON UPDATE CASCADE ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci

A tests/database/migrations/[TIMESTAMP]_create_users_table.php with the following Blueprint would be created:

<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->increments('id');
            $table->string('username', 128)->nullable()->index();
            $table->string('email', 255)->index();
            $table->string('password', 255);
            $table->string('first_name', 45)->nullable()->index();
            $table->string('last_name', 45)->index();
            $table->string('timezone', 45)->default('America/New_York');
            $table->unsignedInteger('location_id');
            $table->softDeletes();
            $table->string('remember_token', 255)->nullable();
            $table->timestamps();
            $table->foreign('location_id', 'users_location_id_foreign')->references('id')->on('locations')->onUpdate('cascade')->onDelete('cascade');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('users');
    }
}

Currently Supported DBMS's

These DBMS's are what are currently supported for creating migrations from. Migrations created will, as usual, follow what database drivers Laravel migrations allow for

  • MySQL
  • Postgres
  • SQLite
  • SQL Server
Comments
  • Undefined offset: 0 in WritesTablesToFile.php:38

    Undefined offset: 0 in WritesTablesToFile.php:38

    When I run php artisan generate:migrations with the default configs, I got this error:

    Using connection mysql
    Using /var/www/network/tests/database/migrations as the output path..
    
       1/103 [░░░░░░░░░░░░░░░░░░░░░░░░░░░░]   0% < 1 sec/< 1 sec 26.0 MiB
       ErrorException 
    
      Undefined offset: 0
    
      at vendor/bennett-treptow/laravel-migration-generator/src/Generators/Concerns/WritesTablesToFile.php:38
         34▕         $baseStubFileName = ConfigResolver::tableNamingScheme($driver);
         35▕         foreach ($this->stubNameVariables() as $variable => $replacement) {
         36▕             if (is_callable($replacement)) {
         37▕                 //replacement is a closure
      ➜  38▕                 [$variable, $replacement] = $replacement($baseStubFileName);
         39▕             }
         40▕             if ($variable === null) {
         41▕                 continue;
         42▕             }
    
    opened by mvalim 10
  • [BUG] Call to a member function `useCurrent()` on null

    [BUG] Call to a member function `useCurrent()` on null

    Package Version: 3.1.5

    Database Version: mysql Ver 8.0.23-0ubuntu0.20.04.1 for Linux on x86_64 ((Ubuntu))

    Describe the bug

    Generating some tables with timestamps creates this syntax:

    $table->timestamps()->useCurrent();
    

    which is not valid syntax because the timestamps function does not return a ColumnDefinition

    To Reproduce

    create table test_table
    (
        id              int auto_increment
            primary key,
        created_at      timestamp       default CURRENT_TIMESTAMP not null,
        updated_at      timestamp                                 null on update CURRENT_TIMESTAMP
    )
    

    Expected behavior

    Expected generation to create:

    $table->timestamp('created_at')->nullable()->useCurrent();
    $table->timestamp('updated_at')->nullable()->useCurrentOnUpdate();
    

    P.S. Your package is a huge time saver! Thank you so much.

    opened by kemp 7
  • Expand regex space replacing enum character compatibility

    Expand regex space replacing enum character compatibility

    I found an issue with enums that contain numbers or forward slashes.

    Input examples Text 1 example Text a/b

    I have expanded the regex to process those characters. I expect there could be additional characters that possibly should be added.

    Previously the regex would be up regexes incorrectly and then cause a fatal error later: laravel-migration-generator/src/Tokenizers/MySQL/ColumnTokenizer.php(91): Undefined array key 1

    opened by hellerbenjamin 5
  • File malformatted when comments are present

    File malformatted when comments are present

    Package Version What version are you running? 4.2.2

    Database Version Mysql 8.0.27

    Describe the bug

    There seem to be an error from time to time (it doesn't seem consistent) when generating migrations.

    There's a syntax error.

    public function up() { Schema::create('warehouses', function (Blueprint $table) { $table->smallIncrements('warehouse_id')->unsigned()->primary(); $table->string('warehouse_name', 120)->default(' COMMENT 'The'); $table->dateTime('warehouse_created_utc', 6)->nullable(); $table->dateTime('warehouse_modified_utc', 6)->nullable(); $table->dateTime('warehouse_deleted_utc', 6)->nullable(); }); }

    image

    Thanks

    bug 
    opened by Squad-G 4
  • [BUG] sort_mode foreign_key -> Dependency `REFERENCES` not found

    [BUG] sort_mode foreign_key -> Dependency `REFERENCES` not found

    Package Version 4.0.1

    Database Version mysql 8.0.26-0ubuntu0.20.04.3

    Describe the bug

    $ php artisan generate:migrations --verbose
    Using connection mysql
    Using /home/jim/projects/maglr/dashboard/tests/database/migrations as the output path..
    
       MJS\TopSort\ElementNotFoundException 
    
      Dependency `REFERENCES` not found, required by `js_spread_text`
    
      at vendor/marcj/topsort/src/ElementNotFoundException.php:40
        36|      */
        37|     public static function create($source, $target)
        38|     {
        39|         $message = sprintf('Dependency `%s` not found, required by `%s`', $target, $source);
      > 40|         $exception = new static($message, 0, null, $source, $target);
        41| 
        42|         return $exception;
        43|     }
        44| 
    
      1   vendor/marcj/topsort/src/Implementations/ArraySort.php:77
          MJS\TopSort\ElementNotFoundException::create()
    
      2   vendor/marcj/topsort/src/Implementations/FixedArraySort.php:50
          MJS\TopSort\Implementations\ArraySort::visit()
    
      3   vendor/marcj/topsort/src/Implementations/FixedArraySort.php:33
          MJS\TopSort\Implementations\FixedArraySort::doSort()
    
      4   vendor/bennett-treptow/laravel-migration-generator/src/Helpers/DependencyResolver.php:51
          MJS\TopSort\Implementations\FixedArraySort::sort()
    
      5   vendor/bennett-treptow/laravel-migration-generator/src/Helpers/DependencyResolver.php:21
          LaravelMigrationGenerator\Helpers\DependencyResolver::build()
    
      6   vendor/bennett-treptow/laravel-migration-generator/src/GeneratorManagers/BaseGeneratorManager.php:105
          LaravelMigrationGenerator\Helpers\DependencyResolver::__construct()
    
      7   vendor/bennett-treptow/laravel-migration-generator/src/GeneratorManagers/BaseGeneratorManager.php:87
          LaravelMigrationGenerator\GeneratorManagers\BaseGeneratorManager::sortTables()
    
      8   vendor/bennett-treptow/laravel-migration-generator/src/Commands/GenerateMigrationsCommand.php:80
          LaravelMigrationGenerator\GeneratorManagers\BaseGeneratorManager::handle()
    
      9   vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:36
          LaravelMigrationGenerator\Commands\GenerateMigrationsCommand::handle()
    

    Screenshots image image

    Additional context A bit of an uncommon many to many relation from our end. Where we want the records to be deleted, if any of the references gets deleted. I think it is this "composite foreign key" that is causing the crash.

    opened by Jimbolino 4
  • Sort migrations so migrations for dependent tables occur prior to the tables that depend on them (WIP)

    Sort migrations so migrations for dependent tables occur prior to the tables that depend on them (WIP)

    I was fiddling with your migration generator, adding dependency sorting so migrations can be run with FK enabled in MySql. This is WIP that got me close enough that I could tweak the remaining errors by hand. Just wanted to make you aware its floating around in case you want to pick this up and run with it. I may circle back myself at some point to turn this into a real PR (biggest thing needed is add support for generating table modification migrations containing the FK constraints that need to be deferred and a lot more testing).

    opened by pdbreen 4
  • Should the left and the right side of the comparison be the same?

    Should the left and the right side of the comparison be the same?

    https://github.com/bennett-treptow/laravel-migration-generator/blob/93e92f23307e14d1b2f5c434418766f4be6fedfc/src/Definitions/TableDefinition.php#L109-L112

    opened by ordago 3
  • BadMethodCallException Method LaravelMigrationGenerator\Commands\GenerateMigrationsCommand::newLine does not exist.

    BadMethodCallException Method LaravelMigrationGenerator\Commands\GenerateMigrationsCommand::newLine does not exist.

    Got the following exception

    # php artisan generate:migrations
    Using connection mysql
    Using /var/www/html/tests/database/migrations as the output path..
    
       BadMethodCallException 
    
      Method LaravelMigrationGenerator\Commands\GenerateMigrationsCommand::newLine does not exist.
    
      at vendor/laravel/framework/src/Illuminate/Support/Traits/Macroable.php:103
         99|      */
        100|     public function __call($method, $parameters)
        101|     {
        102|         if (! static::hasMacro($method)) {
      > 103|             throw new BadMethodCallException(sprintf(
        104|                 'Method %s::%s does not exist.', static::class, $method
        105|             ));
        106|         }
        107| 
    
      • Bad Method Call: Did you mean LaravelMigrationGenerator\Commands\GenerateMigrationsCommand::line() ? 
    
          +14 vendor frames 
      15  artisan:37
          Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
    
    opened by GabrieleMartini 3
  • [BUG] ErrorException Required parameter $output follows optional parameter $tableNames

    [BUG] ErrorException Required parameter $output follows optional parameter $tableNames

    Package Version "laravel/sail": "^1.0.1", "php": "^8.0", "laravel/framework": "^8.12",

    Database Version Mysql 5.7.19

    Describe the bug When trying to run the command, I receive a Exception described below. ErrorException Required parameter $output follows optional parameter $tableNames

    To Reproduce command: sail php artisan generate:migrations --connection=mysql2

    Expected behavior A clear and concise description of what you expected to happen.

    Screenshots image

    Additional context Maybe the style of function declaration is deprecated on PHP 8.

    PHP 8.0.2 (cli) (built: Feb 14 2021 14:21:37) ( NTS ) Copyright (c) The PHP Group Zend Engine v4.0.2, Copyright (c) Zend Technologies with Zend OPcache v8.0.2, Copyright (c), by Zend Technologies with Xdebug v3.0.2, Copyright (c) 2002-2021, by Derick Rethans

    opened by patake 3
  • [BUG] Apostrophes in column comment value not escaped

    [BUG] Apostrophes in column comment value not escaped

    Package Version What version are you running? 2.2., 3. 4.1.2

    Database Version What database driver are you using? And what version is that database? MySQL

    Describe the bug A clear and concise description of what the bug is. When generating migrations, if the table has a comment that contains an apostrophe, the apostrophe isn't escaped in the migration.

    To Reproduce Please include any stack traces and applicable .env / config changes you've made Create a table with a comment that contains an apostrophe, then generate a migration.

    Expected behavior A clear and concise description of what you expected to happen. The apostrophes in comments should be escaped.

    Screenshots If applicable, add screenshots to help explain your problem. image

    Additional context Add any other context about the problem here.

    opened by mchlbowyer 2
  • Generate migration from mysql database. ->comment(

    Generate migration from mysql database. ->comment("...") not generated.

    MYSQL COMMENT "xxxx" definition not generate ->comment("xxxx") migration code.

    I repaired two fillets, so this problem was solved.

    see //+Utopszkij ......... //- Utopszkij comments!

    https://drive.google.com/file/d/1kH9jQ5xWrtQ8m9QlThTGvGKCOvCt4GGf/view?usp=sharing

    https://drive.google.com/file/d/10a1FANxZ-oCftARlKi5GTJj095v-8odh/view?usp=sharing

    Fogler Tibor (Utopszkij) [email protected] 2022.02.05.

    opened by utopszkij 2
  • [feat][WIP] : add pgsql migration support

    [feat][WIP] : add pgsql migration support

    This PR includes breaking changes (update the package name to a more generic format <vendor>/<package> rather than package namespace)

    This is a rough but working migration of the existing MySQL's migration generator to PgSQL Currently, migration works and supports multi schema migration generation known issue serial, character varying, timestamps definition generated incorrectly currently, there are many that need work on this like Tests Update README for breaking changes and new configuration Table View support

    opened by rambhosale 0
Releases(4.3.0)
  • 4.3.0(Aug 9, 2022)

    What's Changed

    • Use Database Prefix by @bennett-treptow in https://github.com/bennett-treptow/laravel-migration-generator/pull/71

    Full Changelog: https://github.com/bennett-treptow/laravel-migration-generator/compare/4.2.3...4.3.0

    Source code(tar.gz)
    Source code(zip)
  • 4.2.3(Aug 3, 2022)

    What's Changed

    • Fix empty string default not being parsed correctly by @bennett-treptow in https://github.com/bennett-treptow/laravel-migration-generator/pull/70

    Full Changelog: https://github.com/bennett-treptow/laravel-migration-generator/compare/4.2.2...4.2.3

    Source code(tar.gz)
    Source code(zip)
  • 4.2.2(Aug 2, 2022)

    What's Changed

    • Fix binary columns with a default value not being output correctly by @bennett-treptow in https://github.com/bennett-treptow/laravel-migration-generator/pull/67
    • Fix index tokenizer to accept multiple columns / fks by @bennett-treptow in https://github.com/bennett-treptow/laravel-migration-generator/pull/68

    Full Changelog: https://github.com/bennett-treptow/laravel-migration-generator/compare/4.2.1...4.2.2

    Source code(tar.gz)
    Source code(zip)
  • 4.2.1(Feb 9, 2022)

    What's Changed

    • Fix Text fields being default null unless otherwise specified by @bennett-treptow in https://github.com/bennett-treptow/laravel-migration-generator/pull/65

    Full Changelog: https://github.com/bennett-treptow/laravel-migration-generator/compare/4.2.0...4.2.1

    Source code(tar.gz)
    Source code(zip)
  • 4.2.0(Feb 9, 2022)

  • 4.1.3(Feb 8, 2022)

    What's Changed

    • Fix quoting issues for comments by @bennett-treptow in https://github.com/bennett-treptow/laravel-migration-generator/pull/63

    Full Changelog: https://github.com/bennett-treptow/laravel-migration-generator/compare/4.1.2...4.1.3

    Source code(tar.gz)
    Source code(zip)
  • 4.1.2(Feb 5, 2022)

    What's Changed

    • Fix - update filter on array error when specifying tables on command line by @bennett-treptow in https://github.com/bennett-treptow/laravel-migration-generator/pull/61

    Full Changelog: https://github.com/bennett-treptow/laravel-migration-generator/compare/4.1.1...4.1.2

    Source code(tar.gz)
    Source code(zip)
  • 4.1.1(Feb 5, 2022)

    What's Changed

    • Feature: export comment by @nacl30d in https://github.com/bennett-treptow/laravel-migration-generator/pull/47

    Full Changelog: https://github.com/bennett-treptow/laravel-migration-generator/compare/4.1.0...4.1.1

    Source code(tar.gz)
    Source code(zip)
  • 4.1.0(Nov 29, 2021)

    What's Changed

    • Fixing a bug where CHARACTER SET breaks everything by @ChrisThompsonTLDR in https://github.com/bennett-treptow/laravel-migration-generator/pull/56
    • Nullable is now only set on columns that explicitly state they are or are not nullable (NULL or NOT NULL or DEFAULT NULL). If no nullable modifier is provided, no ->nullable() will be added.

    New Contributors

    • @ChrisThompsonTLDR made their first contribution in https://github.com/bennett-treptow/laravel-migration-generator/pull/56

    Full Changelog: https://github.com/bennett-treptow/laravel-migration-generator/compare/4.0.2...4.1.0

    Source code(tar.gz)
    Source code(zip)
  • 4.0.2(Oct 26, 2021)

    What's Changed

    • php-cs-fixer ordered_imports by @Jimbolino in https://github.com/bennett-treptow/laravel-migration-generator/pull/51
    • fixes comparison by @ordago in https://github.com/bennett-treptow/laravel-migration-generator/pull/55

    New Contributors

    • @ordago made their first contribution in https://github.com/bennett-treptow/laravel-migration-generator/pull/55

    Full Changelog: https://github.com/bennett-treptow/laravel-migration-generator/compare/4.0.1...4.0.2

    Source code(tar.gz)
    Source code(zip)
  • 4.0.1(Sep 27, 2021)

  • 4.0.0(Sep 24, 2021)

    New foreign key sorting! Check out UPGRADE.md and README.md for upgrade and information on new sorting options.

    Also included in this release is the option to use defined timestamp column types instead of converting to timestamp() as completed by @nacl30d in PR #46

    Source code(tar.gz)
    Source code(zip)
  • 3.2.3(Jun 18, 2021)

    Thanks to @hellerbenjamin for bringing this to light with #39. #40 resolves this problem with not finding all quoted values other than alpha characters.

    Source code(tar.gz)
    Source code(zip)
  • 3.2.0(Jun 9, 2021)

  • 3.1.6(Apr 28, 2021)

  • 3.1.3(Apr 26, 2021)

  • 3.1.2(Apr 26, 2021)

  • 3.1.1(Apr 26, 2021)

  • 3.1.0(Apr 25, 2021)

  • 3.0.1(Apr 25, 2021)

  • 3.0.0(Apr 25, 2021)

    All config options have been updated to be env vars. Since it seems like config options will continue to grow, it makes more sense to remove the headache of having to upgrade the config file every time there's a new config option and instead move towards .env files. See UPGRADE.md on how to upgrade to 3.0.0

    Source code(tar.gz)
    Source code(zip)
  • 2.2.3(Apr 25, 2021)

  • 2.2.2(Apr 25, 2021)

    Previous PR with new config options did not apply to single-column index methods like:

    $table->string('unique_field')->unique('unique_field_key_name');
    

    were not being correctly updated. Only multi-column indices were using the new config. This release will correct that.

    Source code(tar.gz)
    Source code(zip)
  • 2.2.1(Apr 25, 2021)

    This release adds 4 new config keys for each of the key types so you can specify which types you want index names to be brought into the migrations. Note that in some cases, you will still want to turn this config on for multi-column indices that are long because index names can only be 64 characters long.

    Source code(tar.gz)
    Source code(zip)
Owner
Bennett Treptow
Bennett Treptow
A PHP webpage that uses string replacements to generate a binary on the fly that you can enter at setup in NEOS.

openpilot-installer-generator A PHP webpage that uses string replacements to generate a binary on the fly that you can enter at setup in NEOS. What is

null 34 Nov 17, 2022
A PHP README File Generator, to generate easily your GitHub README files 🎉

Readme Generator ?? Requiremennts ?? Make sure you have PHP 8.0 or higher installed. Steup ⚙️ Install Composer v2 or higher (https://getcomposer.org)

♚ PH⑦ de Soria™♛ 9 Oct 18, 2022
Prequel for Laravel. Clear and concise database management.

TL;DR? Test Prequel here! What is Prequel exactly? Prequel is meant to be a database management tool for Laravel to replace the need for separate stan

Protoqol 1.4k Dec 27, 2022
Laravel Migrations Generator: Automatically generate your migrations from an existing database schema.

Laravel Migrations Generator Generate Laravel Migrations from an existing database, including indexes and foreign keys! Upgrading to Laravel 5.4 Pleas

Bernhard Breytenbach 3.3k Dec 30, 2022
Laravel Migrations Generator: Automatically generate your migrations from an existing database schema.

Laravel Migrations Generator Generate Laravel Migrations from an existing database, including indexes and foreign keys! This package is cloned from ht

Kit Loong 1.4k Jan 1, 2023
Database migrations for PHP ala ActiveRecord Migrations with support for MySQL, Postgres, SQLite

Introduction Ruckusing is a framework written in PHP5 for generating and managing a set of "database migrations". Database migrations are declarative

Cody Caughlan 506 Nov 17, 2022
Generate Laravel test factories from your existing models

Laravel Test Factory Generator php artisan generate:model-factory This package will generate factories from your existing models so you can get starte

Marcel Pociot 923 Dec 16, 2022
Ariama Victor (A.K.A. OVAC4U) 106 Dec 25, 2022
Simple user settings facade for Hyperf. Settings are stored as JSON in a single database column, so you can easily add it to an existing table.

hyperf-user-settings Simple user settings util for hyperf Settings are stored as JSON in a single database column, so you can easily add it to an exis

lysice 1 Oct 15, 2021
For using Laravel with a pre-existing MySQL Database

MySQL to Laravel This is a script to help with mapping an existing MySQL database to a new Laravel build. Place the script in the public folder of you

Chad Haney 17 Nov 29, 2022
PHP Database Migrations for Everyone

Phinx: Simple PHP Database Migrations Intro Phinx makes it ridiculously easy to manage the database migrations for your PHP app. In less than 5 minute

CakePHP 4.3k Jan 7, 2023
Framework agnostic database migrations for PHP.

Phoenix Framework agnostic database migrations for PHP. Features Validation all settings in migration before executing first query Multiple migration

Michal Lulco 148 Nov 19, 2022
PHP Database Migrations for Everyone

Phinx: Simple PHP Database Migrations Intro Phinx makes it ridiculously easy to manage the database migrations for your PHP app. In less than 5 minute

CakePHP 4.3k Jan 7, 2023
Validate PHP database migration files for compliance with best practices. Ensure db migrations are irreversible.

PHP DB Migration Validator Introduction In modern PHP frameworks such as Symfony and Laravel, migrations usually have up and down methods. In up metho

Anton Komarev 17 Dec 14, 2022
The MX_PhinxMigrations module integrates Phinx database migrations into Magento 2

MX Phinx Migrations About The MX_PhinxMigrations module integrates Phinx database migrations into Magento 2 as a replacement for the built-in setup:up

Inviqa 34 Jul 30, 2021
Declare database migrations and factory definitions inside Laravel models.

Lucid This package allows you to declare database migrations and factory definitions inside of your Laravel models. Running the lucid:migrate command

null 23 Jul 9, 2022
A Simple MVC PHP Framework, integrated with lot of features such as Session, Cookies, Migrations, Database, Factories, Seeding, Bootstrap and Tailwind CSS

Navite A Simple MVC PHP Framework, integrated with lot of features such as Session, Cookies, Migrations, Database, Factories, Seeding, Bootstrap and T

Celionatti 2 Aug 22, 2022
Laravel ClickHouse adds CH client integration, generation & execution of ClickHouse database migrations to the Laravel application.

Laravel ClickHouse Introduction Laravel ClickHouse database integration. This package includes generation and execution of the ClickHouse database mig

cybercog 11 Dec 20, 2022
Output complex, flexible, AJAX/RESTful data structures.

Fractal Fractal provides a presentation and transformation layer for complex data output, the like found in RESTful APIs, and works really well with J

The League of Extraordinary Packages 3.5k Jan 8, 2023
Map nested JSON structures onto PHP classes

JsonMapper - map nested JSON structures onto PHP classes Takes data retrieved from a JSON web service and converts them into nested object and arrays

Christian Weiske 1.4k Dec 30, 2022