Migrate teachers.
193830
protected function migrateTeachers()
    {
        $this->output->info('### Migrating teachers ###');
        foreach ($this->teachers() as $teacher) {
            $this->showMigratingInfo($teacher, 1);
            $this->output->info('  email: ' . $teacher->email);
            $this->migrateTeacher($teacher);
        }
        $this->output->info(
            '### END Migrating teachers. Migrated ' . count($this->teachers()) .  ' teachers   ###');
    }
239144
public function up()
    {
        Schema::create('bank_details', function(Blueprint $table)
        {
            $table->integer('bank_detail_id', true)->unsigned();
            $table->integer('user_id')->unsigned();
            $table->text('account_number');
            $table->text('sort_code');

            $table->foreign('user_id')->references('user_id')->on('users');
        });

        Schema::create('purchases', function(Blueprint $table)
        {
            $table->integer('purchase_id', true)->unsigned();
            $table->integer('item_id')->unsigned();
            $table->integer('user_id')->unsigned();
            $table->integer('delivery_option_id')->unsigned();
            $table->decimal('unit_price', 8, 2)->unsigned();
            $table->integer('quantity')->unsigned();
            $table->decimal('total', 8, 2)->unsigned();
            $table->decimal('received', 8, 2)->unsigned();
            $table->integer('refunded')->unsigned();
            $table->decimal('refunded_amount', 8, 2)->unsigned();
            $table->integer('created')->unsigned();
            $table->integer('paid')->unsigned();
            $table->integer('dispatched')->unsigned();
            $table->string('tracking_number', 128);
            $table->char('country', 2);
            $table->string('name', 64);
            $table->string('street1', 64);
            $table->string('street2', 64);
            $table->string('city', 64);
            $table->string('county', 64);
            $table->string('postcode', 16);

            $table->foreign('item_id')->references('item_id')->on('items');
            $table->foreign('user_id')->references('user_id')->on('users');
        });

        Schema::create('postal_addresses', function(Blueprint $table)
        {
            $table->integer('postal_address_id', true)->unsigned();
            $table->integer('user_id')->unsigned()->nullable();
            $table->char('country', 2);
            $table->string('name', 64);
            $table->string('street1', 64);
            $table->string('street2', 64);
            $table->string('city', 64);
            $table->string('county', 64);
            $table->string('postcode', 16);
            $table->integer('added')->unsigned();

            $table->foreign('user_id')->references('user_id')->on('users');
        });
    }
101154
def migrate():
    '''
    
    '''
    counter = Counter()
    drom_zone = GeoZone.objects(id='country-subset:fr:drom').first()
    dromcom_zone = GeoZone.objects(id='country-subset:fr:dromcom').first()
    # Iter over datasets with zones
    for dataset in Dataset.objects(spatial__zones__gt=[]):
        counter['datasets'] += 1
        new_zones = []
        for zone in dataset.spatial.zones:
            if zone.id.startswith('fr/'):
                counter['zones'] += 1
                country, kind, zone_id = zone.id.split('/')
                zone_id = zone_id.upper()  # Corsica 2a/b case.
                if kind == 'town':
                    counter['towns'] += 1
                    new_zones.append(
                        GeoZone
                        .objects(code=zone_id, level='fr:commune')
                        .valid_at(date.today())
                        .first())
                elif kind == 'county':
                    counter['counties'] += 1
                    new_zones.append(
                        GeoZone
                        .objects(code=zone_id, level='fr:departement')
                        .valid_at(date.today())
                        .first())
                elif kind == 'region':
                    counter['regions'] += 1
                    # Only link to pre-2016 regions which kept the same id.
                    new_zones.append(
                        GeoZone
                        .objects(code=zone_id, level='fr:region')
                        .first())
                elif kind == 'epci':
                    counter['epcis'] += 1
                    new_zones.append(
                        GeoZone
                        .objects(code=zone_id, level='fr:epci')
                        .valid_at(dataset.created_at.date())
                        .first())
                else:
                    new_zones.append(zone)
            elif zone.id.startswith('country-subset/fr'):
                counter['zones'] += 1
                subset, country, kind = zone.id.split('/')
                if kind == 'dom':
                    counter['drom'] += 1
                    new_zones.append(drom_zone)
                elif kind == 'domtom':
                    counter['dromcom'] += 1
                    new_zones.append(dromcom_zone)
            elif zone.id.startswith('country/'):
                counter['zones'] += 1
                counter['countries'] += 1
                new_zones.append(zone.id.replace('/', ':'))
            elif zone.id.startswith('country-group/'):
                counter['zones'] += 1
                counter['countrygroups'] += 1
                new_zones.append(zone.id.replace('/', ':'))
            else:
                new_zones.append(zone)
        dataset.update(
            spatial=SpatialCoverage(
                granularity=dataset.spatial.granularity,
                zones=[getattr(z, 'id', z) for z in new_zones if z]
            )
        )
    log.info(Formatter().vformat('''Summary
    Processed {zones} zones in {datasets} datasets:
    - {countrygroups} country groups (World/UE)
    - {countries} countries
    - France:
        - {regions} regions
        - {counties} counties
        - {epcis} EPCIs
        - {towns} towns
        - {drom} DROM
        - {dromcom} DROM-COM
    ''', (), counter))
    log.info('Done')
985684
def migrate(directory, message, sql, head, splice, branch_label, version_path,
            rev_id, x_arg):
    """"""
    _migrate(directory, message, sql, head, splice, branch_label, version_path,
             rev_id, x_arg)
210177
public function up()
    {
        Schema::create('translation_groups', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name')->unique();
            $table->string('description')->nullable()->default(NULL);
            $table->timestamps();
        });

        Schema::create('translations', function (Blueprint $table) {
            $table->increments('id');
            $table->string('language', 10);
            $table->string('key', 100);
            $table->text('value')->nullable()->default(NULL);
            $table->integer('parent')->unsigned()->nullable()->default(NULL);
            $table->integer('translation_group')->unsigned();
            $table->boolean('flagged')->nullable()->default(NULL);
            $table->timestamps();

            $table->unique(['language', 'key', 'translation_group', 'parent']);

            $table->foreign('parent')->references('id')->on('translations')->onDelete('SET NULL');
            $table->foreign('translation_group')->references('id')->on('translation_groups')->onDelete('cascade');
        });
    }
480757
private function migrateCurriculum()
    {
        foreach ($this->departments() as $department) {
            $this->setDepartment($department);
            $this->showMigratingInfo($department,1);
            $this->migrateDepartment($department);
            foreach ($this->studies($department) as $study) {
                $this->setStudy($study);
                $this->showMigratingInfo($study,2);
                $this->migrateStudy($study);
                $this->addStudyToDeparment();
                foreach ($this->courses($study) as $course) {
                    $this->setCourse($course);
                    $this->showMigratingInfo($course,3);
                    $this->migrateCourse($course);
                    $this->addCourseToStudy();
                    foreach ($this->modules($course) as $module) {
                        $this->setModule($module);
                        $this->showMigratingInfo($module, 4);
                        $this->migrateModule($module);
                        $this->addModuleToCourse();
                        foreach ($this->submodules($module) as $submodule) {
                            $this->setSubmodule($submodule);
                            $this->showMigratingInfo($submodule, 5);
                            $this->migrateSubmodule($submodule);
                            $this->addSubModuleToModule();
                        }
                    }
                }
            }
        }
    }
488754
public function migrate()
    {
        $fs = new Filesystem;
        $finder = new ClassFinder;
        $path = env('MIGRATIONS_PATH', 'database/migrations');

        if ($fs->exists($path)) {
            foreach ($fs->files($path) as $file) {
                $fs->requireOnce($file);
                $class = $finder->findClass($file);

                (new $class)->up();
            }
        }
    }
441706
def migrate(self):
        """"""
        with io.open(self.json_file, 'rt', encoding='utf8') as fh:
            threads = json.load(fh)
        progress = Progress(len(threads))

        for i, thread in enumerate(threads):
            progress.update(i, str(i))
            self.insert(thread)

        progress.finish("{0} threads, {1} comments".format(len(threads), self.count))
721990
public function up()
    {
        Schema::create('attendances', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('user_id')->unsigned();
            $table->integer('day_id')->unsigned();
            $table->integer('timeslot_id')->unsigned();
            $table->date('date');
            $table->integer('studysubmodule_id')->unsigned();
            $table->integer('type_id')->unsigned(); //TODO ? 1 a N aixi?
            $table->text('notes');
            //todo userstamps??? https://github.com/WildSideUK/Laravel-Userstamps?? https://github.com/acacha/Laravel-Userstamps
            //Ho farem més tard.
            $table->timestamps();
        });

        Schema::create('attendance_types', function (Blueprint $table) {
            $table->increments('id');
            $table->enum('name', ['Faltes', 'Faltes justificades', 'Retards', 'Retards Justificats', 'Expulsions']);
            $table->timestamps();
        });
    }
1148439
public function up()
    {
        // Create table for storing roles
        Schema::create('roles', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name')->unique();
            $table->string('display_name')->nullable();
            $table->string('description')->nullable();
            $table->timestamps();
            $table->softDeletes();
        });

        // Create table for storing users
        Schema::create('users', function (Blueprint $table) {
            $table->increments('id');
            $table->string('first_name');
            $table->string('last_name');
            $table->integer('country_id')->unsigned();
            $table->string('phone_number')->nullable();
            $table->string('username');
            $table->string('password');
            $table->string('email')->unique();
            $table->string('slug')->unique();
            $table->integer('points')->default(0);
            $table->timestamp('last_login')->nullable();
            $table->string('remember_token');
            $table->boolean('state')->default(1);
            $table->timestamps();
            $table->softDeletes();

            $table->foreign('country_id')->references('id')->on('countries');
        });

        // Create table for associating roles to users (Many-to-Many)
        Schema::create('role_user', function (Blueprint $table) {
            $table->integer('user_id')->unsigned();
            $table->integer('role_id')->unsigned();

            $table->foreign('user_id')->references('id')->on('users')
                ->onUpdate('cascade')->onDelete('cascade');
            $table->foreign('role_id')->references('id')->on('roles')
                ->onUpdate('cascade')->onDelete('cascade');

            $table->primary(['user_id', 'role_id']);
            $table->softDeletes();
        });

        // Create table for storing permissions
        Schema::create('permissions', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name')->unique();
            $table->string('display_name')->nullable();
            $table->string('description')->nullable();
            $table->timestamps();
            $table->softDeletes();
        });

        // Create table for associating permissions to roles (Many-to-Many)
        Schema::create('permission_role', function (Blueprint $table) {
            $table->integer('permission_id')->unsigned();
            $table->integer('role_id')->unsigned();

            $table->foreign('permission_id')->references('id')->on('permissions')
                ->onUpdate('cascade')->onDelete('cascade');
            $table->foreign('role_id')->references('id')->on('roles')
                ->onUpdate('cascade')->onDelete('cascade');

            $table->primary(['permission_id', 'role_id']);
            $table->softDeletes();
        });
    }
937968
public function migrateUp()
    {
        Schema::table('tddd_testers', function (Blueprint $table) {
            $table->dropColumn('require_tee');

            $table->dropColumn('require_script');

            $table->text('pipers');
        });
    }
444790
public function up()
    {
        Schema::table('users', function (Blueprint $table) {
            if (Schema::hasColumn('users', 'deleted_at') == false) {
                $table->softDeletes();
            }
        });
    }
1165943
public function up()
    {
      //remove anahita from nodes and edges table names
      if (!dbexists('SHOW TABLES LIKE "#__nodes"')) {
          dbexec('RENAME TABLE #__anahita_nodes TO #__nodes');
      }

      if (!dbexists('SHOW TABLES LIKE "#__edges"')) {
          dbexec('RENAME TABLE #__anahita_edges TO #__edges');
      }

        //migrate users usertype
       dbexec('UPDATE `#__users` SET `usertype`=\'registered\' WHERE `usertype` NOT LIKE \'%admin%\' ');
        dbexec('UPDATE `#__users` SET `usertype`=\'administrator\' WHERE `usertype`=\'Administrator\' ');
        dbexec('UPDATE `#__users` SET `usertype`=\'super-administrator\' WHERE `usertype`=\'Super Administrator\' ');
        dbexec('ALTER TABLE `#__users` DROP COLUMN `gid` ');
        dbexec('ALTER TABLE `#__users` DROP COLUMN `sendEmail` ');

       //migrate people usertype
       dbexec('UPDATE `#__nodes` SET `person_usertype`=\'registered\' WHERE `person_usertype` NOT LIKE \'%admin%\' ');
        dbexec('UPDATE `#__nodes` SET `person_usertype`=\'administrator\' WHERE `person_usertype`=\'Administrator\' ');
        dbexec('UPDATE `#__nodes` SET `person_usertype`=\'super-administrator\' WHERE `person_usertype`=\'Super Administrator\' ');

       //migrate session table
       dbexec('ALTER TABLE `#__session` DROP COLUMN `gid` ');

       //drop legacy tables
       dbexec('DROP TABLE #__core_acl_aro');
        dbexec('DROP TABLE #__core_acl_aro_groups');
        dbexec('DROP TABLE #__core_acl_aro_map');
        dbexec('DROP TABLE #__core_acl_aro_sections');
        dbexec('DROP TABLE #__core_acl_groups_aro_map');
        dbexec('DROP TABLE #__groups');

       //legacy component cleanup
       dbexec('DELETE FROM `#__components` WHERE `option` IN (\'com_users\', \'com_user\') ');
        dbexec('UPDATE `#__components` SET `admin_menu_link`=\'option=com_people\', `admin_menu_alt`=\'People\', `admin_menu_img`=\'js/ThemeOffice/component.png\' WHERE `option`=\'com_people\' ');

        dbexec('ALTER TABLE `#__nodes` MODIFY `enabled` tinyint(1) NOT NULL DEFAULT 0');
        dbexec('ALTER TABLE `#__nodes` MODIFY `is_default` tinyint(1) NOT NULL DEFAULT 0');
        dbexec('UPDATE `#__nodes` SET `story_subject_id` = `created_by` WHERE `story_subject_id` = `story_target_id` AND `name` = \'actor_follow\'');
        dbexec('UPDATE `#__nodes` SET `enabled`=1, `access` = \'admins\' WHERE `type` LIKE \'%com:people.domain.entity.person\' AND `enabled` = 0');
    }
743718
public function up()
    {
        // Laravel 5.4 changed the table layout for jobs and failed_jobs
        if (Schema::hasColumn('jobs', 'reserved')) {
            Schema::table('jobs', function (Blueprint $table) {
                $table->dropColumn('reserved');
            });
        }
        if (!Schema::hasColumn('failed_jobs', 'exception')) {
            Schema::table('failed_jobs', function (Blueprint $table) {
                $table->longText('exception');
            });
        }
    }
856487
public function up()
    {
        Schema::create('carts', function (Blueprint $table) {
            $table->increments('id');
            $table->string('cookie');
            $table->integer('auth_user')->unsigned()->nullable();
            $table->decimal('subtotal', 8, 2);
            $table->decimal('discount', 8, 2);
            $table->decimal('discount_percentage', 5, 2);
            $table->integer('coupon_id')->unsigned()->nullable();
            $table->decimal('shipping_charges', 8, 2);
            $table->decimal('net_total', 8, 2);
            $table->decimal('tax', 8, 2);
            $table->decimal('total', 8, 2);
            $table->decimal('round_off', 8, 2);
            $table->decimal('payable', 8, 2);
            $table->timestamps();
        });
    }
316186
public function up()
    {
        /** based on ISO 3166-2 https://en.wikipedia.org/wiki/ISO_3166-2 */
        Schema::create('provinces', function (Blueprint $table) {
            $table->increments('id');
            $table->char('country_id', 2);
            $table->enum('type', ProvinceTypeProxy::values())->default(ProvinceTypeProxy::defaultValue());
            $table->string('code', 16)->nullable()->comment('National identification code');
            $table->string('name');

            $table->foreign('country_id')
                ->references('id')
                ->on('countries');
        });
    }
1290599
public function up()
    {
        Schema::create(Config::get('amethyst.invoice.data.invoice.table'), function (Blueprint $table) {
            $table->increments('id');
            $table->string('number')->nullable();
            $table->string('country');
            $table->string('locale');
            $table->string('currency');
            $table->integer('type_id')->unsigned()->nullable();
            $table->foreign('type_id')->references('id')->on(Config::get('amethyst.taxonomy.data.taxonomy.table'));
            $table->integer('sender_id')->unsigned()->nullable();
            $table->foreign('sender_id')->references('id')->on(Config::get('amethyst.legal-entity.data.legal-entity.table'));
            $table->integer('recipient_id')->unsigned();
            $table->foreign('recipient_id')->references('id')->on(Config::get('amethyst.legal-entity.data.legal-entity.table'));
            $table->integer('tax_id')->unsigned()->nullable();
            $table->foreign('tax_id')->references('id')->on(Config::get('amethyst.tax.data.tax.table'));
            $table->date('issued_at')->nullable();
            $table->date('expires_at')->nullable();
            $table->timestamps();
            $table->softDeletes();
        });

        Schema::create(Config::get('amethyst.invoice.data.invoice-container.table'), function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->text('description')->nullable();
            $table->integer('invoice_id')->unsigned();
            $table->foreign('invoice_id')->references('id')->on(Config::get('amethyst.invoice.data.invoice.table'));
            $table->timestamps();
            $table->softDeletes();
        });

        Schema::create(Config::get('amethyst.invoice.data.invoice-item.table'), function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->string('description')->nullable();
            $table->float('price');
            $table->float('quantity');
            $table->integer('unit_id')->unsigned();
            $table->foreign('unit_id')->references('id')->on(Config::get('amethyst.taxonomy.data.taxonomy.table'));
            $table->integer('invoice_container_id')->unsigned();
            $table->foreign('invoice_container_id')->references('id')->on(Config::get('amethyst.invoice.data.invoice-container.table'));
            $table->integer('invoice_id')->unsigned();
            $table->foreign('invoice_id')->references('id')->on(Config::get('amethyst.invoice.data.invoice.table'));
            $table->integer('tax_id')->unsigned()->nullable();
            $table->foreign('tax_id')->references('id')->on(Config::get('amethyst.tax.data.tax.table'));
            $table->timestamps();
            $table->softDeletes();
        });
    }