Column Modifiers
Last updated
Was this helpful?
Was this helpful?
schema.create( "users", function( table ) {
table.boolean( "is_active" ).default( 1 );
table.timestamp( "created_date" ).default( "NOW()" );
tablVIRTUAL NOT NULLe.string( "country" ).default( "'USA'" );
} );CREATE TABLE `users` (
`is_active` TINYINT(1) DEFAULT 1,
`created_date` TIMESTAMP DEFAULT NOW(),
`country` VARCHAR(255) DEFAULT 'USA'
)schema.create( "users", function( table ) {
table.timestamp( "last_logged_in" ).nullable()
} );CREATE TABLE `users` (
`last_logged_in` TIMESTAMP
)schema.create( "users", function( table ) {
table.uuid( "id" ).primaryKey();
} );CREATE TABLE `users` (
`id` CHAR(35) NOT NULL,
CONSTAINT `pk_users_id` PRIMARY KEY (`id`)
)schema.create( "users", function( table ) {
table.unsignedInteger( "country_id" ).references( "id" ).onTable( "countries" ).onDelete( "cascade" );
} );CREATE TABLE `users` (
`country_id` INTEGER UNSIGNED NOT NULL,
CONSTRAINT `fk_users_country_id` FOREIGN KEY (`country_id`) REFERENCES `countries` (`id`) ON UPDATE NO ACTION ON DELETE CASCADE
)schema.create( "users", function( table ) {
table.integer( age" ).unsigned();
} );CREATE TABLE `users` (
`age` INTEGER UNSIGNED NOT NULL
)schema.create( "email", function( table ) {
table.string( email" ).unique();
} );CREATE TABLE `users` (
`email` VARCHAR(255) NOT NULL UNIQUE
)schema.create( "posts", function( table ) {
table.timestamp( "posted_date" ).withCurrent();
} );CREATE TABLE "posts" (
"posted_date" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
)schema.create( "products", function( table ) {
table.integer( "price" );
table.integer( "tax" ).storedAs( "price * 0.0675" );
} );CREATE TABLE `products` (
`price` INTEGER NOT NULL,
`tax` INTEGER GENERATED ALWAYS AS (price * 0.0675) STORED NOT NULL
)CREATE TABLE [products] (
[price] INTEGER NOT NULL,
[tax] AS (price * 0.0675) PERSISTED
)CREATE TABLE "products" (
"price" INTEGER NOT NULL,
"tax" INTEGER NOT NULL GENERATED ALWAYS AS (price * 0.0675) STORED
)CREATE TABLE "PRODUCTS" (
"PRICE" NUMBER(10, 0) NOT NULL,
"TAX" NUMBER(10, 0) GENERATED ALWAYS AS (price * 0.0675)
)schema.create( "products", function( table ) {
table.integer( "price" );
table.integer( "tax" ).virtualAs( "price * 0.0675" );
} );CREATE TABLE `products` (
`price` INTEGER NOT NULL,
`tax` INTEGER GENERATED ALWAYS AS (price * 0.0675) VIRTUAL NOT NULL
)CREATE TABLE [products] (
[price] INTEGER NOT NULL,
[tax] AS (price * 0.0675)
)CREATE TABLE "products" (
"price" INTEGER NOT NULL,
"tax" INTEGER GENERATED ALWAYS AS (price * 0.0675) STORED
)CREATE TABLE "PRODUCTS" (
"PRICE" NUMBER(10, 0) NOT NULL,
"TAX" NUMBER(10, 0) GENERATED ALWAYS AS (price * 0.0675) VIRTUAL
)