nf/migration

将迁移添加到NF主题

2.0.3 2018-12-13 03:54 UTC

This package is auto-updated.

Last update: 2024-09-13 23:19:03 UTC


README

这是我们的主题扩展:https://github.com/hieu-pv/nf-theme

NF迁移

安装

迁移包也可以用于插件,该插件是用NF Core模块创建的

要创建一个使用NF Core模块的空插件,请移动到 wp-contents/plugins

通过运行以下命令并选择正确选项,您可以创建一个空插件

vcc create-project --name="your_plugin_name"

plugin/uninstall.php 复制文件 uninstall.php。这样,当插件被卸载时,表将自动删除

要在您的插件中使用nf-core模块,请确保您在 config/app.php 中有正确的配置,其中 is_plugin=trueplugin_file={your_main_plugin_file_name}

步骤1:通过Composer安装

composer require nf/migration

步骤2:添加服务提供者

打开 config/app.php 并注册所需的服务提供者。

  'providers'  => [
        // .... Others providers
        \NF\Database\Providers\DatabaseServiceProvider::class,
    ],

步骤3:更新自动加载规则

将以下代码添加到您的 composer.json 文件的 autoload 部分

    "classmap": [
        "database"
    ]

步骤4:发布所需文件

运行发布命令后,我们将在主题根目录下看到一个名为 database 的新文件夹

php command migration:publish

步骤5:使用命令行

创建迁移文件

php command make:migration {file_name} --create="{table_name}"

或者,您也可以创建另一个文件来更新现有表

php command make:migration {file_name} --table="{existing_table_name}"

示例

// create test table
php command make:migration create_test_table --create=test

// update test table
php command make:migration add_more_column_to_test_table --table=test

步骤6:迁移您的表

php command migrate

回滚所有迁移文件

php command migrate:rollback