/** * Run the migrations. * * @return void */ public function up() { // This is to fix the auto increment bug caused by 2016_04_16_082627_create_various_artists // Return if the database driver is not MySQL. if (DB::getDriverName() !== 'mysql') { return; } $latestArtist = Artist::orderBy('id', 'DESC')->first(); DB::statement('ALTER TABLE artists AUTO_INCREMENT=' . ($latestArtist->id + 1)); }
protected function enableForeignKeyChecks() { switch (\DB::getDriverName()) { case 'mysql': \DB::statement('SET FOREIGN_KEY_CHECKS=1'); break; case 'sqlite': \DB::statement('PRAGMA foreign_keys = ON'); break; } }
/** * Bootstrap any application services. * * @return void */ public function boot() { try { if (\DB::getDriverName() == 'sqlite') { \DB::statement('PRAGMA foreign_keys=1'); } } catch (\PDOException $e) { // Ignore the exception // Because DB may not yet been set up. } }
/** * Run the migrations. * * @return void */ public function up() { $this->builder()->create(self::TABLE_NAME, function (Blueprint $table) { $table->increments('id'); $table->string('name', 63)->unique(); $table->timestamps(); $table->softDeletes(); }); if (DB::getDriverName() !== 'sqlite') { DB::statement('ALTER TABLE `tags` AUTO_INCREMENT=55;'); } }
/** * Reverse the migrations. * * @return void */ public function down() { if ('sqlite' !== DB::getDriverName()) { DB::statement('ALTER TABLE `show_songs` DROP INDEX show_songs_title_fulltext'); } Schema::table('images', function ($table) { $table->dropIndex('images_hash_index'); }); Schema::table('track_files', function ($table) { $table->dropIndex('track_files_is_master_index'); $table->dropIndex('track_files_format_index'); }); }
/** * @return bool|null */ protected function enableForeignKeyCheck() { switch (\DB::getDriverName()) { case "sqlite": return \DB::statement('PRAGMA foreign_keys = ON'); break; case "mysql": return \DB::statement('SET FOREIGN_KEY_CHECKS = 1'); break; default: return null; break; } }
/** * Run the migrations. * * @return void */ public function up() { $this->builder()->create(self::TABLE_NAME, function (Blueprint $table) { $table->increments('id'); $table->string('name')->unique(); $table->string('sku')->unique(); $table->string('slug')->unique(); $table->text('description')->nullable(); $table->timestamps(); $table->softDeletes(); }); if (DB::getDriverName() !== 'sqlite') { DB::statement('ALTER TABLE `products` AUTO_INCREMENT=67825;'); } }
/** * Run the migrations. * * @return void */ public function up() { Schema::create('files', function (Blueprint $table) { $table->bigIncrements('id'); $table->string('location')->unique(); if (DB::getDriverName() !== 'mysql') { $table->binary('content'); } $table->boolean('visibility')->default(true); $table->timestamps(); }); if (DB::getDriverName() === 'mysql') { DB::statement("ALTER TABLE `files` ADD `content` LONGBLOB;"); } }
/** * Run the migrations. * * @return void */ public function up() { $this->builder()->create(self::TABLE_NAME, function (Blueprint $table) { $table->increments('id'); $table->string('label', 127); $table->tinyInteger('position')->unsigned()->default(0); $table->integer('product_id')->unsigned()->index(); $table->foreign('product_id')->references('id')->on('products')->onDelete('cascade'); $table->unique(['product_id', 'label']); $table->timestamps(); $table->softDeletes(); }); if (DB::getDriverName() !== 'sqlite') { DB::statement('ALTER TABLE `product_options` AUTO_INCREMENT=55;'); } $this->initialiseProductOptions(); }
public function up() { Schema::table('tracks', function ($table) { $table->boolean('is_latest')->notNullable()->default(false)->indexed(); }); if ('sqlite' !== DB::getDriverName()) { DB::update(' UPDATE tracks t1 INNER JOIN ( SELECT id, user_id FROM tracks WHERE published_at IS NOT NULL AND deleted_at IS NULL ORDER BY created_at DESC LIMIT 1 ) t2 ON t2.id = t1.id SET is_latest = true WHERE t2.user_id = t1.user_id AND published_at IS NOT NULL '); } }
/** * @return bool */ protected function isMySQL() { return DB::getDriverName() === 'mysql'; }