-
Notifications
You must be signed in to change notification settings - Fork 16
Enable MySQL Driver #168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable MySQL Driver #168
Conversation
Related #38 |
$res = $this->searchService->itemMatchCount($q); | ||
$pagination = new Paginator($results, $res[0]->count, $this->perPage, null, array('path' => '/search')); | ||
$count = $this->searchService->itemMatchCount($q); | ||
$pagination = new Paginator($results, $count, $this->perPage, null, array('path' => '/search')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -127,6 +127,7 @@ public function matchCount($str) | |||
WHERE | |||
fts.words MATCH :match | |||
__SQL__; | |||
return \DB::select(\DB::raw($query), array( 'match' => FtsUtils::createMatchWord($str))); | |||
$res = \DB::select(\DB::raw($query), array( 'match' => FtsUtils::createMatchWord($str))); | |||
return $res[0]->count; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
お手数ですがphpdocの@return
の方も修正していただけますか…!
$table->integer('tag_id')->unsigned(); | ||
$table->foreign('tag_id')->references('id')->on('tags'); | ||
$table->foreign('tag_id')->references('id')->on('tags')->onDelete('cascade'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
対応ダン!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
既存マイグレーションを修正してしまうと既にこのマイグレーションを実行済みの場合に変更を適用できなくなってしまうので、新しいマイグレーションファイルで modify columnしてもらいたいです...
参考
http://stackoverflow.com/questions/26820788/add-on-delete-cascade-to-existing-column-in-laravel
* | ||
* @param int $tag_id | ||
* @param string $words | ||
* @return stdClass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
array
にしましょ! そして申し訳ないんですが、 app/Repositories/Fluent/TagFtsRepository.php
の同じ箇所も array
に変えていただけると... 🙏
->references('id')->on('users') | ||
->onDelete('cascade')->onUpdate('cascade'); | ||
$table->text('token')->unique(); | ||
$table->string('token', 512)->unique(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mysql都合の変更なので、 if (env('DB_DRIVER') === 'mysql')
していただけると..
(unsignedをsqlite側に適用するなら ここと同じ理由 で別マイグレーションファイルにしたいです...。別ファイルが面倒だと思うのでmysql側だけunsignedでもいいかなと思います)
@@ -17,7 +17,7 @@ public function up() | |||
$table->integer('user_id') | |||
->references('id')->on('users') | |||
->onDelete('cascade')->onUpdate('cascade'); | |||
10000 $table->text('token')->unique(); | |||
$table->string('token', 512)->unique(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -15,7 +15,7 @@ public function up() | |||
Schema::create('users', function(Blueprint $table) | |||
{ | |||
$table->increments('id'); | |||
$table->string('username')->after('id')->unique(); | |||
$table->string('username')->unique(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ここはcreateですし実質変更ないので大丈夫ですかね。
@@ -15,7 +15,7 @@ public function up() | |||
Schema::create('user_roles', function(Blueprint $table) | |||
{ | |||
$table->increments('id'); | |||
$table->string('name')->after('id')->unique(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ここもcreateですし実質変更ないので大丈夫ですかね。
@@ -17,7 +17,7 @@ public function up() | |||
{ | |||
Schema::table('users', function($table) | |||
{ | |||
$table->string('role')->after('password')->default(self::ROLE_ID_MEMBER); | |||
$table->string('role')->default(self::ROLE_ID_MEMBER); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
あれ、そもそもここで after()
削除してるのって何か理由ありますか?
(MySQL onlyな指定なのでこれまでのsqliteでは効いてないのでちょっとアレですが、mysqlなら消さなくてもいいのでは?と。そして消さなくていいなら余分なdiffは作らない方がいいかなと!)
remove query builder method [after] => caused mysql error (may be fixed in Laravel 5.1~)
これでしたね。。 🙇
消してOKです!
@hanhan1978 |
あー、、あと何よりPRの出し先がmasterではなくdevelop・・・・ |
そうだった。developだった...。久しぶりすぎてowlのルールを忘れてました・・・ |
\App::bind('Owl\Repositories\ItemRepositoryInterface', 'Owl\Repositories\Fluent\ItemRepository'); | ||
\App::bind('Owl\Repositories\ItemFtsRepositoryInterface', 'Owl\Repositories\Fluent\ItemFtsRepository'); | ||
if(env('DB_DRIVER', 'sqlite') == 'mysql') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ここ、PSR-2に合わせてifとelseの前後などに半角スペース1つください...
(phpcsの代わりにscrutinizerにしたのでエラー出てない.... 🙇 )
$fts->words = FtsUtils::toNgram($item->title . "\n\n" . $item->body); | ||
$fts->save(); | ||
} | ||
if(env('DB_DRIVER') === 'mysql'){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ここもスペース!
@@ -32,7 +39,15 @@ public function up() | |||
*/ | |||
public function down() | |||
{ | |||
DB::statement('DROP TABLE items_fts ;'); | |||
if(env('DB_DRIVER') === 'mysql') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ここもスペース!
$fts->words = FtsUtils::toNgram($tag->name); | ||
$fts->save(); | ||
} | ||
if(env('DB_DRIVER') === 'mysql'){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ここも(
@@ -31,7 +37,13 @@ public function up() | |||
*/ | |||
public function down() | |||
{ | |||
DB::statement('DROP TABLE tags_fts ;'); | |||
if(env('DB_DRIVER') === 'mysql'){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ここm(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
すいません、IDEに不慣れだったせいで、タブとスペースが混ざっていたことに今さっき気づきました。とりあえず指摘点を修正し終わったら、その辺相談させて下さい。
- Append space after if/else to follow psr2 - Fix php doc return type - Revert change in migrations - Separate migration by database schema - modify item_tag foreign key constraint -> Add delete cascade for mysql compatibility - Fix migration rollback for items table -> must drop fulltext index before changing collation of a related column.
Change mysql setting [strict] false => true => avoid migration error for creatd_at default value(0) Change migration files for MySQL 1. remove query builder method [after] => caused mysql error (may be fixed in Laravel 5.1~) 2. change token column data type from text to varchar(512) => cannot set unique index for blob data type in MySQL Add setting in .env.example => default sqlite Sync .env setting int .env.behat => add database config Add MySQL specific repository for fulltext search => MySQL/ItemFtsRepository => MySQL/TagFtsRepository
- Append space after if/else to follow psr2 - Fix php doc return type - Revert change in migrations - Separate migration by database schema - modify item_tag foreign key constraint -> Add delete cascade for mysql compatibility - Fix migration rollback for items table -> must drop fulltext index before changing collation of a related column.
3352f28
to
87e21c2
Compare
@hanhan1978 |
Change mysql setting [strict] false => true
=> avoid migration error for creatd_at default value(0)
Change migration files for MySQL
=> caused mysql error (may be fixed in Laravel 5.1~)
=> cannot set unique index for blob data type in MySQL
Add setting in .env.example
=> default sqlite
Sync .env setting int .env.behat
=> add database config
Add MySQL specific repository for fulltext search
=> MySQL/ItemFtsRepository
=> MySQL/TagFtsRepository