我正在使用laravel 5进行申请。 我改变了字段'投票'我定义为
$ table-> enum ('vote', [ '- 1 ', '0 ', '1 ']);
并且应该如下
$ table-> enum ('vote', [' 1', ' 2', ' 3', ' 4', ' 5'] ) ;
答案 0 :(得分:19)
为此,您应该按照以下步骤操作:
创建新的迁移文件
# my original answer
In [1]: %%timeit colors = np.random.randint(256, size=(11, 3)); labels = np.random.randint(11, size=(512, 512))
labels[..., None].choose(colors)
....:
10 loops, best of 3: 52 ms per loop
# Divakar's answer
In [2]: %%timeit colors = np.random.randint(256, size=(11, 3)); labels = np.random.randint(11, size=(512, 512))
colors[labels.ravel()].reshape(labels.shape+(3,))
....:
100 loops, best of 3: 4.44 ms per loop
# using take
In [3]: %%timeit colors = np.random.randint(256, size=(11, 3)); labels = np.random.randint(11, size=(512, 512))
colors.take(labels, axis=0)
....:
The slowest run took 4.96 times longer than the fastest. This could mean that an
intermediate result is being cached
1000 loops, best of 3: 1.25 ms per loop
# using integer array indexing
In [4]: %%timeit colors = np.random.randint(256, size=(11, 3)); labels = np.random.randint(11, size=(512, 512))
....: colors[labels]
....:
100 loops, best of 3: 4.19 ms per loop
打开新创建的迁移文件(app_folder \ database \ migrations {date_migrationfile_was_created} -update_votes_tables.php)
更改要更改的列
有关详细信息,请参阅documentation on database migrations
注意:如果您将迁移文件添加到问题中,我们可以提供更详细的帮助
答案 1 :(得分:11)
这是我怎么做的:
php artisan make:migration Alter_votes_to_tableName --table=tableName
打开文件然后将其更改
php artisan migrate
答案 2 :(得分:1)
修改列将需要doctrine/dbal
软件包。
安装软件包
composer require doctrine/dbal
创建迁移
php artisan make:migration add_values_to_vote_column_in_votes_table
更新迁移文件
Schema::table('votes', function (Blueprint $table) {
$table->enum('vote', [' 1', ' 2', ' 3', ' 4', ' 5'])->change();
});
运行迁移
php artisan migrate
答案 3 :(得分:0)
首先使用以下命令创建新迁移
php artisan make:migration Alter_your_comment_yourTableName --table=yourTableName
根据需要更改文件,然后在composer中运行以下命令
php artisan migrate