dongmi4734 2018-11-13 08:12
浏览 45

即使遵循迁移过程,我也无法从laravel向表中添加新列?

I am following all the steps for adding new column votes to the user table from laravel, still there isn't in the database? Please tell me where is my mistake? Firstly php artisan make:migration add_votes_to_users_table --table=users

public function up()
{
    Schema::table('users', function (Blueprint $table) {
         $table->integer('votes');
    });
}

/**
 * Reverse the migrations.
 *
 * @return void
 */
public function down()
{
    Schema::table('users', function (Blueprint $table) {
        $table->dropColumn('votes');
    });
}
php artisan migrate

enter image description here

Error from cmd- In Connection.php line 647:

SQLSTATE[42S01] And In Connection.php line 449:

SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'users' already exists

  • 写回答

4条回答 默认 最新

  • douzhuang1900 2018-11-13 08:36
    关注

    I am suspecting that the reason you are getting this errors can come from 2 sides.

    1) you created users table yourself without run any migration

    2) a migration was interrupted.

    If the above does not work try:

    php artisan migrate:reset
    

    to rollback all your changes or if you want to move back 1 step at a time you can try:

    php artisan migrate:rollback --step=1
    

    Last if you are sure you can start over and you are ok with that you can run:

    php artisan migrate:fresh
    

    This will drop all the tables (check the database just to be sure as well and drop yourself any remaining even though i don't think anything will be left, never happened to me) and then run

    php artisan migrate 
    

    all over again

    评论

报告相同问题?

悬赏问题

  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 shape_predictor_68_face_landmarks.dat
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料