Create a migration file for the model.
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,
        ]);
    }
1089466
def migration_creatr(migration_file, create, table):
    """"""
    if not check():
        click.echo(Fore.RED + 'ERROR: Ensure you are in a bast app to run the create:migration command')
        return

    migration = CreateMigration()
    if table is None:
        table = snake_case(migration_file)
    file = migration.create_file(snake_case(migration_file), table=table, create=create)
    click.echo(Fore.GREEN + 'Migration file created at %s' % file)
1162164
protected function createMigrations()
    {
        file_put_contents(
            $this->createUsersVerificationsMigration(),
            file_get_contents(__DIR__.'/stubs/migrations/users_verifications.stub')
        );

        file_put_contents(
            $this->createUsersMigration(),
            file_get_contents(__DIR__.'/stubs/migrations/users.stub')
        );

        $this->info('Migrations created successfully!');
    }
218322
protected function writeMigrations()
    {
        $files = $this->migrator->create($this->options);

        foreach ($files as $file) {
            $path = pathinfo($file, PATHINFO_FILENAME);
            $this->line("      <fg=green;options=bold>create</fg=green;options=bold>  $path");
        }

        $this->composer->dumpAutoloads();
    }
190877
def load_migration_file(self, filename):
        """"""
        path = os.path.join(self.directory, filename)
        # spec = spec_from_file_location("migration", path)
        # module = module_from_spec(spec)
        # spec.loader.exec_module(module)
        module = imp.load_source("migration", path)
        return module
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) : '';
    }
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))
1336888
def create_migration_template(name):
    
    assert name, 'Name of the migration can not be empty.'
    from . import migrations

    # Find next number
    #
    package = migrations
    prefix = package.__name__ + '.'
    all_versions = []
    for importer, modname, ispkg in pkgutil.iter_modules(package.__path__, prefix):
        version = int(modname.split('.')[-1].split('_')[0])
        all_versions.append(version)

    next_number = max(all_versions) + 1

    # Generate next migration name
    #
    next_migration_name = '{}_{}.py'.format(next_number, name)
    migration_fullname = os.path.join(package.__path__[0], next_migration_name)

    # Write next migration file content.
    #
    with open(migration_fullname, 'w') as f:
        f.write(MIGRATION_TEMPLATE)
    return migration_fullname
742066
public function up()
    {
        // Check if the images table exists
        if (Schema::hasTable('images')) {
            if (Schema::hasColumn('images', 'imageable_type')) {
                $images = DB::select('select * from images');
                foreach ($images as $image) {
                    // Get the model name
                    $new_type_array = explode('\\', $image->imageable_type);
                    $last_model = array_pop($new_type_array);
                    
                    // Move image to new folder
                    $image_folder = Config::get('redminportal::image.upload_dir');
                    
                    switch ($last_model) {
                        case 'Category':
                            $move_file = $this->moveFileNewToOld($image_folder, $image, 'categories');
                            break;
                        case 'Media':
                            $move_file = $this->moveFileNewToOld($image_folder, $image, 'medias');
                            break;
                        case 'Module':
                            $move_file = $this->moveFileNewToOld($image_folder, $image, 'modules');
                            break;
                        case 'Promotion':
                            $move_file = $this->moveFileNewToOld($image_folder, $image, 'promotions');
                            break;
                        default:
                            $move_file = false;
                            break;
                    }
                    
                    // Create dimensions
                    if ($move_file) {
                        $img_helper = new RImage;
                        $img_helper->createDimensions($move_file);
                    }
                    
                    // Points to new namespace Redooor\\Redminportal\\App\\Models\\
                    $new_type = 'Redooor\\Redminportal\\App\\Models\\' . $last_model;
                    DB::table('images')
                        ->where('id', $image->id)
                        ->update([
                            'imageable_type' => $new_type,
                            'path' => ($move_file ? $move_file : $image->path)
                        ]);
                }
            }
        }
    }
1238221
public function migrateFiles()
    {
        $fileResources = $this->getFileResourceData();

        foreach ($fileResources as $fileResourceData) {
            $resourceUri = $fileResourceData['fileResource']->getUri();
            if (!isset($fileResourceData['property'])) {
                $this->failedResources[$resourceUri][] = 'Unable to find property';
                continue;
            }
            if (!isset($fileResourceData['subject'])) {
                $this->failedResources[$resourceUri][] = 'Unable to find subject';
                continue;
            }

            ++$this->migrationInformation['old_resource_count'];
            $this->migrateResource(
                $fileResourceData['fileResource'], $fileResourceData['property'], $fileResourceData['subject']
            );
        }
    }
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);
    }
1215280
def create_new_migration_record(self):
        
        migration_record = self.migration_model(
            name=self.name,
            version=self.latest_migration)
        self.session.add(migration_record)
        self.session.commit()
256617
def create(*catalog_roots)
      fs = [@db_filepath, @db_log_filepath, @config_filepath]
      fs.each do |f|
        FileUtils.rm(f) if File.exist?(f)
      end

      if File.exist? @config_filepath
        raise SimpleCatalogerError, "cannot create already existent catalog '#{@name}'"
      end
      @config = {
          :roots   => catalog_roots,
          :ignore  => %w{sub subtitles images},
          :version => DirCat::VERSION
      }
      write_config

      #
      # migrate db
      #
      # TODO: drop tables!
      ActiveRecord::Base.establish_connection(@active_record_config)
      ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : false
      migration_dir = File.join(File.dirname(__FILE__), %w{migration})
      unless Dir.exist? migration_dir
        raise "migration dir '#{migration_dir}' not exists"
      end
      ActiveRecord::Migrator.migrate(migration_dir, ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
      require_models
    end
1281201
def create_migration
      migration_version = Time.now.to_i
      dir = "/db/migrate/#{migration_version}_create_#{@scaffold_name}s.rb"
      unless File.exists?(File.join(Dir.pwd,dir))
        source = "#{@gem_path}/lib/modules/scaffold/migration.rb"
        FileUtils.cp(source,File.join(Dir.pwd,dir))
        config_migration(migration_version)
        $stdout.puts "\e[1;32m \tcreate\e[0m\t#{dir}"
      end
    end
53113
def new_file(self, path: str, checksum: str=None, to_archive: bool=False,
                 tags: List[models.Tag]=None) -> models.File:
        """"""
        new_file = self.File(path=path, checksum=checksum, to_archive=to_archive, tags=tags)
        return new_file
801588
def migration(resource, version, previous_version=''):
    """"""
    def decorator(func):
        @wraps(func)
        def wrapper(*args, **kwargs):
            migrated = func(*args, **kwargs)

            return migrated

        m = Migration(wrapper, resource, version, previous_version)
        m.register()

        return m

    return decorator
979444
protected function createModel()
	{
		$name = str_singular( $this->name );
		$tmpl = file_get_contents( __DIR__ . "/Model.tmpl" );
		$tmpl = str_replace( [ '{{NAME}}', '{{NAMESPACE}}' ], [ $name, $this->namespace ], $tmpl );
		$path = app_path( "Models/{$name}.php" );
		if( ! file_exists( $path ) ) {
			file_put_contents( $path, $tmpl );
		}
	}