本文整理汇总了PHP中Schema::getConnection方法的典型用法代码示例。如果您正苦于以下问题:PHP Schema::getConnection方法的具体用法?PHP Schema::getConnection怎么用?PHP Schema::getConnection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Schema
的用法示例。
在下文中一共展示了Schema::getConnection方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: migrate
/**
* Resets the database and install the migration table.
*
* @return void
*/
protected function migrate()
{
$tableNames = Schema::getConnection()->getDoctrineSchemaManager()->listTableNames();
foreach ($tableNames as $table) {
Schema::drop($table);
}
$this->app['Illuminate\\Contracts\\Console\\Kernel']->call('migrate:install', ['--env' => 'testing']);
}
示例2: up
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
$platform = Schema::getConnection()->getDoctrineSchemaManager()->getDatabasePlatform();
$platform->registerDoctrineTypeMapping('enum', 'string');
Schema::table('assets', function ($table) {
$table->decimal('purchase_cost', 8, 2)->nullable()->default(null)->change();
});
}
示例3: down
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('goods', function (Blueprint $table) {
$table->dropColumn('capsule_unit');
});
$table = Schema::getConnection()->getTablePrefix() . 'good_log';
DB::statement("ALTER TABLE `" . $table . "` MODIFY COLUMN `status` ENUM('purchase', 'new', 'picking' , 'price', 'edit', 'damage', 'replacement', 'allocation', 'empty');");
}
示例4: down
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
$grammar = Schema::getConnection()->getSchemaGrammar();
if ($grammar instanceof \Illuminate\Database\Schema\Grammars\MySqlGrammar) {
Schema::table('GDN_Discussion', function ($table) {
$table->dropIndex('search');
});
}
Schema::drop('GDN_Discussion');
}
示例5: cleanDatabase
/**
* Clean out the database for a new seed generation.
*/
private function cleanDatabase()
{
DB::statement('SET FOREIGN_KEY_CHECKS=0');
$tableNames = Schema::getConnection()->getDoctrineSchemaManager()->listTableNames();
foreach ($tableNames as $name) {
//if you don't want to truncate migrations
if ($name == 'migrations') {
continue;
}
DB::table($name)->truncate();
}
DB::statement('SET FOREIGN_KEY_CHECKS=1');
}
示例6: up
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
\Schema::create($this->table, function (Blueprint $table) {
$table->increments('meta_id');
$table->string('meta_key');
$table->longText('meta_value');
$table->string('meta_type')->default('string');
$table->morphs('metable');
$table->index('meta_key');
// Laravel doesn't handle index length, so we need raw statement for this one
\Schema::getConnection()->statement('create index meta_attributes_index_value on meta_attributes (meta_key, meta_value(20))');
});
}
示例7: up
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('people', function (Blueprint $table) {
// Credit: https://github.com/laravel/framework/issues/3253#issuecomment-51961561
$conn = Schema::getConnection();
$dbSchemaManager = $conn->getDoctrineSchemaManager();
$doctrineTable = $dbSchemaManager->listTableDetails('people');
if ($doctrineTable->hasIndex('people_email_unique')) {
$table->dropUnique('people_email_unique');
}
$table->dropUnique('deleted_at');
$table->unique(['email', 'deleted_at']);
});
}
示例8: up
/**
* Add the seeded data.
*/
public function up()
{
// we will have some crazy ID values, cajole MySQL into accepting them
$grammar = Schema::getConnection()->getSchemaGrammar();
if ($grammar instanceof \Illuminate\Database\Schema\Grammars\MySqlGrammar) {
DB::statement('SET SESSION SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";');
}
// do the seeding
DB::beginTransaction();
foreach ($this->getSeedData() as $table => $rows) {
// Note: each row may have different columns: can't use bulk insert
foreach ($rows as $row) {
$this->insertRow($table, $row);
}
}
DB::commit();
}
示例9: emptyTables
private function emptyTables()
{
if (substr_count(get_class(DB::connection()), 'MySql') > 0) {
DB::statement('SET FOREIGN_KEY_CHECKS=0');
}
$tableNames = Schema::getConnection()->getDoctrineSchemaManager()->listTableNames();
foreach ($tableNames as $name) {
//if you don't want to truncate migrations
if ($name == 'migrations') {
continue;
}
DB::table($name)->truncate();
}
if (substr_count(get_class(DB::connection()), 'MySql') > 0) {
DB::statement('SET FOREIGN_KEY_CHECKS=1');
}
}
示例10: testSetUp
/**
* Tests to make sure our testing environment is set up correctly
*/
public function testSetUp()
{
// make sure tests are working
$this->assertTrue(true);
// make sure Sentry is loaded and facade works
$this->assertInstanceOf('Cartalyst\\Sentry\\Sentry', $this->app['sentry']);
// verify that we have a database connection
$this->assertInstanceOf('Illuminate\\Database\\Connection', Schema::getConnection());
// test that our database exists and has tables created in migrations
$this->assertTrue(Schema::hasTable('migrations'));
$this->assertTrue(Schema::hasTable('users'));
$this->assertTrue(Schema::hasTable('foos'));
$this->assertTrue(Schema::hasTable('bars'));
$this->assertTrue(Schema::hasTable('bazes'));
// test that the data we entered is loaded
// check to see that our testing models were loaded
$this->assertTrue(class_exists('Morphatic\\Snapi\\Tests\\Foo'));
$this->assertTrue(class_exists('Morphatic\\Snapi\\Tests\\Bar'));
$this->assertTrue(class_exists('Morphatic\\Snapi\\Tests\\Baz'));
}
示例11: dropTables
/**
* Drop all the tables in the database
*/
public function dropTables()
{
$all_tables = \Schema::getConnection()->getDoctrineSchemaManager()->listTableNames();
\DB::statement("SET foreign_key_checks = 0");
foreach ($all_tables as $table) {
\DB::statement('DROP TABLE IF EXISTS ' . $table);
}
}
示例12: up
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
$platform = Schema::getConnection()->getDoctrineSchemaManager()->getDatabasePlatform();
$platform->registerDoctrineTypeMapping('enum', 'string');
class ChangeProductsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('products', function ($table) {
$table->integer('subindustry_id')->unsigned()->nullable()->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('products', function ($table) {
$table->integer('subindustry_id')->unsigned()->change();
});
}
}
示例13: down
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
$table = Schema::getConnection()->getTablePrefix() . 'good_log';
DB::statement("ALTER TABLE `" . $table . "` MODIFY COLUMN `status` ENUM('purchase', 'new', 'picking' , 'price', 'edit', 'damage', 'replacement');");
}