I'm learning laravel, and I'm stuck on a simple process. I want the tables to be generated as UTF-8 but varchar and text fields are like latin-1.
Schema section in guide did not help at all. I found this GitHub entry but it does not work neither (throws me errors).
I have a schema like this:
<?php
class Create_Authors_Table {
/**
* Make changes to the database.
*
* @return void
*/
public function up()
{
Schema::create('authors',function($table){
//$table->charset('utf8'); //does not work
//$table->collate('utf8_general_ci'); //does not work
$table->increments('id');
$table->string('name')->charset('utf8'); //adding ->collate('utf8_general_ci') does not work
$table->text('bio')->charset('utf8');
$table->timestamps();
});
}
/**
* Revert the changes to the database.
*
* @return void
*/
public function down()
{
Schema::drop('authors');
}
}
This is the SQL output:
CREATE TABLE IF NOT EXISTS `authors` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(200) NOT NULL,
`bio` text NOT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
But this is what I need:
CREATE TABLE IF NOT EXISTS `authors` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(200) NOT NULL,
`bio` text NOT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
I even put collation
key to my application/config/database.php
'mysql' => array(
'driver' => 'mysql',
'host' => '',
'database' => '',
'username' => '',
'password' => '',
'charset' => 'utf8',
'collation'=> 'utf8_unicode_ci', //this line was not there out of the box, googling provided me this
'prefix' => '',
),
What am I missing, how do I fix this?
Thanks,