You are not logged in.

Important Note: This forum is being archived and will be completely locked down on the 7th of February. The new forum can be found at http://laravel.io.

Announcement

    Laravel 4 Advanced Architecture: Book Now On Sale

#1 2012-06-05 02:01:09

rcravens
Artisan
Registered: 2011-09-20
Posts: 11

Schema Builder - MySQL InnoDB Engine

Is there a way to specify which MySQL engine to use when creating a table using the schema builder?

Offline

#2 2012-06-05 02:18:16

rcravens
Artisan
Registered: 2011-09-20
Posts: 11

Re: Schema Builder - MySQL InnoDB Engine

So I found this in ../laravel/database/schema/grammers/mysql.php

	public function create(Table $table, Fluent $command)
	{
		$columns = implode(', ', $this->columns($table));

		// First we will generate the base table creation statement. Other than auto
		// incrementing keys, no indexes will be created during the first creation
		// of the table as they're added in separate commands.
		$sql = 'CREATE TABLE '.$this->wrap($table).' ('.$columns.')';

		if ( ! is_null($table->engine))
		{
			$sql .= ' ENGINE = '.$table->engine;
		}

		return $sql;
	}

So it looks like in my schema builder code I should be able to set the engine. I tried the following:

		Schema::create('users', function( $table ) {

			$table->engine = "InnoDB";
			$table->increments( 'id' );
			$table->string( 	'email' )->unique();
			$table->string( 	'password' );
			$table->string(		'first_name');
			$table->string(		'last_name');
			$table->boolean( 	'confirmed' );
			$table->timestamps();
		} ); 
	}

and it worked. Let me know if that is not how to do it. Otherwise, hope this helps others.

Bob

Last edited by sineld (2012-06-08 15:52:55)

Offline

Board footer

Powered by FluxBB

');