Created
January 23, 2013 06:22
-
-
Save ktkaushik/4602563 to your computer and use it in GitHub Desktop.
migration_template source code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def migration_template(source, destination=nil, config={}) | |
| destination = File.expand_path(destination || source, self.destination_root) | |
| migration_dir = File.dirname(destination) | |
| @migration_number = self.class.next_migration_number(migration_dir) | |
| @migration_file_name = File.basename(destination).sub(/\.rb$/, '') | |
| @migration_class_name = @migration_file_name.camelize | |
| destination = self.class.migration_exists?(migration_dir, @migration_file_name) | |
| if !(destination && options[:skip]) && behavior == :invoke | |
| if destination && options.force? | |
| remove_file(destination) | |
| elsif destination | |
| raise Error, "Another migration is already named #{@migration_file_name}: #{destination}" | |
| end | |
| destination = File.join(migration_dir, "#{@migration_number}_#{@migration_file_name}.rb") | |
| end | |
| template(source, destination, config) | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment