getSchemaBuilder() public method

Get a schema builder instance for the connection.
public getSchemaBuilder ( ) : Illuminate\Database\Schema\Builder
return Illuminate\Database\Schema\Builder
Ejemplo n.º 1
0
 /**
  * Create a new FieldTypeSchema instance.
  *
  * @param FieldType  $fieldType
  * @param Repository $cache
  */
 public function __construct(FieldType $fieldType, Container $container, Repository $cache)
 {
     $this->cache = $cache;
     $this->container = $container;
     $this->fieldType = $fieldType;
     $this->connection = $container->make('db')->connection();
     $this->schema = $this->connection->getSchemaBuilder();
 }
Ejemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function version($id)
 {
     $schema = $this->connection->getSchemaBuilder();
     if (!$schema->hasTable($this->tableName)) {
         return null;
     }
     $version = $this->connection->table($this->tableName)->where('version', $id)->first();
     if ($version) {
         return (array) $version;
     }
     return null;
 }
Ejemplo n.º 3
0
 /**
  * Create Schema
  *
  * @return AdapterInterface
  */
 public function createSchema()
 {
     /* @var \Illuminate\Database\Schema\Blueprint $table */
     $this->adapter->getSchemaBuilder()->create($this->tableName, function ($table) {
         $table->string('version');
     });
 }
Ejemplo n.º 4
0
 /**
  * Retrieve the schema builder for the database connection. And set a custom blueprint resolver to return an
  * instance of the Culpa Blueprint class.
  *
  * @param Connection $connection
  * @return \Illuminate\Database\Schema\Builder
  */
 protected static function getSchemaBuilder(Connection $connection)
 {
     $schemaBuilder = $connection->getSchemaBuilder();
     $schemaBuilder->blueprintResolver(function ($table, $callback) {
         return new Blueprint($table, $callback);
     });
     return $schemaBuilder;
 }
Ejemplo n.º 5
0
 public function getSchemaBuilder()
 {
     if (empty($this->builder)) {
         return parent::getSchemaBuilder();
     }
     $class = $this->builder;
     return new $class($this);
 }
Ejemplo n.º 6
0
 /**
  * @param \Illuminate\Database\Connection $db
  */
 public function initialize(Connection $db)
 {
     $builder = $db->getSchemaBuilder();
     $tables = ['networks' => function (Blueprint $table) {
         $table->increments('id');
         $table->string('server');
         $table->unique(['server']);
     }, 'channels' => function (Blueprint $table) {
         $table->increments('id');
         $table->integer('network_id')->unsigned();
         $table->string('channel');
         $table->unique(['network_id', 'channel']);
         $table->foreign('network_id')->references('id')->on('networks');
     }, 'nicks' => function (Blueprint $table) {
         $table->increments('id');
         $table->integer('network_id')->unsigned();
         $table->string('nick');
         $table->unique(['network_id', 'nick']);
         $table->foreign('network_id')->references('id')->on('networks');
     }, 'logs' => function (Blueprint $table) {
         $table->increments('id');
         $table->integer('channel_id')->unsigned();
         $table->integer('nick_id')->unsigned();
         $table->timestamp('timestamp');
         $table->text('message');
         $table->foreign('channel_id')->references('id')->on('channels');
         $table->foreign('nick_id')->references('id')->on('nicks');
     }, 'words' => function (Blueprint $table) {
         $table->increments('id');
         $table->string('word', 40);
     }, 'logs_words' => function (Blueprint $table) {
         $table->increments('id');
         $table->integer('logs_id')->unsigned();
         $table->integer('word_id')->unsigned();
         $table->foreign('logs_id')->references('id')->on('logs');
         $table->foreign('word_id')->references('id')->on('words');
     }];
     foreach ($tables as $table => $callback) {
         if ($builder->hasTable($table)) {
             continue;
         }
         $builder->create($table, $callback);
     }
 }
Ejemplo n.º 7
0
 /**
  * Preparar Migration.
  */
 public function __construct()
 {
     $this->con = app('db')->connection($this->getConnection());
     $this->builder = $this->con->getSchemaBuilder();
     $this->grammar = $this->con->getSchemaGrammar();
 }
Ejemplo n.º 8
0
 /**
  * Construct an instance of a BaseMigration.
  */
 public function __construct()
 {
     $this->db = app('db')->connection($this->connection);
     $this->builder = $this->db->getSchemaBuilder();
 }
 public function tearDown()
 {
     $this->connection->getSchemaBuilder()->dropIfExists('riders');
     $this->connection->getSchemaBuilder()->dropIfExists('classes');
 }
Ejemplo n.º 10
0
 /**
  * Overrride build function
  *
  * @param Connection $connection
  * @param Grammar    $grammar
  */
 public function build(Connection $connection, Grammar $grammar)
 {
     $command = $this->parseCommand($this->commands[0]->get('name'));
     $schema = $connection->getSchemaBuilder();
     if ($command === "drop") {
         $schema->dropIfExists($this->getI18NTableName());
     }
     parent::build($connection, $grammar);
     if ($command === "create") {
         $primary = $this->i18n_primary;
         $i18n_columns = $this->i18n_columns;
         $table_name = $this->table;
         $schema->create($this->getI18NTableName(), function (Blueprint $table) use($table_name, $primary, $i18n_columns) {
             foreach ($primary as $name => $col) {
                 $table->columns[] = $col;
                 $table->foreign($col->get('name'))->references($col->get('name'))->on($table_name)->onDelete('cascade');
             }
             foreach ($i18n_columns as $col) {
                 $table->columns[] = $col;
             }
             $table->string($this->i18n_code_field, 10);
             $table->primary(array_merge(array_keys($primary), [$this->i18n_code_field]));
         });
     }
 }
Ejemplo n.º 11
0
 public function __construct(Illuminate\Database\Connection $connection = NULL)
 {
     static::$connection = $connection ?: Forge::find('db.connection');
     static::$schema = static::$connection->getSchemaBuilder();
     static::$instance = $this;
 }