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 update table column type

Schema::table('users', function ($table) {
    $table->string('name', 50)->change();
});
We could also modify a column to be nullable:

Schema::table('users', function ($table) {
    $table->string('name', 50)->nullable()->change();
});
Comment

laravel migration column types

# nullableTimestamps()
## alias of the timestamps method
	$table->nullableTimestamps(0);

# nullableMorphs()
## The method is similar to the morphs method 
## however, the columns that are created will be "nullable":
	$table->nullableMorphs('taggable');

# nullableUuidMorphs()
## The method is similar to the uuidMorphs method
## however, the columns that are created will be "nullable":
    $table->nullableUuidMorphs('taggable');

# point()
## creates a POINT equivalent column:
    $table->point('position');

# polygon()
## creates a POLYGON equivalent column:
    $table->polygon('position');

# rememberToken()
## creates a nullable, VARCHAR(100) equivalent column 
## that is intended to store the current "remember me" authentication token:
    $table->rememberToken();

# set()
## creates a SET equivalent column with the given list of valid values:
    $table->set('flavors', ['strawberry', 'vanilla']);

# smallIncrements()
## creates an auto-incrementing UNSIGNED SMALLINT 
## equivalent column as a primary key:
    $table->smallIncrements('id');

# smallInteger()
## creates a SMALLINT equivalent column:
    $table->smallInteger('votes');

# softDeletesTz()
## adds a nullable deleted_at TIMESTAMP (with timezone) equivalent column 
## with an optional precision (total digits). 
## This column is intended to store the deleted_at timestamp 
## needed for Eloquent's "soft delete" functionality:
    $table->softDeletesTz($column = 'deleted_at', $precision = 0);

# softDeletes()
## adds a nullable deleted_at TIMESTAMP 
## equivalent column with an optional precision (total digits). 
## This column is intended to store the deleted_at timestamp 
## needed for Eloquent's "soft delete" functionality:
    $table->softDeletes($column = 'deleted_at', $precision = 0);

# string()
## creates a VARCHAR equivalent column of the given length:
    $table->string('name', 100);

# text()
## creates a TEXT equivalent column:
    $table->text('description');

# timeTz()
## creates a TIME (with timezone) 
## equivalent column with an optional precision (total digits):
    $table->timeTz('sunrise', $precision = 0);

# time()
## creates a TIME equivalent column with an optional precision (total digits):
    $table->time('sunrise', $precision = 0);

# timestampTz()
## creates a TIMESTAMP (with timezone) 
## equivalent column with an optional precision (total digits):
    $table->timestampTz('added_at', $precision = 0);

# timestamp()
## creates a TIMESTAMP equivalent column 
## with an optional precision (total digits):
    $table->timestamp('added_at', $precision = 0);

# timestampsTz()
## creates created_at and updated_at TIMESTAMP 
## (with timezone) equivalent columns with an optional precision (total digits):
    $table->timestampsTz($precision = 0);

# timestamps()
## creates created_at and updated_at TIMESTAMP 
## equivalent columns with an optional precision (total digits):
    $table->timestamps($precision = 0);

# tinyIncrements()
## creates an auto-incrementing UNSIGNED TINYINT 
## equivalent column as a primary key:
    $table->tinyIncrements('id');

# tinyInteger()
## creates a TINYINT equivalent column:
    $table->tinyInteger('votes');

# tinyText()
## creates a TINYTEXT equivalent column:
    $table->tinyText('notes');

# unsignedBigInteger()
## creates an UNSIGNED BIGINT equivalent column:
    $table->unsignedBigInteger('votes');

# unsignedDecimal()
## creates an UNSIGNED DECIMAL equivalent column with 
## an optional precision (total digits) 
## and scale (decimal digits):
    $table->unsignedDecimal('amount', $precision = 8, $scale = 2);

# unsignedInteger()
## creates an UNSIGNED INTEGER equivalent column:
    $table->unsignedInteger('votes');

# unsignedMediumInteger()
## creates an UNSIGNED MEDIUMINT equivalent column:
    $table->unsignedMediumInteger('votes');

# unsignedSmallInteger()
## creates an UNSIGNED SMALLINT equivalent column:
    $table->unsignedSmallInteger('votes');

# unsignedTinyInteger()
## creates an UNSIGNED TINYINT equivalent column:
    $table->unsignedTinyInteger('votes');

# uuidMorphs()
## The uuidMorphs method is a convenience method that adds a 
## {column}_id CHAR(36) equivalent column and a {column}_type 
## VARCHAR equivalent column.
## This method is intended to be used when defining the columns necessary 
## for a polymorphic Eloquent relationship that use UUID identifiers. 
## In the following example, `taggable_id` and `taggable_type` columns would be created:
    $table->uuidMorphs('taggable');

# uuid()
## creates a UUID equivalent column:
    $table->uuid('id');

# year()
## creates a YEAR equivalent column:
    $table->year('birth_year');
Comment

number data type in laravel migration

laravel migration types
Comment

data types of laravel migrations

select count(*) as aggregate from `categories` where `title` = jncisudrf
Comment

laravel Database migrations column types

$table->geometry('positions');
$table->ipAddress('visitor');
$table->macAddress('device');
$table->point('position');
$table->uuid('id');
Comment

PREVIOUS NEXT
Code Example
Php :: get_the_terms 
Php :: codeigniter4 route optional parameter 
Php :: drupal 7 db_query example 
Php :: composer install phpWord 
Php :: laravel manually authenticate user 
Php :: epoch conversion php 
Php :: preg_split 
Php :: laravel where() method 
Php :: laravel log package, laravel log, save laravel log 
Php :: which programming languae does php resemble to? 
Php :: laravel collection when 
Php :: laravel check if primary key exists 
Php :: install execute array in php 
Php :: laravel model isdirty 
Php :: disadvantages of php 
Php :: PHP temporary files 
Php :: square php 
Php :: check php-fpm version ubuntu 
Php :: install multiple php versions windows xampp 
Php :: php strict mopde 
Php :: how to fetch all user data form user in wp 
Php :: PHP strtok — Tokenize string 
Php :: laravel call controller method from another controller 
Php :: Toaster switch Statement 
Php :: install spatie for role and permissions 
Php :: windows list registered applications 
Php :: laravel validation if another record is not deleted / not null 
Php :: get custom field post wordpress dev 
Php :: custom validation in laravel 
Php :: laravel allow all fillable 
ADD CONTENT
Topic
Content
Source link
Name
5+8 =