Closed CaraesNaur closed 8 months ago
Hi @CaraesNaur , thank you for your details.
I repeat your steps in a new Laravel project, and here is my generated migration:
Schema::create('file_visuals', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('organization_id')->index('IDX_file_visuals_organization_id');
$table->unsignedBigInteger('parent_company_id')->index('IDX_file_visuals_parent_company_id');
$table->unsignedBigInteger('brand_owner_id')->index('IDX_file_visuals_brand_owner_id');
$table->unsignedBigInteger('brand_id')->index('IDX_file_visuals_brand_id');
$table->unsignedBigInteger('subbrand_id')->nullable()->index('IDX_file_visuals_subbrand_id');
$table->unsignedBigInteger('created_by')->index('IDX_file_visuals_created_by');
$table->unsignedBigInteger('owned_by')->nullable()->index('IDX_file_visuals_owned_by');
$table->unsignedBigInteger('updated_by')->nullable()->index('IDX_file_visuals_updated_by');
$table->unsignedBigInteger('deleted_by')->nullable()->index('IDX_file_visuals_deleted_by');
$table->unsignedBigInteger('file_id')->index('IDX_file_visuals_file_id');
$table->unsignedBigInteger('custom_orientation_id')->nullable()->index('IDX_file_visuals_custom_orientation_id');
$table->unsignedSmallInteger('frame_number')->default(1);
$table->unsignedSmallInteger('frames_count')->default(1);
$table->unsignedSmallInteger('total_planes')->default(1);
$table->dateTime('created_at');
$table->dateTime('updated_at')->nullable();
$table->dateTime('deleted_at')->nullable();
$table->decimal('dimension_x', 12, 6)->default(0);
$table->decimal('dimension_y', 12, 6)->default(0);
$table->unsignedDecimal('play_duration', 8, 3)->nullable()->default(0);
$table->decimal('plunge_angle', 12, 6)->default(0);
});
Could you check your composer.json
there is a different migration generator installed?
If you don't mind you could post your composer.json
here for checking purposes.
The only other generator present is krlove/eloquent-model-generator. I use both via scripts, as I have ~200 models/tables to deal with.
$ grep -Pi '(migrat|generat)' composer.*
composer.json: "kitloong/laravel-migrations-generator": "^6.6",
composer.json: "krlove/eloquent-model-generator": "^2.0@dev",
composer.json: "@php artisan key:generate --ansi"
composer.lock: "This file is @generated automatically"
composer.lock: "ext-bcmath": "Needed for generation of some types of barcodes",
composer.lock: "description": "PHP library generating PDF files from UTF-8 encoded HTML",
composer.lock: "description": "🛠 Nette Utils: lightweight utilities for string & array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.",
composer.lock: "description": "Generate a new Laravel database seed file based on data from the existing database table.",
composer.lock: "generators",
composer.lock: "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes."
composer.lock: "ext-uuid": "Enables the use of PeclUuidTimeGenerator and PeclUuidRandomGenerator.",
composer.lock: "description": "A PHP library for generating and working with universally unique identifiers (UUIDs).",
composer.lock: "description": "Provides an object-oriented API to generate and represent UIDs",
composer.lock: "ext-dom": "Required by Faker\\Provider\\HtmlLorem for generating random HTML.",
composer.lock: "ext-iconv": "Required by Faker\\Provider\\ru_RU\\Text::realText() for generating real Russian text.",
composer.lock: "description": "Faker is a PHP library that generates fake data for you.",
composer.lock: "name": "kitloong/laravel-migrations-generator",
composer.lock: "url": "https://github.com/kitloong/laravel-migrations-generator.git",
composer.lock: "url": "https://api.github.com/repos/kitloong/laravel-migrations-generator/zipball/116f50fab918b7f1363a40ebd954ce250f6aedcd",
composer.lock: "KitLoong\\MigrationsGenerator\\MigrationsGeneratorServiceProvider"
composer.lock: "KitLoong\\MigrationsGenerator\\": "src"
composer.lock: "description": "Generates Laravel Migrations from an existing database",
composer.lock: "generator",
composer.lock: "migration",
composer.lock: "migrations"
composer.lock: "issues": "https://github.com/kitloong/laravel-migrations-generator/issues",
composer.lock: "source": "https://github.com/kitloong/laravel-migrations-generator/tree/v6.10.0"
composer.lock: "name": "krlove/code-generator",
composer.lock: "url": "https://github.com/krlove/code-generator.git",
composer.lock: "url": "https://api.github.com/repos/krlove/code-generator/zipball/1ac521f5ef79a376282e3315ba6a13a83c63fb9a",
composer.lock: "Krlove\\CodeGenerator\\": "src/"
composer.lock: "description": "Code Generator",
composer.lock: "issues": "https://github.com/krlove/code-generator/issues",
composer.lock: "source": "https://github.com/krlove/code-generator/tree/1.0.1"
composer.lock: "name": "krlove/eloquent-model-generator",
composer.lock: "url": "https://github.com/krlove/eloquent-model-generator.git",
composer.lock: "url": "https://api.github.com/repos/krlove/eloquent-model-generator/zipball/f4383da4a6b0dd643986330e86fd39d631e569be",
composer.lock: "krlove/code-generator": "^1.0",
composer.lock: "Krlove\\EloquentModelGenerator\\Provider\\GeneratorServiceProvider"
composer.lock: "Krlove\\EloquentModelGenerator\\": "src/"
composer.lock: "description": "Eloquent Model Generator",
composer.lock: "issues": "https://github.com/krlove/eloquent-model-generator/issues",
composer.lock: "source": "https://github.com/krlove/eloquent-model-generator/tree/2.0.1"
composer.lock: "ext-soap": "To be able to generate mocks based on WSDL files",
composer.lock: "krlove/eloquent-model-generator": 20
Full composer.json
:
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"php": "^7.3|^8.0",
"barryvdh/laravel-debugbar": "*",
"doctrine/dbal": "^3.6",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.0.1",
"laravel/framework": "^9.0",
"laravel/sanctum": "^2.11",
"laravel/telescope": "^4.15",
"laravel/tinker": "^2.5",
"laravel/ui": "*",
"michaelachrisco/readonly": "^0.50.0",
"orangehill/iseed": "^3.0",
"stancl/tenancy": "^3.7",
"venturedrake/laravel-crm": "^0.18.1",
"wildside/userstamps": "^2.3"
},
"require-dev": {
"fakerphp/faker": "^1.9.1",
"kitloong/laravel-migrations-generator": "^6.6",
"krlove/eloquent-model-generator": "^2.0@dev",
"laravel/sail": "^1.0.1",
"mockery/mockery": "^1.4.4",
"nunomaduro/collision": "^6.1",
"phpunit/phpunit": "^9.5.10",
"spatie/laravel-ignition": "^1.0"
},
"autoload": {
"psr-4": {
"App\\": "app/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
},
"files": [
"app/Helpers/EmbedAssets.php"
]
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"scripts": {
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi"
],
"post-update-cmd": [
"@php artisan vendor:publish --tag=laravel-assets --ansi --force"
],
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate --ansi"
]
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"minimum-stability": "dev",
"prefer-stable": true
}
Hi @CaraesNaur , thank you.
I can confirm the error is caused by a conflict with krlove/eloquent-model-generator
DB types registration.
The quick fix for now is to temporarily remove the library, generate migrations, and re-install the library.
Meanwhile, I will look for a way to fix this problem.
The correct migrations were made with krlove/eloquent-model-generator
1.3.8.
This is happening with 2.0.1.
I rolled back krlove/eloquent-model-generator
to 1.3.8, the migrations are back to what they should be.
This is a known issue in https://github.com/krlove/eloquent-model-generator/issues/103, the types are overwritten even though the command is not executed.
Closing this as it is not related to the migrations generator.
Describe the bug Regression: some column types in migrations do not match those of the basis database table.
bigint
becomes integersmallint
becomes integerdatetime
becomes stringdecimal
becomes floatTo Reproduce Steps to reproduce the behavior:
php artisan migrate:generate -n -vvv --tables=file_visuals
The migration run today contains:
Expected behavior
This is the relevant snip from an older version of the same migration:
Screenshots If applicable, add screenshots to help explain your problem.
Old (expected) on the left, new (wrong) on the right.
(Making
owned_by
nullable andplay_duration
unsigned are deliberate, expected differences.)Details (please complete the following information):
Additional context Add any other context about the problem here.