Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
strobil opened this issue Sep 6, 2017 · 4 comments
Closed

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

strobil opened this issue Sep 6, 2017 · 4 comments

Comments

@strobil
Copy link

strobil commented Sep 6, 2017

  • 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

@ccrims0n
Copy link
Contributor

ccrims0n commented Sep 6, 2017

@strobil Laravel treats float as double in the blueprint.

@steveheinsch
Copy link

#9103

@strobil
Copy link
Author

strobil commented Sep 7, 2017

@ccrims0n But if i want double, i will use $table->double, isn't it?

@themsaid
Copy link
Member

themsaid commented Sep 7, 2017

check #9103

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants