Skip to content

column was created with "double" type instead of "float" #21032

Closed
@strobil

Description

@strobil
  • Laravel Version: 5.4.33
  • PHP Version:7.1.7
  • Database Driver & Version: 5.0.12-dev

Description:

I have described table as below:

    Schema::create('movies', function (Blueprint $table) {
        $table->increments('id');
        $table->string('title');
        $table->string('title_en')->nullable();

        $table->integer('year')->default(0);
        $table->integer('duration')->default(0);

        $table->text('description')->nullable();

        $table->float('rating_imdb', 2, 1)->nullable();
        $table->float('rating_kinopoisk',2, 1)->nullable();

        $table->integer('megogo_id')->unsigned()->unique()->nullable();
        $table->integer('kinopoisk_id')->unsigned()->nullable();

        $table->unique(['megogo_id', 'kinopoisk_id']);
    });

Pay attention for two columns of type float:
$table->float('rating_imdb', 2, 1)->nullable();
$table->float('rating_kinopoisk',2, 1)->nullable();

But in database laravel creates columns with type of double

CREATE TABLE `movies` (
	`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
	`title` VARCHAR(191) NOT NULL COLLATE 'utf8mb4_unicode_ci',
	`title_en` VARCHAR(191) NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_ci',
	`year` INT(11) NOT NULL DEFAULT '0',
	`duration` INT(11) NOT NULL DEFAULT '0',
	`description` TEXT NULL COLLATE 'utf8mb4_unicode_ci',
	`rating_imdb` DOUBLE(2,1) NULL DEFAULT NULL,
	`rating_kinopoisk` DOUBLE(2,1) NULL DEFAULT NULL,
	`megogo_id` INT(10) UNSIGNED NULL DEFAULT NULL,
	`kinopoisk_id` INT(10) UNSIGNED NULL DEFAULT NULL,
	PRIMARY KEY (`id`),
	UNIQUE INDEX `movies_megogo_id_kinopoisk_id_unique` (`megogo_id`, `kinopoisk_id`),
	UNIQUE INDEX `movies_megogo_id_unique` (`megogo_id`)
)
COLLATE='utf8mb4_unicode_ci'
ENGINE=InnoDB
;


Steps To Reproduce:

php artisan migrate

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions