【问题标题】:Creating new table in octobercms在 octobercms 中创建新表
【发布时间】:2021-07-19 17:41:45
【问题描述】:

我必须在 octobercms 项目中创建新表,我遵循文档并在插件更新文件中添加了新的迁移文件我有 create_currency_rates_table.php 文件,它有这个代码

<?php namespace RainLab\User\Updates;
use Schema;
use October\Rain\Database\Updates\Migration;

class CreateCurrencyRateTable extends Migration
{
    public function up()
    {
        Schema::create('currency_rates', function($table)
        {
            $table->engine = 'InnoDB';
            $table->increments('id');
            $table->string('currency');
         
        });
    }

    public function down()
    {
        Schema::drop('currency_rate');
    }
}

当我使用 php artisan october:up 时,它没有检测到新的迁移。如何创建新表?谁能帮帮我?

【问题讨论】:

  • 你试过只输入 php artisan migrate 吗?
  • 我试过但失败了

标签: laravel octobercms octobercms-plugins octobercms-backend


【解决方案1】:

您还需要更新 plugins\&lt;author&gt;\&lt;plugin_name&gt;\updates\version.yaml 这个文件并在其中添加您的文件名。

因此,在您的情况下,您添加了一个像 create_currency_rates_table.php 这样的文件,然后您需要在 version.yaml 中添加文件的详细信息

例如:

1.0.1: First version of Demo
1.0.2:
  - Description About what is this update about?
  - create_currency_rates_table.php

现在当您下次只需login to backend 时,此表将自动创建。

如有任何疑问,请发表评论。

【讨论】:

    猜你喜欢
    • 2020-01-15
    • 2017-03-29
    • 2017-04-07
    • 2017-12-03
    • 2019-11-27
    • 2021-07-25
    • 1970-01-01
    • 1970-01-01
    • 2019-05-23
    相关资源
    最近更新 更多