当前位置: 首页 > 软件库 > Web应用开发 > Web框架 >

laravel-migrations-generator

授权协议 MIT License
开发语言 PHP
所属分类 Web应用开发、 Web框架
软件类型 开源软件
地区 不详
投 递 者 马涵蓄
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

Laravel Migrations Generator

Style check CITests CI

Generate Laravel Migrations from an existing database, including indexes and foreign keys!

This package is cloned from https://github.com/Xethron/migrations-generator and updated to support Laravel 5.6 and above, with a lot of feature improvements.

Supported Database

Currently, Generator support generate migrations from:

  • MySQL
  • PostgreSQL
  • SQL Server

Version Compatibility

Laravel Version
8.x 5.x
7.x 5.x
6.x 5.x
5.8.x 5.x
5.7.x 5.x
5.6.x 5.x
5.5 and below https://github.com/Xethron/migrations-generator

Install

The recommended way to install this is through composer:

composer require --dev "kitloong/laravel-migrations-generator"

Laravel Setup

Laravel will automatically register service provider for you.

Lumen Setup

Auto-discovery is not available in Lumen, you need some modification on bootstrap/app.php.

Enable facade

Uncomment the following line.

$app->withFacades();

Register provider

Add following line into the Register Service Providers section.

$app->register(\MigrationsGenerator\MigrationsGeneratorServiceProvider::class);

Usage

To generate migrations from a database, you need to have your database setup in Laravel's config (config/database.php).

To create migrations for all the tables, run:

php artisan migrate:generate

You can specify the tables you wish to generate using:

php artisan migrate:generate --tables="table1,table2,table3,table4,table5"

You can also ignore tables with:

php artisan migrate:generate --ignore="table3,table4,table5"

Laravel Migrations Generator will first generate all the tables, columns and indexes, and afterwards setup all the foreign key constraints.

So make sure you include all the tables listed in the foreign keys so that they are present when the foreign keys are created.

You can also specify the connection name if you are not using your default connection with:

php artisan migrate:generate --connection="connection_name"

Squash migrations

By default, Generator will generate multiple migration files for each table.

You can squash all migrations into a single file with:

php artisan migrate:generate --squash

Options

Run php artisan help migrate:generate for a list of options.

Options Description
-c, --connection[=CONNECTION] The database connection to use
-t, --tables[=TABLES] A list of Tables you wish to Generate Migrations for separated by a comma: users,posts,comments
-i, --ignore[=IGNORE] A list of Tables you wish to ignore, separated by a comma: users,posts,comments
-p, --path[=PATH] Where should the file be created?
-tp, --template-path[=TEMPLATE-PATH] The location of the template for this generator
--date[=DATE] Migrations will be created with specified date. Foreign keys will be created for specified time + 1 second. Date should be in format suitable for Carbon::parse
--table-filename[=TABLE-FILENAME] Define table migration filename, default pattern: [datetime_prefix]_create_[table]_table.php
--fk-filename[=FK-FILENAME] Define foreign key migration filename, default pattern: [datetime_prefix]_add_foreign_keys_to_[table]_table.php
--default-index-names Don't use db index names for migrations
--default-fk-names Don't use db foreign key names for migrations
--use-db-collation Follow db collations for migrations
--squash Generate all migrations into a single file

Thank You

Thanks to Bernhard Breytenbach for his great work. This package is cloned from https://github.com/Xethron/migrations-generator.

Thanks to Jeffrey Way for his amazing Laravel-4-Generators package. This package depends greatly on his work.

Contributors

Contributors

License

The Laravel Migrations Generator is open-sourced software licensed under the MIT license

  • Laravel Migrations Generator是自动生成数据库迁移文件的工具。 0.准备工作 Laravel5.5及以上版本,确保正确创建数据库以及数据库配置正确。 1.安装: 项目目录下执行: composer require --dev "xethron/migrations-generator" 2.使用: 为当前数据库所有数据表生成数据库迁移文件: php artisan mig

  • 安装 推荐的安装方式是通过composer: 作曲家需要–dev “ kitloong / laravel-migrations-generator ” Laravel安装 Laravel将自动为您注册服务提供商。 流明设置 自动发现在流明中不可用,您需要对 bootstrap/app.php 启用外观 取消注释以下行 $app->withFacades(); 注册提供商 添加以下行 $app->

  • laravel migration 逆向生成迁移文件 composer github laravel5.8 安装 composer require --dev "xethron/migrations-generator" 配置 1、修改文件 config/app.php,添加相应的服务提供者 'providers' => [ //...... Way\Generators\

  • 熟悉laravel的同学都知道,laravel的数据迁移和数据填充,能够随着源代码的改变而同步记录同步数据库结构的变化,也就是对数据库的版本控制。 但是,有的项目开发之初,数据库结构的变化会比较频繁,每个都手动创建migrate文件的,工作量会比较大,或者老项目已有数据库,如果手动为所有的已存在的表去创建迁移文件的会非常耗时,还容易出错。 这里,就给大家分享一下如何逆向生成迁移文件。 git地址:

  • -- 文章仅供个人学习参考,如有不恰当的地方,希望前辈们指教。-- 1、使用命令 创建数据库文件 php artisan make:model --migration Model/Posts php artisan make:model --migration Model/Users 2、修改database\migrations 文件夹下会自动生成数据库文件 class CreatePostsT

  • 默认进入laravel主目录下, php artisan tinker $obj = new \App\xxxModel; //给表中写入数据 $obj->表字段 = "content"; $obj->name = "orange"; $obj->save(); 使用时会出错原因: 1、单词写错了,或者命名空间不对。 2、除字符串以外的内容都应该是英文输入,不然识别不了 3、自己的粗心

  • 1.创建建表文件   php artisan make:migration create_comments_table   打开database/migrations/xxx_create_comments_table.php: public function up() { Schema::create('comments',function(Blueprint $tabl

  • 本人用的是laravel5.6版本,其他版本可以参考 https://github.com/Xethron/migrations-generator 第一步 安装依赖包 composer require --dev "xethron/migrations-generator:~1.3.0" 第二步 在config/app.php 里面的 'providers' => []加上两行代码 Way\G

  • 创建migrate文件 php artisan make:migration create_comments_table 编辑migrate文件 <?php use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Mi

  • Yunjuji Generator *** # github或者码云上拉取目录使用说明 ## 目录说明 - model.csv【字段信息文件, 和你的实体同级,必须】【具体规则参考 `csv说明` 】 - model.json【自己的命名空间, 和实体同级,必须】【具体规则参考 `model.json文件`】 - filter.json【过滤字段文件, 和你的实体同级,非必须】【具体规则参考 `过

  • 1. 安装 composer require fzaninotto/faker --dev 2. 创建 migrations 参考:laravel文档 3. 定义ModelFactory 说明: 默认是英文,如若需要支持中文,需要改写原来的做法 // 支持中文假数据 $faker = Faker\Factory::create('zh_CN'); $factory->define(ApiMe

  • 1.安装 'l5-repository': 直接参照github文档:https://github.com/andersao/l5-repository 1>composer require prettus/l5-repository 2>vim config/app.php 给 'providers' 元素,添加 'Prettus\Repository\Providers\Repo

  • 百度一般都是composer安装 xethron/migrations-generator 扩展,但是我本地运行这个命令直接报错,并且我看github的信息,这个包是基于laravel5的,我用laravel8,显然不支持,百度了一个测试可用,相关回答参考https://stackoverflow.com/questions/63809325/laravel-7-2-composer-instal

 相关资料
  • Complete migrations were introduced in Gitea 1.9.0. It defines two interfaces to support migrating repository data from other git host platforms to Gitea or, in the future, migrating Gitea data to oth

  • Scala Migrations 是一个类库用来简化数据库模型的升级和回滚的管理,允许通过一个版本控制系统来管理数据库模型。它旨在允许多个开发人员对一个项目一个数据库后端设计模式的修改,独立适用迁移到其本地数据库进行调试,当完成后,检查他们到源代码控制管理系统作为一个 经营正常的源代码。其他开发商然后检查新的迁移和应用到他们的本地数据库。最后,Scala Migrations 被用来迁移生产数据库到最新的架构版本。

  • MyBatis Migrations 是 MyBatis 项目下的一款采用命令行来迁移数据库的工具。 MyBatis Schema 迁移系统(或简称为 MyBatis 迁移)旨在: 使用任何新数据库或现有数据库 利用源代码管理系统(例如Subversion) 使并发开发人员或团队能够独立工作 允许冲突非常明显且易于管理 允许向前和向后迁移(分别演进和演进) 使数据库的当前状态易于访问和理解 尽管具

  • At the foundation, any forum revolves around data: users provide discussions, posts, profile information, etc. Our job as forum developers is to provide a great experience for creating, reading, updat

  • 就像你使用Git / SVN来管理源代码的更改一样,你可以使用迁移来跟踪数据库的更改. 通过迁移,你可以将现有的数据库转移到另一个状态,反之亦然:这些状态转换将保存在迁移文件中,它们描述了如何进入新状态以及如何还原更改以恢复旧状态. 你将需要Sequelize CLI. CLI支持迁移和项目引导. 命令行界面 安装命令行界面 让我们从安装CLI开始,你可以在 这里 找到说明. 最推荐的方式是这样安

  • 就像你使用版本控制 如 Git 来管理源代码的更改一样,你可以使用迁移来跟踪数据库的更改. 通过迁移,你可以将现有的数据库转移到另一个状态,反之亦然:这些状态转换将保存在迁移文件中,它们描述了如何进入新状态以及如何还原更改以恢复旧状态. 你将需要 Sequelize CLI. CLI支持迁移和项目引导. Sequelize 中的 Migration 是一个 javascript 文件,它导出两个函