---
title: "load migrate file and load"
author: "夜鸣猪"
date: "2013-03-22T05:52:46Z"
tags: []
categories: ["编程语言"]
slug: "load-migrate-file-and-load"
draft: false
lastmod: "2013-03-22T05:52:46Z"
id: 1833831
url: "https://hlee.iteye.com/blog/1833831"
---

```java

Dir[rails.root.join('db','migrate','*.rb')].each{|file|require file}

Dir[file.dirname(__file__) + '/../lib/*.rb'].each do |file| 
  require File.basename(file, File.extname(file))
end


rails console
>> require "db/migrate/20090408054532_add_foos.rb"
>> AddFoos.up


script/runner 'require("db/migrate/20090408054532_add_foos.rb").first.constantize.up'


rake db:migrate:up VERSION=20090408054532

```