Migrate teacher.

@param Teacher $teacher
496985
protected function migrateTeacher(Teacher $teacher) {
        $user = User::firstOrNew([
            'email' => $teacher->email,
        ]);
        $user->name = $teacher->name;
        $user->password = bcrypt('secret');
        $user->remember_token = str_random(10);
        $user->save();
        //TODO: migrate teacher codes, create roles and assign to user/teachers
    }
938427
public function migrate(array $filters)
    {
        $this->filters =$filters;
        foreach ($this->academicPeriods() as $period) {
            $this->period = $period->id;
            $this->setDestinationConnectionByPeriod($this->period);
            $this->switchToDestinationConnection();
            $this->output->info('Migrating period: ' . $period->name . '(' .  $period->id . ')');
            $this->migrateTeachers();
            $this->migrateLocations();
            $this->migrateCurriculum();
            $this->migrateClassrooms();
            $this->migrateEnrollments();
            $this->seedDays();
            $this->seedShifts();
            $this->migrateTimeslots();
            $this->migrateLessons();
       }
    }
623955
public function up()
	{
		if(Schema::hasColumn('001_017_text', 'lang_017'))
		{
			$key = DB::select(DB::raw('SHOW KEYS FROM 001_017_text WHERE Key_name=\'fk01_001_017_text\''));

			if($key != null)
			{
				Schema::table('001_017_text', function (Blueprint $table) {
					$table->dropForeign('fk01_001_017_text');
					$table->dropIndex('fk01_001_017_text');
				});

				Schema::table('001_017_text', function (Blueprint $table) {
					// rename column, function renameColumn doesn't work
					DB::select(DB::raw('ALTER TABLE 001_017_text CHANGE lang_017 lang_id_017 VARCHAR(2) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL'));
					$table->foreign('lang_id_017', 'fk01_001_017_text')->references('id_001')->on('001_001_lang')
						->onDelete('restrict')->onUpdate('cascade');
				});
			}
		}
	}
382130
protected function updateSubclassInterfacesTraits($class)
    {
        foreach ($class->subclasses as $subclass) {
            $subclass = $this->classes[$subclass];
            $subclass->interfaces = array_unique(array_merge($subclass->interfaces, $class->interfaces));
            $subclass->traits = array_unique(array_merge($subclass->traits, $class->traits));
            $this->updateSubclassInterfacesTraits($subclass);
        }
    }
1346427
public function up()
    {
        $driver = Schema::getConnection()->getDriverName();
        // Even though we take care of this scenario in the code,
        // SQL Server does not allow potential cascading loops,
        // so set the default no action and clear out created/modified by another user when deleting a user.
        $onDelete = (('sqlsrv' === $driver) ? 'no action' : 'set null');

        $output = new ConsoleOutput();
        $output->writeln("Migration driver used: $driver");

        // Script Service Config
        if (!Schema::hasTable('script_config')) {
            Schema::create(
                'script_config',
                function (Blueprint $t) {
                    $t->integer('service_id')->unsigned()->primary();
                    $t->foreign('service_id')->references('id')->on('service')->onDelete('cascade');
                    $t->mediumText('content')->nullable();
                    $t->text('config')->nullable();
                }
            );
        }

        // Event Scripts
        if (!Schema::hasTable('event_script')) {
            Schema::create(
                'event_script',
                function (Blueprint $t) use ($onDelete) {
                    $t->string('name', 80)->primary();
                    $t->string('type', 40);
                    $t->boolean('is_active')->default(0);
                    $t->mediumText('content')->nullable();
                    $t->text('config')->nullable();
                    $t->timestamp('created_date')->nullable();
                    $t->timestamp('last_modified_date')->useCurrent();
                    $t->integer('created_by_id')->unsigned()->nullable();
                    $t->foreign('created_by_id')->references('id')->on('user')->onDelete($onDelete);
                    $t->integer('last_modified_by_id')->unsigned()->nullable();
                    $t->foreign('last_modified_by_id')->references('id')->on('user')->onDelete($onDelete);
                }
            );
        }
    }
1357130
public function up()
    {
        Schema::table('users', function(Blueprint $table) {
            $table->string('token', 24)->unique()->after('remember_token');
            $table->tinyInteger('active')->default(0)->after('token');
        });
    
    }
191146
public function up()
    {
        $this->create('migrations', function ($table) {
            // Place table rows here
            $table->increments('id');
            $table->string('migration');
            $table->integer('migrated');
            $table->timestamps();
        });
    }
995948
public function up()
    {

        Schema::create('character_minings', function (Blueprint $table) {

            $table->bigInteger('character_id');
            $table->date('date');
            $table->time('time');
            $table->integer('year');
            $table->integer('month');
            $table->integer('solar_system_id');
            $table->integer('type_id');
            $table->bigInteger('quantity');

            $table->primary(['character_id', 'date', 'time', 'solar_system_id', 'type_id'],
                'mining_primary');
            $table->index(['character_id', 'date', 'solar_system_id', 'type_id'], 'mining_date_systype');
            $table->index('character_id');
            $table->index('date');
            $table->index('year');
            $table->index(['year', 'month']);
            $table->index('solar_system_id');
            $table->index('type_id');

            $table->timestamps();
        });
    }
155076
public function up()
    {
        Schema::connection($this->connection)->create('provider', function (Blueprint $table) {
            $table->increments('id', true);
            $table->string('firstname');
            $table->string('lastname');
            $table->string('practice_name');
            $table->string('address');
            $table->string('town');
            $table->string('state')->nullable();
            $table->string('country')->nullable();
            $table->string('email')->nullable();
        });
    }
974411
public function down()
    {
        // Check if the table exists
        if (Schema::hasTable('translations')) {
            if (Schema::hasColumn('translations', 'translatable_type')) {
                $items = DB::select('select * from translations');
                foreach ($items as $item) {
                    // Points to old namespace Redooor\\Redminportal\\
                    $old_type_array = explode('\\', $item->translatable_type);
                    $last_model = array_pop($new_type_array);
                    $old_type = 'Redooor\\Redminportal\\' . $last_model;
                    DB::table('translations')->where('id', $item->id)
                        ->update([
                        'translatable_type' => $old_type
                    ]);
                }
            }
        }
    }
957929
public function up()
    {
        if (!Schema::hasColumn('user', 'oauth_provider')) {
            Schema::table(
                'user',
                function (Blueprint $t){
                    $t->string('oauth_provider', 50)->nullable()->after('remember_token');
                }
            );
        }

        Schema::create(
            'oauth_config',
            function (Blueprint $t){
                $t->integer('service_id')->unsigned()->primary();
                $t->foreign('service_id')->references('id')->on('service')->onDelete('cascade');
                $t->integer('default_role')->unsigned()->nullable();
                // previously set to 'restrict' which isn't supported by all databases
                // removing the onDelete clause gets the same behavior as No Action and Restrict are defaults.
                $t->foreign('default_role')->references('id')->on('role');
                $t->string('client_id');
                $t->longText('client_secret');
                $t->string('redirect_url');
                $t->string('icon_class')->nullable();
            }
        );
    }
887663
public function up()
    {
        $driver = Schema::getConnection()->getDriverName();
        // Even though we take care of this scenario in the code,
        // SQL Server does not allow potential cascading loops,
        // so set the default no action and clear out created/modified by another user when deleting a user.
        $onDelete = (('sqlsrv' === $driver) ? 'no action' : 'set null');

        if (!Schema::hasTable('lookup')) { // make sure this isn't a clean install
            Schema::create('lookup', function (Blueprint $t) use ($onDelete) {
                $t->increments('id');
                $t->integer('app_id')->unsigned()->nullable();
                $t->foreign('app_id')->references('id')->on('app')->onDelete('cascade');
                $t->integer('role_id')->unsigned()->nullable();
                $t->foreign('role_id')->references('id')->on('role')->onDelete('cascade');
                $t->integer('user_id')->unsigned()->nullable();
                $t->foreign('user_id')->references('id')->on('user')->onDelete('cascade');
                $t->string('name');
                $t->text('value')->nullable();
                $t->boolean('private')->default(0);
                $t->text('description')->nullable();
                $t->timestamp('created_date')->nullable();
                $t->timestamp('last_modified_date')->useCurrent();
                $t->integer('created_by_id')->unsigned()->nullable();
                $t->foreign('created_by_id')->references('id')->on('user')->onDelete($onDelete);
                $t->integer('last_modified_by_id')->unsigned()->nullable();
                $t->foreign('last_modified_by_id')->references('id')->on('user')->onDelete($onDelete);
            });

            $lookups = [];
            if (Schema::hasTable('app_lookup')) {
                $lookups = array_merge($lookups, DB::table('app_lookup')->get()->toArray());
            }

            if (Schema::hasTable('role_lookup')) {
                $lookups = array_merge($lookups, DB::table('role_lookup')->get()->toArray());
            }

            if (Schema::hasTable('user_lookup')) {
                $lookups = array_merge($lookups, DB::table('user_lookup')->get()->toArray());
            }

            if (Schema::hasTable('system_lookup')) {
                $lookups = array_merge($lookups, DB::table('system_lookup')->get()->toArray());
            }

            foreach ($lookups as $lookup) {
                $lookup = array_except((array)$lookup, 'id');
                try {
                    DB::table('lookup')->insert($lookup);
                    Log::debug('Migrating Lookup: ' . array_get($lookup, 'name'));
                } catch (\Exception $ex) {
                    Log::error('Migrating Lookup Failed for ' . array_get($lookup, 'name') . ': ' . $ex->getMessage());
                }
            }
        }
    }
18300
public function submitMigration($className)
    {

        if ($this->direction == 'up') {
            if ($className::checkVersionUp($this->current, $this->target)) {
                $this->addMigration(new $className);
            }
        } elseif ($this->direction == 'down') {
            if ($className::checkVersionDown($this->current, $this->target)) {
                $this->addMigration(new $className);
            }
        }
    }
768153
private function runMigration()
    {
        // Confirm connection and migration.
        $connection = $this->confirmConnectionAndMigration();

        // Load the migration class.
        $migration_class = $this->getMigrationClass();

        // Process the migration.
        $this->processMigration($connection, $migration_class);

        // Save this migration to the database/migrations folder.
        $this->createMigrationFile($connection, $migration_class);
    }
444790
public function up()
    {
        Schema::table('users', function (Blueprint $table) {
            if (Schema::hasColumn('users', 'deleted_at') == false) {
                $table->softDeletes();
            }
        });
    }
709021
public function _perform($class)
    {
        $version = ObjectVersion::get($class);
        echo 'Object ' . $class . ' is in version ' . $version . PHP_EOL;

        while (true) {
            $migrateFunction = 'migrate_' . $version . '_' . ($version + 1);
            if (method_exists($class, $migrateFunction) === false) {
                break;
            }

            echo 'Migrate from ' . $version . ' to ' . ($version + 1) . PHP_EOL;
            $ok = forward_static_call(array($class, $migrateFunction));
            if ($ok !== true) {
                echo 'Failed' . PHP_EOL;
                break;
            }

            $version = ObjectVersion::inc($class);
            echo 'Ok' . PHP_EOL;
        }
    }
205605
private function processMigration($connection, $class)
    {
        // Verbose.
        $this->info('Migrating...');
        $this->line('');

        // Migrate the database.
        $migration = new $class($connection);
        $migration->up($connection);
    }