kitloong / laravel-migrations-generator

Laravel Migrations Generator: Automatically generate your migrations from an existing database schema.
MIT License
2.44k stars 270 forks source link

Unknown database type data requested - sqlite DB #132

Closed bldrvnlw closed 1 year ago

bldrvnlw commented 1 year ago

Describe the bug The following error appears and no migrations are created:

Setting up Tables and Index Migrations

In AbstractPlatform.php line 454:

  Unknown database type data requested, Doctrine\DBAL\Platforms\SqlitePlatform may not support it.

To Reproduce Steps to reproduce the behavior: Install the package on a laravel 5.8 installation with sqlite as database.

  1. Create table celltype
    PRAGMA foreign_keys=OFF;
    BEGIN TRANSACTION;
    CREATE TABLE celltype (jobID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
    title TEXT,
    email TEXT NOT NULL,
    snp2gene INTEGER,
    snp2geneTitle TEXT,
    status TEXT,
    created_at DATA NOT NULL);
  2. Run php artisan migrate:generate celltype
  3. See error

Expected behavior A create migration file would be produced

Screenshots None

Details (please complete the following information):

Additional context NA

kitloong commented 1 year ago

@bldrvnlw Thanks for reporting.

Could you please check your doctrine/dbal version?

I too have the same issue if I install doctrine/dbal v3, if this is the case, you should use doctrine/dbal v2 given you are using a really old version of Laravel. See https://github.com/laravel/framework/blob/5.8/composer.json#L121

Here are my steps to generate migration files successfully.

  1. php74 /opt/homebrew/bin/composer create-project --prefer-dist laravel/laravel blog "5.8.*"
  2. php74 /opt/homebrew/bin/composer require doctrine/dbal:^2.0
  3. php74 /opt/homebrew/bin/composer require --dev "kitloong/laravel-migrations-generator"
  4. php74 artisan migrate:generate
bldrvnlw commented 1 year ago

Thanks for the answer! Indeed it's an old version we're in the process of upgrading to a newer Laravel - the generation of the migrations is part of the whole cleanup.

The dbal version on this system is 2.13.9. I'm still getting that error - perhaps another package is the cause. I could post the composer.lock file if that helps

kitloong commented 1 year ago

@bldrvnlw Please post your composer.json to reproduce the issue.

bldrvnlw commented 1 year ago

Here it is:

{
    "name": "laravel/laravel",
    "config": {
        "preferred-install": "dist",
        "platform": {
            "php": "7.3"
        }
    },
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": ">=5.6.4 <7.4",
        "laravel/framework": "5.8.*",
        "laravelcollective/html": "5.8.*",
        "guzzlehttp/guzzle": "^6.2",
        "predis/predis": "^1.1",
        "rairlie/laravel-locking-session": "^1.1",
        "laracasts/utilities": "^3.2",
        "laravel/tinker": "^1.0",
        "doctrine/dbal": "2.*"
    },
    "require-dev": {
        "mockery/mockery": "0.9.*",
        "phpunit/phpunit": "7.*",
        "symfony/css-selector": "3.1.*",
        "symfony/dom-crawler": "3.1.*",
        "fakerphp/faker": "^1.19",
        "kitloong/laravel-migrations-generator": "^6.4"
    },
    "autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
            "fuma\\": "app/"
        },
        "files": [
            "app/Helper/helpers.php"
        ]
    },
    "autoload-dev": {
        "classmap": [
            "tests/TestCase.php"
        ]
    },
    "scripts": {
        "post-root-package-install": [
            "php -r \"copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "php artisan key:generate"
        ]
    }
}
kitloong commented 1 year ago

Hi @bldrvnlw , thank you for the details.

I have replaced it with your composer.json, I am able to generate migrations successfully.

I amended the following to make it work in my local:

"psr-4": {
    "App\\": "app/"
},

Remove

"files": [
    "app/Helper/helpers.php"
]

You may have other conflicts in your source code lead to this error. I am closing this issue now since this is not the migration generator error.

bldrvnlw commented 1 year ago

Thanks for your help!