本文整理汇总了PHP中Illuminate\Database\Capsule\Manager::schema方法的典型用法代码示例。如果您正苦于以下问题:PHP Manager::schema方法的具体用法?PHP Manager::schema怎么用?PHP Manager::schema使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Database\Capsule\Manager
的用法示例。
在下文中一共展示了Manager::schema方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: TableExists
/**
* Returns true if the specified table exists in the database.
*
* @param $table
*
* @return bool
*/
public function TableExists($table)
{
if ($this->capsule->schema()->hasTable($table)) {
return true;
}
return false;
}
示例2: createSchema
/**
* Create Schema
*
* @return AdapterInterface
*/
public function createSchema()
{
/* @var \Illuminate\Database\Schema\Blueprint $table */
$this->adapter->schema()->create($this->tableName, function ($table) {
$table->string('version');
});
}
示例3: setupBeforeClass
public static function setupBeforeClass()
{
$db = new DB();
$db->addConnection(['driver' => 'sqlite', 'database' => ':memory:', 'prefix' => '']);
$db->setAsGlobal();
$db->bootEloquent();
$db->schema()->create('voucher_campaigns', function ($table) {
$table->increments('id');
$table->timestamps();
$table->string('name');
$table->string('brand');
$table->string('urn')->unique();
$table->integer('expiry_limit')->default('14');
$table->boolean('is_active')->default('1');
});
$db->schema()->create('voucher_entries', function ($table) {
$table->increments('id');
$table->timestamps();
$table->string('hash')->unique();
$table->integer('campaign_id');
$table->boolean('is_redeemed')->default('0');
$table->datetime('redeemed_at')->default('0000-00-00 00:00:00');
$table->boolean('is_expired')->default('0');
$table->datetime('expired_at')->default('0000-00-00 00:00:00');
$table->boolean('is_valid')->default('1');
});
parent::setupBeforeClass();
static::$fm->seed(5, 'Fastwebmedia\\LaravelVouchering\\Models\\Campaign');
static::$fm->seed(5, 'Fastwebmedia\\LaravelVouchering\\Models\\Voucher');
}
示例4: init
public function init()
{
$this->capsule = new Capsule();
$this->capsule->addConnection(['driver' => 'mysql', 'host' => DB_HOST, 'port' => DB_PORT, 'database' => DB_NAME, 'username' => DB_USER, 'password' => DB_PASSWORD, 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci']);
$this->capsule->bootEloquent();
$this->capsule->setAsGlobal();
$this->schema = $this->capsule->schema();
}
示例5: init
/**
* Init the migration
*/
public function init()
{
//Get the Container
$container = $this->getContainer();
//Get Eloquent capsule
$this->capsule = $container['db'];
//Get schema builder instance
$this->schema = $this->capsule->schema();
}
示例6: createMigrationHistoryTable
/**
* Creates the migration history table.
*/
protected function createMigrationHistoryTable()
{
$tableName = $this->migrationTable;
$this->stdout("Creating migration history table \"{$tableName}\"...", Console::FG_YELLOW);
$this->db->schema()->create($this->migrationTable, function (Blueprint $table) {
$table->string('version', 180);
$table->primary('version');
$table->integer('apply_time');
});
$this->addMigrationHistory(self::BASE_MIGRATION);
$this->stdout("Done.\n", Console::FG_GREEN);
}
示例7: createAndSeedOrdersTable
/**
* Creates and seeds the order table.
*/
protected function createAndSeedOrdersTable()
{
/*
* @var $db Manager
*/
$this->db = Yii::$app->db;
$this->db->schema()->create('order', function ($table) {
$table->increments('id');
$table->string('name')->unique();
$table->timestamps();
});
Order::create(['name' => 'Test address']);
Order::create(['name' => 'Another test Address']);
}
示例8: setUp
public function setUp()
{
parent::setUp();
$this->mockWebApplication();
$this->db = Yii::$app->db;
$this->db->schema()->dropIfExists('order');
$this->db->schema()->create('order', function (Blueprint $table) {
$table->increments('id');
$table->string('address');
$table->timestamps();
});
$this->unloadFixtures();
$this->loadFixtures();
}
示例9: migrateTables
protected function migrateTables()
{
DB::schema()->create('posts', function ($table) {
$table->increments('id');
$table->integer('author_id')->unsigned();
$table->string('title');
$table->timestamps();
});
DB::schema()->create('comments', function ($table) {
$table->increments('id');
$table->integer('post_id')->unsigned();
$table->string('body');
$table->timestamps();
});
DB::schema()->create('people', function ($table) {
$table->increments('id');
$table->string('name');
$table->timestamps();
});
DB::schema()->create('messages', function ($table) {
$table->increments('id');
$table->integer('sender_id')->unsigned();
$table->integer('receiver_id')->unsigned();
$table->string('contents');
$table->timestamps();
});
}
示例10: runMigrations
/**
* command migrate
*/
private function runMigrations()
{
$files = glob($this->getMigrationPath() . '/*.php');
if (!Capsule::schema()->hasTable('migrations')) {
Capsule::schema()->create('migrations', function ($table) {
$table->string('migration');
$table->integer('batch');
});
}
$migrations = Migration::all();
foreach ($migrations as $migration) {
$filename = $this->getMigrationPath() . '/' . $migration->migration . '.php';
if (in_array($filename, $files)) {
$key = array_keys($files, $filename);
unset($files[$key[0]]);
}
}
$batch = Migration::all()->max('batch') + 1;
foreach ($files as $file) {
require_once $file;
$filename = basename($file, '.php');
$class = substr($filename, 18);
$migration = new $class();
$migration->up();
Migration::create(array('migration' => $filename, 'batch' => $batch));
$this->line("<success>File \"{$filename}.php\" processed</success>\n");
}
}
示例11: migrateTables
/**
* Migrates the tables required for testing.
*/
protected function migrateTables()
{
DB::schema()->create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('email');
$table->timestamps();
});
DB::schema()->create('posts', function (Blueprint $table) {
$table->increments('id');
$table->string('title');
$table->text('body');
$table->unsignedInteger('user_id')->index();
$table->timestamps();
});
DB::schema()->create('tags', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->timestamps();
});
DB::schema()->create('post_tag', function (Blueprint $table) {
$table->unsignedInteger('tag_id')->index();
$table->unsignedInteger('post_id')->index();
});
DB::schema()->create('categories', function (Blueprint $table) {
$table->increments('id');
$table->string('title');
$table->text('description')->nullable();
$table->timestamps();
});
}
示例12: createTables
public function createTables()
{
Capsule::schema()->create('routes', function ($table) {
$table->increments('id');
$table->string('name')->nullable();
});
Capsule::schema()->create('methods', function ($table) {
$table->increments('id');
$table->string('tags');
$table->enum('method', ['GET', 'POST', 'PUT', 'DELETE']);
$table->text('description')->nullable();
$table->integer('route_id')->unsigned()->index();
$table->foreign('route_id')->references('id')->on('routes')->onDelete('cascade');
});
Capsule::schema()->create('parameters', function ($table) {
$table->increments('id');
$table->string('name');
$table->enum('in', ['formData', 'path']);
$table->text('description')->nullable();
$table->boolean('required');
$table->enum('type', ['string', 'file']);
$table->integer('method_id')->unsigned()->index();
$table->foreign('method_id')->references('id')->on('methods')->onDelete('cascade');
});
}
示例13: createTables
protected function createTables()
{
Manager::schema()->create('conv_users', function ($table) {
$table->integer('conv_id')->nullable();
$table->integer('user_id')->nullable();
$table->primary(array('conv_id', 'user_id'));
});
Manager::schema()->create('conversations', function ($table) {
$table->increments('id');
$table->softDeletes();
$table->timestamps();
});
Manager::schema()->create('messages', function ($table) {
$table->increments('id');
$table->integer('sender_id');
$table->integer('conv_id');
$table->text('content');
$table->timestamps();
$table->index('sender_id');
$table->index('conv_id');
});
Manager::schema()->create('messages_status', function ($table) {
$table->increments('id');
$table->integer('user_id');
$table->integer('msg_id');
$table->boolean('self');
$table->integer('status');
$table->index('msg_id');
});
}
示例14: migration
/**
* To Perform migration to ensure the table and its properties
* are up-to-date
*
*/
public static function migration()
{
$tables = Migration::tables();
// Simple Filters.
if (!isset($tables)) {
return false;
}
foreach ($tables as $key => $value) {
if (empty($value) || is_null($value) || !isset($value)) {
continue;
}
loop:
if (Capsule::Schema()->hasTable($key)) {
foreach ($value as $column => $datatype) {
if (!Capsule::Schema()->hasColumn($key, $column)) {
//Assign the Name and Datatype for temporary access
self::$columns['name'] = $column;
self::$columns['datatype'] = $datatype;
Capsule::Schema()->table($key, function ($table) {
$column = self::$columns['name'];
$datatype = self::$columns['datatype'];
$table->{$datatype}($column)->after('id');
});
}
}
} else {
Capsule::schema()->create($key, function ($table) {
$table->increments('id');
$table->timestamps();
});
goto loop;
}
}
}
示例15: migrateTables
protected function migrateTables()
{
DB::schema()->create('models', function ($table) {
$table->increments('id');
$table->string('name');
$table->timestamps();
});
}