Generate new migration file
763669
public function newMigration()
    {
        $fileName = (isset($this->arguments[1])) ? $this->arguments[1] : null;
        $this->migrateManager->newMigration($fileName);
    }
401369
def migrate(app_name=None, revision=None):
    ""
    cmd = ['python bin/manage.py syncdb --migrate']
    if app_name:
        cmd.append(app_name)
        if revision:
            cmd.append(revision)
    verun(' '.join(cmd))
173834
protected function createMigrationFile()
    {
        $fieldObjects = $this->getFields();

        if (@$fieldObjects['id']) {
            unset($fieldObjects['id']);
        }

        if (@$fieldObjects['created_at'] && @$fieldObjects['updated_at']) {
            $this->addGenericCall((new Base())->timestamps());

            unset($fieldObjects['created_at'], $fieldObjects['updated_at']);
        } // if

        if (@$fieldObjects['deleted_at']) {
            $this->addGenericCall((new Base())->softDeletes());

            unset($fieldObjects['deleted_at']);
        } // if

        $schema = implode(', ', $fieldObjects);

        if (strpos($schema, 'enum') !== false) {
            $this->getCommand()->info(sprintf('Please change the enum field of table "%s" manually.',
                $this->getName()));
        }

        if ($this->isPivotTable()) {
            $tables = array_keys($this->getForeignKeys());

            Artisan::call(
                'make:migration:pivot',
                [
                    'tableOne' => $tables[0],
                    'tableTwo' => $tables[1]
                ]
            );
        } else {
            Artisan::call(
                'make:migration:schema',
                [
                    'name' => "create_{$this->getName()}_table",
                    '--model' => $this->needsLaravelModel(),
                    '--schema' => $fieldObjects ? $schema : ''
                ]
            );

            $migrationFiles = glob(
                database_path('migrations') . DIRECTORY_SEPARATOR . "*_create_{$this->getName()}_table.php"
            );
        }

        return @$migrationFiles ? end($migrationFiles) : '';
    }
1263
def run_migration(data, version_start, version_end):
    """"""
    items = []
    if version_start == 1 and version_end == 2:
        for item in data['accounts']:
            items.append(v2.upgrade(item))

    if version_start == 2 and version_end == 1:
        for item in data:
            items.append(v2.downgrade(item))
        items = {'accounts': items}
    return items
125392
public function generateMigrationFile($method, $tables)
    {
        if ($method == 'create') {
            $function = 'getFields';
            $prefix = 'create';
        } elseif ($method = 'foreign_keys') {
            $function = 'getForeignKeyConstraints';
            $prefix = 'add_foreign_keys_to';
            $method = 'table';
        } else {
            return;
        }

        $this->method = $method;
        foreach ($tables as $table) {
            $migrationName = $prefix . '_' . $table . '_table';
            
            $fields = $this->schemaParser->{$function}($table);

            if (empty($fields)) {
                continue;
            }

            $filename = $this->datePrefix . '_' . $migrationName.'.php';

            $templateData = $this->getTemplateData($fields, [
                'CLASS'  => ucwords(camel_case($migrationName)),
                'TABLE'  => $table,
                'METHOD' => $method,
            ]);

            $this->generateFile($filename, $templateData);
        }
    }
712695
public function generate()
    {
        $create_at = date("YmdHis");
        $filename = sprintf("Version%s%s", $create_at, ucfirst(Str::camel('sessions')));

        $generator = new Generator(
            $this->setting->getMigrationDirectory(),
            $filename
        );

        $generator->write('model/session', [
            'className' => $filename
        ]);

        echo Color::green('Session migration created.');
    }
1093503
function buildDbMigrateArgs(grunt, config, command) {
  var args = [];
  var name = grunt.option('name');

  args.push(command);

  if (command === 'create') {
    if (!name) {
      throw new Error('--name required to create migration');
    }
    args.push(name);
  }

  if (grunt.option('count') !== undefined) {
    args.push('--count');
    args.push(grunt.option('count'));
  }

  if (grunt.option('dry-run')) {
    args.push('--dry-run');
  }

  if (grunt.option('db-verbose')) {
    args.push('--verbose');
  }

  if (grunt.option('sql-file')) {
    args.push('--sql-file');
  }

  if (grunt.option('coffee-file')) {
    args.push('--coffee-file');
  } else if (config.coffeeFile) {
    args.push('--coffee-file');
  }

  if (grunt.option('migrations-dir')) {
    args.push('--migrations-dir');
    args.push(grunt.option('migrations-dir'));
  } else if (config.migrationsDir) {
    args.push('--migrations-dir');
    args.push(config.migrationsDir);
  }

  if (grunt.option('table')) {
    args.push('--table');
    args.push(grunt.option('table'));
  } else if (config.table) {
    args.push('--table');
    args.push(config.table);
  }

  return args;
}
1323449
def exec_migration(migration, is_up)
      migration_dir = self.migration_dir(migration)
      result = @lang.exec_migration(migration_dir, is_up)
      if @lang.ext != "sql"
        puts result
      end

      Log.info("Updating current version number...")
      version = migration["version"]
      is_up ? @db.log_up(version) : @db.log_down(version)
    end
503705
protected function createMigration()
    {
        $files = scandir(__DIR__ . '/migrations');
        foreach ($files as $file) {
            if ($file == '.' || $file == '..' || file_exists(base_path('/database/migrations') . '/' . $file)) {
                continue;
            }
            if (copy(__DIR__ . '/migrations/' . $file, base_path('/database/migrations') . '/' . $file)) {
                $this->line("<info>Created Migration:</info> $file");
            }
        }
    }
39632
protected function createMigration()
    {
        $data = ['table' => $this->argument('table'), 'attachment' => $this->argument('attachment'), 'after' => $this->argument('after')];
        $prefix = date('Y_m_d_His');

        $fileName = $this->migrationsFolderPath.'/'.$prefix.'_add_'.$data['attachment'].'_fields_to_'.$data['table'].'_table.php';
        $data['className'] = 'Add'.ucfirst(Str::camel($data['attachment'])).'FieldsTo'.ucfirst(Str::camel($data['table'])).'Table';

        // Save the new migration to disk using the stapler migration view.
        $migration = $this->view->make('laravel-stapler::migration', $data)->render();
        $this->file->put($fileName, $migration);

        // Dump the autoloader and print a created migration message to the console.
        $this->info("Created migration: $fileName");
    }
1280471
private function migrate()
    {
        /**
         * create table for sentry user
         */
        if (!Capsule::schema()->hasTable('users')){
            Capsule::schema()->create('users', function($table)
            {
                $table->increments('id');
                $table->string('email');
                $table->string('password');
                $table->text('permissions')->nullable();
                $table->boolean('activated')->default(0);
                $table->string('activation_code')->nullable();
                $table->timestamp('activated_at')->nullable();
                $table->timestamp('last_login')->nullable();
                $table->string('persist_code')->nullable();
                $table->string('reset_password_code')->nullable();
                $table->string('first_name')->nullable();
                $table->string('last_name')->nullable();
                $table->timestamps();

                // We'll need to ensure that MySQL uses the InnoDB engine to
                // support the indexes, other engines aren't affected.
                $table->engine = 'InnoDB';
                $table->unique('email');
                $table->index('activation_code');
                $table->index('reset_password_code');
            });
        }

        /**
         * create table for sentry group
         */
        if (!Capsule::schema()->hasTable('groups')){
            Capsule::schema()->create('groups', function($table)
            {
                $table->increments('id');
                $table->string('name');
                $table->text('permissions')->nullable();
                $table->timestamps();

                // We'll need to ensure that MySQL uses the InnoDB engine to
                // support the indexes, other engines aren't affected.
                $table->engine = 'InnoDB';
                $table->unique('name');
            });
        }

        /**
         * create user-group relation
         */
        if (!Capsule::schema()->hasTable('users_groups')){
            Capsule::schema()->create('users_groups', function($table)
            {
                $table->integer('user_id')->unsigned();
                $table->integer('group_id')->unsigned();

                // We'll need to ensure that MySQL uses the InnoDB engine to
                // support the indexes, other engines aren't affected.
                $table->engine = 'InnoDB';
                $table->primary(array('user_id', 'group_id'));
            });
        }

        /**
         * create throttle table
         */
        if (!Capsule::schema()->hasTable('throttle')){
            Capsule::schema()->create('throttle', function($table)
            {
                $table->increments('id');
                $table->integer('user_id')->unsigned();
                $table->string('ip_address')->nullable();
                $table->integer('attempts')->default(0);
                $table->boolean('suspended')->default(0);
                $table->boolean('banned')->default(0);
                $table->timestamp('last_attempt_at')->nullable();
                $table->timestamp('suspended_at')->nullable();
                $table->timestamp('banned_at')->nullable();

                // We'll need to ensure that MySQL uses the InnoDB engine to
                // support the indexes, other engines aren't affected.
                $table->engine = 'InnoDB';
                $table->index('user_id');
            });
        }
    }
1221178
private function createMigrations()
    {
        $scripts   = $this->locator->findScripts();
        $rollbacks = $this->locator->findRollbackScripts();

        $this->releaseChecker->checkScripts($scripts, $rollbacks);

        foreach ($scripts as $k => $script) {
            $this->createMigration($script, $rollbacks[$k]);
        }
    }
195894
def print_new(ctx, name, migration_type):
    """"""
    click.echo(ctx.obj.repository.generate_migration_name(name, migration_type))
1254820
def migrate(ctx, start_version, end_version):
    """"""
    if ctx.type == 'file':
        if ctx.data_file:
            file_path = ctx.data_file
        else:
            file_path = os.path.join(ctx.data_file, ctx.namespace + '.json')

        # todo make this more like alemebic and determine/load versions automatically
        with open(file_path, 'r') as f:
            data = json.loads(f.read())

        data = run_migration(data, start_version, end_version)
        with open(file_path, 'w') as f:
            f.write(json.dumps(data))
962109
protected function createMigration()
    {
        $migrationFile = base_path("/database/migrations") . "/" . date('Y_m_d_His')
            . "_create_settings_table.php";

        $output = $this->laravel->view->make('settings::generators.migration')->render();

        if (!file_exists($migrationFile) && $fs = fopen($migrationFile, 'x')) {
            fwrite($fs, $output);
            fclose($fs);

            return true;
        }

        return false;
    }
506918
protected function createMigration()
    {
        $table = Str::plural(Str::snake(class_basename($this->argument('name'))));

        if ($this->option('pivot')) {
            $table = Str::singular($table);
        }

        $this->call('make:migration', [
            'name' => "create_{$table}_table",
            '--create' => $table,
        ]);
    }
570835
public function generateMigration(): string
    {
        return $this->view->renderFile(Yii::getAlias($this->templateFile), [
            'table' => $this->table,
            'className' => $this->className,
            'namespace' => $this->normalizedNamespace
        ]);
    }