marshmallow/laravel-open-ai-migrations

Marshmallow - 使用 Open AI 的 Laravel 迁移

v0.0.3 2023-02-16 08:41 UTC

README

marshmallow.

Latest Version on Packagist Total Downloads License Stars Forks

它做什么?

此命令

artisan make:ai-migration "Add is_active and published_at to the posts table after intro"

INFO  Migration [database/migrations/2023_02_16_082621_change_the_slug_column_in_blogs_to_be_nullable_and_unique.php] created successfully.
INFO  Estimated costs of [$0.00302] for using [151] tokens.

将变成这样!!

Schema::table('posts', function (Blueprint $table) {
    $table->after('intro', function (Blueprint $table) {
        $table->boolean('is_active')->default(true);
        $table->dateTime('published_at')->nullable();
    });
});

安装

您可以通过 composer 安装此包

通过 Composer 安装

composer require marshmallow/laravel-open-ai-migrations

发布配置文件

php artisan vendor:publish --tag=laravel-open-ai-migrations

添加您的 API 密钥

将您的 Open AI API 密钥添加到您的 .env 文件。

OPEN_AI_API_KEY="sk-xxxxxxx"

更新配置文件

发布配置文件后,您需要添加您的 Open AI API 令牌。那里还有一些其他的魔法,您真的应该看看。

使用方法

运行 AI 迁移命令,描述您想要此迁移执行的操作。

artisan make:ai-migration "Change the slug column in blogs to be nullable and unique"

在此 artisan 命令准备就绪后,您将在迁移文件夹中有一个完整的迁移文件,内容正好如此!

public function up()
{
    Schema::table('blogs', function (Blueprint $table) {
        $table->string('slug')->nullable()->unique()->change();
    });
}

变更日志

有关最近更改的更多信息,请参阅 CHANGELOG

贡献

有关详细信息,请参阅 CONTRIBUTING

安全漏洞

请参阅 我们的安全策略,了解如何报告安全漏洞。

致谢

许可证

MIT 许可证 (MIT)。有关更多信息,请参阅 许可证文件