【发布时间】:2017-05-07 09:43:30
【问题描述】:
我使用命令 php artisan migrate:make 创建了一些迁移,然后用一些字段填充并保存它。这是全新安装,也是第一次运行迁移。
我运行了 php artisan migrate 并且迁移成功完成。然而,虽然迁移表 IS 创建了,并且它有一行包含文件名和批次 1,但没有表。
这是我的迁移文件代码:
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateFuelLocationsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
//
Schema::create('fuel_locations', function (Blueprint $table) {
$table->increments('id');
$table->string('uid');
$table->string('name');
$table->string('fuel_type');
$table->string('email');
$table->string('street');
$table->string('city');
$table->string('state');
$table->string('zip');
$table->string('phone');
$table->string('service_hours');
$table->string('payment_methods');
$table->string('payment_method_other');
$table->decimal('latitude', 3, 7);
$table->decimal('longitude', 3, 7);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
Schema::dropIfExists('fuel_locations');
}
}
还有几行来自我的 config/database.php:
'mysql' => [
'driver' => 'mysql',
'database' => 'mydb',
'host' => 'localhost',
'username' => 'root',
'password' => '',
'charset' => env('DB_CHARSET', 'utf8'),
'collation' => env('DB_COLLATION', 'utf8_unicode_ci'),
'prefix' => env('DB_PREFIX', ''),
'timezone' => env('DB_TIMEZONE', '+00:00'),
'strict' => env('DB_STRICT_MODE', false),
],
我确实尝试将主机更改为 127.0.0.1,但无法连接。我怎样才能修复它,以便它确实像它应该的那样创建表。
【问题讨论】:
-
您用来检查数据库的任何工具是否有可能没有以某种方式刷新并且表实际上存在?尝试运行 sql
show tables;并查看它是否显示已创建的表。如果迁移表报告它是实际创建的,它应该在那里。 -
我希望是这样,但我使用的是直接命令行 mysql,根本没有缓存。
标签: php laravel laravel-5.3 artisan-migrate