/**
  * 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);
 }
 /**
  * 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;
 }
Exemple #3
0
 /**
  * Create Schema
  *
  * @return AdapterInterface
  */
 public function createSchema()
 {
     /* @var \Illuminate\Database\Schema\Blueprint $table */
     $this->adapter->schema()->create($this->tableName, function ($table) {
         $table->string('version');
     });
 }
 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');
 }
 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();
 }
 /**
  * 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();
 }
 /**
  * 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']);
 }
 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();
 }
Exemple #9
0
 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();
     });
 }
Exemple #10
0
 /**
  * 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");
     }
 }
Exemple #11
0
 /**
  * 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();
     });
 }
Exemple #12
0
 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');
     });
 }
Exemple #13
0
 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');
     });
 }
Exemple #14
0
 /**
  * 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;
         }
     }
 }
Exemple #15
0
 protected function migrateTables()
 {
     DB::schema()->create('models', function ($table) {
         $table->increments('id');
         $table->string('name');
         $table->timestamps();
     });
 }
 /**
  * Create the users table.
  *
  * @return void
  */
 protected function migrateDatabase()
 {
     Capsule::schema()->create('users', function ($table) {
         $table->increments('id');
         $table->string('name');
         $table->string('email');
     });
 }
 protected function setUp()
 {
     parent::setUp();
     $this->schema = DB::schema();
     $migration = App::make('CreatePageAndObjectTables');
     $migration->down();
     $migration->up();
 }
Exemple #18
0
 /**
  * Migrate test table.
  */
 public function migrateTestTable()
 {
     DB::schema()->create('testing', function (Blueprint $table) {
         $table->uuid('id');
         $table->string('test');
         $table->timestamps();
     });
 }
Exemple #19
0
 public function migrateTables()
 {
     DB::schema()->create('posts', function ($table) {
         $table->increments('id');
         $table->string('title');
         $table->timestamps();
     });
 }
Exemple #20
0
 public function __construct($driver, $hostname, $username, $password, $database, $port = NULL, $prefix = NULL, $name = 'default')
 {
     $this->name = $name;
     if (!in_array($driver, ['mysql', 'pgsql', 'sqlite', 'sqlsrv'])) {
         exit('Error: Could not load database driver ' . $driver . '!');
     }
     $capsule = new Capsule();
     $capsule->addConnection(['driver' => $driver, 'host' => $hostname, 'database' => $database, 'username' => $username, 'password' => $password, 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => $prefix, 'port' => $port], $name);
     // Set the event dispatcher used by Eloquent models... (optional)
     $capsule->setEventDispatcher(new Dispatcher(new Container()));
     // Make this Capsule instance available globally via static methods... (optional)
     $capsule->setAsGlobal();
     // Setup the Eloquent ORM... (optional; unless you've used setEventDispatcher())
     $capsule->bootEloquent();
     $this->capsule = $capsule;
     $this->connection = $this->capsule->schema($this->name)->getConnection();
 }
 /**
  * Run the migration.
  *
  * @return void
  */
 public function up()
 {
     if (Capsule::schema()->hasTable($this->table)) {
         Capsule::schema()->table($this->table, function (Blueprint $table) {
             $table->softDeletes();
         });
     }
 }
 public function setUp()
 {
     parent::setUp();
     Capsule::schema()->create('issue1_model', function (Blueprint $table) {
         $table->bigIncrements('id');
         $table->longText('options');
     });
     $this->models = new Issue1Repository();
 }
 protected function migrateCategoryPostsTable()
 {
     DB::schema()->create('category_posts', function ($table) {
         $table->increments('id');
         $table->integer('category_id')->unsigned();
         $table->integer('post_id')->unsigned();
         $table->timestamps();
     });
 }
 public function setUp()
 {
     date_default_timezone_set("UTC");
     $database = __DIR__ . "/../databases/database.sqlite";
     file_put_contents($database, "");
     $this->capsule = new Capsule();
     $this->capsule->addConnection(["driver" => "sqlite", "database" => $database, "prefix" => ""]);
     $this->capsule->setAsGlobal();
     $this->capsule->bootEloquent();
     Capsule::schema()->create("roots", function ($table) {
         $table->increments("id");
         $table->string("test")->nullable();
         $table->unsignedInteger("bar_id")->nullable();
         $table->unsignedInteger("special_bar_id")->nullable();
         $table->timestamps();
     });
     Capsule::schema()->create("bars", function ($table) {
         $table->increments("id");
         $table->unsignedInteger("root_id")->nullable();
         $table->string("test");
         $table->timestamps();
     });
     Capsule::schema()->create("foos", function ($table) {
         $table->increments("id");
         $table->unsignedInteger("root_id")->nullable();
         $table->string("test");
         $table->text("data");
         $table->timestamps();
     });
     Capsule::schema()->create("polies", function ($table) {
         $table->increments("id");
         $table->unsignedInteger("root_id")->nullable();
         $table->morphs("polyable");
         $table->string("test");
         $table->timestamps();
     });
     Capsule::schema()->create("customs", function ($table) {
         $table->increments("id");
         $table->unsignedInteger("root_id")->nullable();
         $table->text("data");
         $table->timestamps();
     });
     Capsule::schema()->create("resources", function ($table) {
         $table->increments("id");
         $table->unsignedInteger("root_id")->nullable();
         $table->string("name");
         $table->timestamps();
     });
     Capsule::schema()->create("resource_references", function ($table) {
         $table->increments("id");
         $table->unsignedInteger("root_id")->nullable();
         $table->unsignedInteger("resource_id");
         $table->unsignedInteger("referable_id");
         $table->string("referable_type");
         $table->timestamps();
     });
 }
 function run()
 {
     Capsule::schema()->dropIfExists('users');
     Capsule::schema()->create('users', function ($table) {
         $table->increments('id');
         $table->string('username');
         $table->timestamps();
     });
 }
 /**
  * Setup the test table.
  *
  * @return void
  */
 protected function migrateTable()
 {
     DB::schema()->create('models', function ($table) {
         $table->increments('id');
         $table->string('default');
         $table->text('input');
     });
     Model::create(['default' => 'model', 'input' => '{"en":"translation","nl":"vertaling"}']);
 }
 function run()
 {
     Capsule::schema()->dropIfExists('friends');
     Capsule::schema()->create('friends', function ($table) {
         $table->integer('user_id')->index();
         $table->integer('friend_id')->index();
         $table->primary(['user_id', 'friend_id']);
     });
 }
 /**
  * Run the migration.
  *
  * @return void
  */
 public function up()
 {
     if (!Capsule::schema()->hasTable($this->table)) {
         Capsule::schema()->create($this->table, function (Blueprint $table) {
             $table->increments('id');
             $table->string('title');
             $table->timestamps();
         });
     }
 }
 function run()
 {
     Capsule::schema()->dropIfExists('users');
     Capsule::schema()->create('users', function ($table) {
         $table->increments('id');
         $table->string('email')->unique();
         $table->string('password');
         $table->timestamps();
     });
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function run()
 {
     Capsule::schema()->dropIfExists('teams');
     Capsule::schema()->create('teams', function (Blueprint $table) {
         $table->increments('id');
         $table->string('name');
         $table->string('nationality', 2);
         $table->timestamps();
     });
 }