如何使用laravel 5.8正确配置sqlite数据库连接

如何使用laravel 5.8正确配置sqlite数据库连接,laravel,sqlite,Laravel,Sqlite,问题是我无法迁移到sqlite数据库,并且已经尝试搜索了几个相关的问题,但没有成功。但是,当创建新的laravel应用程序并执行与我在以下步骤中所述相同的配置时,不会遇到任何问题,并且将成功迁移数据库架构 我试过: 以下是我在.env中的配置: DB_CONNECTION=sqlite DB_PORT=3306 DB_DATABASE=homestead DB_USERNAME=root 下面是我的database.php配置: 'connections' => [ 'sqli

问题是我无法迁移到sqlite数据库,并且已经尝试搜索了几个相关的问题,但没有成功。但是,当创建新的laravel应用程序并执行与我在以下步骤中所述相同的配置时,不会遇到任何问题,并且将成功迁移数据库架构

我试过:

以下是我在.env中的配置:

DB_CONNECTION=sqlite
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=root
下面是我的database.php配置:

'connections' => [

    'sqlite' => [
        'driver' => 'sqlite',
        'url' => env('DATABASE_URL'),
        'database' => database_path('database.sqlite'),
        'prefix' => '',
       'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
    ],

以下是产品迁移:

public function up()
{
    Schema::create('products', function (Blueprint $table) {
        $table->bigIncrements('id');
        $table->integer('user_id')->unsigned();
        $table->integer('category_id')->unsigned()->nullable();
        $table->integer('supplier_id')->unsigned()->nullable();
        $table->integer('company_id')->unsigned()->nullable();
        $table->string('barcode')->unique()->nullable();
        $table->string('name')->nullable();
        $table->string('unit')->nullable();
        $table->text('description')->nullable();
        $table->string('avatar')->nullable();
        $table->double('purchase_price')->default(0.0);
        $table->double('selling_price')->default(0.0);
        $table->double('supply_price')->default(0.0);
        $table->double('taxation')->default(0);
        $table->tinyInteger('stock_limit')->default(1);
        $table->integer('quantity')->default(0); // This will be updated when adding and removing quantity of the product and should matched in inventory 
        $table->timestamp('expiration')->nullable();
        $table->string('type')->default('stock'); // consignment or stock
        $table->string('attr')->nullable();
        $table->timestamps();
    });
}
我使用以下命令创建了空的database.sqlite:

touch database\database.sqlite
以下是尝试运行php artisan migrate时的输出:

SQLSTATE[HY000]: General error: 1 no such table: products (SQL: select count(*) as aggregate from "products" where quantity <= stock_limit)
In PDOConnection.php line 63:
SQLSTATE[HY000]: General error: 1 no such table: products 
In PDOConnection.php line 61:
  SQLSTATE[HY000]: General error: 1 no such table: products 

SQLSTATE[HY000]:一般错误:1没有这样的表:products(SQL:select count(*)作为“products”中的聚合,其中数量显示您的迁移。这样的查询
select count(*)作为“products”中的聚合在imageI中附加的quantity migration的意思是,我们需要知道您的迁移文件中有什么。@Tarasovych添加了products表迁移。您说您正在尝试执行
php artisan migrate
。此时已经应用了哪些迁移?关于
php artisan migrate:fresh
?相同的错误?您有数据库吗可能导致错误的事件侦听器?请显示您的迁移。这样的查询
选择count(*)作为“products”中的聚合在imageI中附加的quantity migration的意思是,我们需要知道您的迁移文件中有什么。@Tarasovych添加了products表迁移。您说您正在尝试执行
php artisan migrate
。此时已经应用了哪些迁移?关于
php artisan migrate:fresh
?相同的错误?您有数据库吗事件侦听器,这可能导致错误?
SQLSTATE[HY000]: General error: 1 no such table: products (SQL: select count(*) as aggregate from "products" where quantity <= stock_limit)
In PDOConnection.php line 63:
SQLSTATE[HY000]: General error: 1 no such table: products 
In PDOConnection.php line 61:
  SQLSTATE[HY000]: General error: 1 no such table: products