aimme/laravel-dynamo

此包的最新版本(3.1.3)没有可用的许可证信息。

用于创建Laravel组件的应用

3.1.3 2019-02-22 12:24 UTC

This package is auto-updated.

Last update: 2024-09-23 00:38:49 UTC


README

Built for Laravel 5 MIT License

该包使用原始mysql文件为应用程序生成迁移文件。我用这个包在从MySQL Workbench将ERD导出为原始mysql后,为应用程序创建迁移文件。我刚刚在Laravel 5上使用了它,希望到目前为止它运行正常。

安装

在您的composer.json中要求此包并更新composer

"aimme/laravel-dynamo": "1.0.0"

要在Laravel 5中发布配置设置,请使用

php artisan vendor:publish --provider="Aimme\Dynamo\DynamoServiceProvider"

生成器绑定到ioC的dynamo

$generator = App::make('dynamo');

文档

  • config/dynamo.php中配置路径。已提供示例值
	'migrations' => [
	     //path to the source erd sql export file
		'source' => [
			'raw' => 'mysql.sql', //source export file by default app will look for the file project root folder.
			'formatted' => 'formatted_source.txt' //to store the formatted source, by default the file will be created in project root
			],
		//make: this array is loaded to the MakeMigraions as making migrations configs
		//order: tells the order of making migrations
		//id_as_auto_increment:  true means if id is set in a table it would be set as increments()
		//or bigIncrements() depending on the field type declared.
		//timestamps_for_all: adds timestamps()->useCurrent() to all migrations even if its not declared in dump
		//output_path: to where all the migrations to be created. Changing it from here wouldn't bring any changes while running through artisan. Just use --path option to define path other than app defined path (database/migrations).
		//clean_folder: removes all the previous file in the path, if any
		'make' => [
			'order' => [
				// 'users',
	            'items_features',
	            // 'listings',
	            'sellers',
	            // 'features',
	            // 'items'
			],
			'id_as_auto_increment' => true,
			'timestamps_for_all' => true,
			'include_remaining' => true,
			'output_path' => 'database/migrations', 
			'clean_folder' => true
		],
	]

配置后,运行artisan命令从sql文件生成迁移文件

php artisan generate:migrations

有一个参数可以更改sql文件的路径,如果没有定义,它将查找配置数组[migrations] [source] [raw]中定义的文件路径。有关更多信息,请参阅上面的配置文件。默认情况下,您可以将名为mysql.sql的mysql文件放在根目录中,无需对配置进行任何更改。

示例

php artisan generate:migrations mysqlfile.sql

可以使用--path选项定义不同于应用程序定义的迁移路径(database/migrations)。迁移文件应该创建的位置。

示例

php artisan generate:migrations mysqlfile.sql --path=another/migrations