我不能在laravel 5中创建一个新表?

时间:2018-03-21 21:24:07

标签: laravel-5

你好我试图创建一个新表,但我不能尝试使用--path no response进行迁移



class CreateParkedTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('parked', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->string('Equipment');
            $table->string('link');
            $table->string('latitude');
            $table->string('longitude');
            $table->timestamps();
        });
    }




当我尝试php artisan migrate或php artisan migrate时:刷新我的表dosent create



C:\xampp\htdocs\FinalProject>php artisan make:migration create-parked-table --create=parked
Created Migration: 2018_03_21_210934_create-parked-table

C:\xampp\htdocs\FinalProject>php artisan migrate

   Illuminate\Database\QueryException  : SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'clients' already exists (SQL: create table `clients` (`id` int unsigned not null auto_increment primary key, `name` varchar(191) not null, `link` varchar(191) not null, `Equipment` varchar(191) not null, `latitude` varchar(191) not null, `longitude` varchar(191) not null, `created_at` timestamp null, `updated_at` timestamp null) default character set utf8mb4 collate utf8mb4_unicode_ci)

  at C:\xampp\htdocs\FinalProject\vendor\laravel\framework\src\Illuminate\Database\Connection.php: 664
    660|         // If an exception occurs when attempting to run a query, we'll format the error
    661|         // message to include the bindings with SQL, which will make this exception a
    662|         // lot more helpful to the developer instead of just the database's errors.
    663|         catch (Exception $e) {
  > 664|             throw new QueryException(
    665|                 $query, $this->prepareBindings($bindings), $e
    666|             );
    667|         }

     l═          ublic function         ki═          sDoctrineAvailable     ki═          ublic function  returnli═          etDoctrineColumn
kiC:\xampp\htdocs\FinalProject\vendor\laravel\framework\src\Illuminate\Database\Connection.php : 458

  2   PDOStatement::execute()
      C:\xampp\htdocs\FinalProject\vendor\laravel\framework\src\Illuminate\Database\Connection.php : 458

  Please use the argument -v to see more details.



 任何想法PLZ我需要创建另外几个表

1 个答案:

答案 0 :(得分:0)

Laravel通过几个步骤完成迁移。

df_test = pd.DataFrame({'Customer_ID' : ['ABC', 'XYZ'],
                    'Biscuits_Ord': [7,7],
                    'Biscuits_Del': [32, 10],
                    'Soda_Ord': [7,7],
                    'Soda_Del': [32, 10]})
df_test.index = df_test['Customer_ID']
del df_test['Customer_ID']

df_test.columns = pd.MultiIndex.from_tuples(df_test.columns.str.split('_').map(tuple).map(reversed).map(tuple))
df_new = df_test.stack()
df_new.index.set_names('Product', level=1, inplace=True)
df_new.reset_index(inplace=True)

在幕后,laravel会保留一个迁移表,其中会跟踪运行的文件以及发生的批处理。

您的表已创建,但是laravel没有提及它,因为该进程被中断/崩溃。

您可以通过转到数据库轻松解决此问题,并手动删除php artisan migrate 表,然后运行clients

如果您不想删除php artisan migrate again表,您还可以将clients迁移文件的名称复制到迁移表中,并选择现有最高的batchnumber,或1更高。