Search
 
SCRIPT & CODE EXAMPLE
 

PHP

migration types in laravel

/*
|========================================================
| Common Migration Types in (for mySql) Laravel
|========================================================
*/
$table->bigIncrements('id'); 	Incrementing ID using a "big integer" equivalent.
$table->bigInteger('votes'); 	BIGINT equivalent to the table
$table->binary('data'); 	BLOB equivalent to the table
$table->boolean('confirmed'); 	BOOLEAN equivalent to the table
$table->char('name', 4); 	CHAR equivalent with a length
$table->date('created_at'); 	DATE equivalent to the table
$table->dateTime('created_at'); 	DATETIME equivalent to the table
$table->decimal('amount', 5, 2); 	DECIMAL equivalent with a precision and scale
$table->double('column', 15, 8); 	DOUBLE equivalent with precision, 15 digits in total and 8 after the decimal point
$table->enum('choices', array('foo', 'bar')); 	ENUM equivalent to the table
$table->float('amount'); 	FLOAT equivalent to the table
$table->increments('id'); 	Incrementing ID to the table (primary key).
$table->integer('votes'); 	INTEGER equivalent to the table
$table->longText('description'); 	LONGTEXT equivalent to the table
$table->mediumInteger('numbers'); 	MEDIUMINT equivalent to the table
$table->mediumText('description'); 	MEDIUMTEXT equivalent to the table
$table->morphs('taggable'); 	Adds INTEGER taggable_id and STRING taggable_type
$table->nullableTimestamps(); 	Same as timestamps(), except allows NULLs
$table->smallInteger('votes'); 	SMALLINT equivalent to the table
$table->tinyInteger('numbers'); 	TINYINT equivalent to the table
$table->softDeletes(); 	Adds deleted_at column for soft deletes
$table->string('email'); 	VARCHAR equivalent column
$table->string('name', 100); 	VARCHAR equivalent with a length
$table->text('description'); 	TEXT equivalent to the table
$table->time('sunrise'); 	TIME equivalent to the table
$table->timestamp('added_on'); 	TIMESTAMP equivalent to the table
$table->timestamps(); 	Adds created_at and updated_at columns
$table->rememberToken(); 	Adds remember_token as VARCHAR(100) NULL
->nullable() 	Designate that the column allows NULL values
->default($value) 	Declare a default value for a column
->unsigned() 	Set INTEGER to UNSIGNED
Comment

laravel migration integer

$table->integer('votes');
Comment

laravel amount migration

$table->decimal('amount', $precision = 8, $scale = 2);
// or
$table->double('amount', 8, 2);
Comment

laravel migration integer

$table->bigInteger('votes');
Comment

laravel migration int length

For Laravel & Mysql

String types
CHAR - 1 to 191 (trailing spaces removed)
STRING - 1 to 16,300 (user defined)
TEXT - 1 to 65,535
MEDIUMTEXT - 1 to 16,777,215
LONGTEXT - 1 to 4,294,967,295

Integer types
TINYINT - 0 to 255 (unsigned) | -128 to 127 (signed)
SMALLINT - 0 to 65,535 (unsigned) | -32,768 to 32,767 (signed)
MEDIUMINT - 0 to 16,777,215 (unsigned) | -8,388,608 to 8,388,607 (signed)
INT - 0 to 4,294,967,295 (unsigned) | -2,147,483,648 to 2,147,483,647 (signed)
BIGINT - 0 to 18,446,744,073,709,551,615 (unsigned) | -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 (signed)

Floating types
Structure: `([max decimal places], [max precision])`
FLOAT - ([0-7], [0-23])
DOUBLE - ([0-14], [24-53])
DECIMAL - ([0-65], [0-30])
Comment

PREVIOUS NEXT
Code Example
Php :: difference between use and require in php 
Php :: laravel pagination layout issue 
Php :: laravel update all relations 
Php :: laravel resource set status code 
Php :: validate contact us page 2021 php coding 
Php :: check date PHP 
Php :: woocommerce change add to cart button text 
Php :: foreign key in php 
Php :: how to data save usigng request all laravel 
Php :: Laravel: Set timestamp column to current timestamp 
Php :: insert multiple rows laravel 
Php :: php print datetime 
Php :: laravel APP_ENV config 
Php :: firebase php 
Php :: php sprintf 
Php :: how to disable opcache 
Php :: html to pdf in php 
Php :: php array insert before key 
Php :: sanitize file name 
Php :: select option in laravel 
Php :: php quotations within quotations 
Php :: laravel signed Route custom domain 
Php :: h:i:s explode in php by ":" 
Php :: wc create new category 
Php :: how to execute php function on button click 
Php :: get value mentthod get laravel 
Php :: drupal 9 guzzle client increase timeout 
Php :: disable display error 
Php :: session() in lumen 
Php :: custom timestamp column laravel 
ADD CONTENT
Topic
Content
Source link
Name
4+6 =