better_migrations 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ pkg
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 [name of plugin creator]
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,26 @@
1
+ h1. Better migrations
2
+
3
+ h2. Installation
4
+
5
+ <code>
6
+ sudo gem install better_migrations
7
+ </code>
8
+
9
+ Create a rake task in @lib/tasks/better_migrations.rake@ (there will be a generator for that):
10
+
11
+ <code>
12
+ require 'rubygems'
13
+ require 'better_migrations/tasks'
14
+ </code>
15
+
16
+ h2. Undoing migrations
17
+
18
+ Run @rake db:migrate:undo@ and select a migration to undo.
19
+
20
+ h2. Applying migrations
21
+
22
+ Run @rake db:migrate:do@ and select a migration to apply.
23
+
24
+ -------------------------------------------
25
+
26
+ Copyright (c) 2009 Christopher Hlubek - resoap software applications, released under the MIT license
@@ -0,0 +1,40 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/rdoctask'
4
+
5
+ require 'lib/better_migrations/tasks'
6
+
7
+ desc 'Default: run unit tests.'
8
+ task :default => :test
9
+
10
+ desc 'Test the better_migrations plugin.'
11
+ Rake::TestTask.new(:test) do |t|
12
+ t.libs << 'lib'
13
+ t.libs << 'test'
14
+ t.pattern = 'test/**/*_test.rb'
15
+ t.verbose = true
16
+ end
17
+
18
+ desc 'Generate documentation for the better_migrations plugin.'
19
+ Rake::RDocTask.new(:rdoc) do |rdoc|
20
+ rdoc.rdoc_dir = 'rdoc'
21
+ rdoc.title = 'BetterMigrations'
22
+ rdoc.options << '--line-numbers' << '--inline-source'
23
+ rdoc.rdoc_files.include('README')
24
+ rdoc.rdoc_files.include('lib/**/*.rb')
25
+ end
26
+
27
+ begin
28
+ require 'jeweler'
29
+ Jeweler::Tasks.new do |gemspec|
30
+ gemspec.name = "better_migrations"
31
+ gemspec.summary = "Better migrations for rails"
32
+ gemspec.description = "Better migration rake tasks for undo / doing specific migrations"
33
+ gemspec.email = "hlubek@resoap.com"
34
+ gemspec.homepage = "http://github.com/chlu/better_migrations"
35
+ gemspec.authors = ["Christopher Hlubek"]
36
+ end
37
+ Jeweler::GemcutterTasks.new
38
+ rescue LoadError
39
+ # puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
40
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.2
@@ -0,0 +1,53 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{better_migrations}
8
+ s.version = "1.0.2"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Christopher Hlubek"]
12
+ s.date = %q{2009-10-07}
13
+ s.description = %q{Better migration rake tasks for undo / doing specific migrations}
14
+ s.email = %q{hlubek@resoap.com}
15
+ s.extra_rdoc_files = [
16
+ "README.textile"
17
+ ]
18
+ s.files = [
19
+ ".gitignore",
20
+ "MIT-LICENSE",
21
+ "README.textile",
22
+ "Rakefile",
23
+ "VERSION",
24
+ "better_migrations.gemspec",
25
+ "install.rb",
26
+ "lib/better_migrations.rb",
27
+ "lib/better_migrations/tasks.rb",
28
+ "rails/init.rb",
29
+ "tasks/better_migrations.rake",
30
+ "test/better_migrations_test.rb",
31
+ "test/test_helper.rb",
32
+ "uninstall.rb"
33
+ ]
34
+ s.homepage = %q{http://github.com/chlu/better_migrations}
35
+ s.rdoc_options = ["--charset=UTF-8"]
36
+ s.require_paths = ["lib"]
37
+ s.rubygems_version = %q{1.3.3}
38
+ s.summary = %q{Better migrations for rails}
39
+ s.test_files = [
40
+ "test/better_migrations_test.rb",
41
+ "test/test_helper.rb"
42
+ ]
43
+
44
+ if s.respond_to? :specification_version then
45
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
46
+ s.specification_version = 3
47
+
48
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
49
+ else
50
+ end
51
+ else
52
+ end
53
+ end
@@ -0,0 +1 @@
1
+ # Install hook code here
@@ -0,0 +1,19 @@
1
+ module BetterMigrations
2
+ class Migrator
3
+ def self.applied_migrations
4
+ migrator = ActiveRecord::Migrator.new(:down, 'db/migrate')
5
+ applied_migrations = (migrator.migrations - migrator.pending_migrations)
6
+ end
7
+ def self.pending_migrations
8
+ migrator = ActiveRecord::Migrator.new(:up, 'db/migrate')
9
+ migrator.pending_migrations
10
+ end
11
+ end
12
+ class Utils
13
+ def self.list_migrations(migrations)
14
+ migrations.each_with_index do |migration, index|
15
+ puts "[\033[0;1m\t#{index + 1}\033[0m] #{migration.name} \033[36m#{migration.version}\033[0m"
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,56 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'better_migrations'))
2
+
3
+ namespace :db do
4
+ namespace :migrate do
5
+ desc 'Undo a migration (down) by selecting a specific version'
6
+ task :undo => :environment do
7
+ version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil
8
+
9
+ unless version
10
+ # puts "\033[0;1mCurrent Version:\033[0m \033[32m#{ActiveRecord::Migrator.current_version}\033[0m"
11
+ applied_migrations = BetterMigrations::Migrator.applied_migrations
12
+ raise "-> \033[33mNo applied migrations found.\033[0m" if applied_migrations.empty?
13
+ puts "\033[0;1mApplied migrations:\033[0m"
14
+ BetterMigrations::Utils.list_migrations applied_migrations
15
+
16
+ print "Enter migration number to undo (x to cancel): "
17
+
18
+ answer = STDIN.gets.chomp
19
+ raise "-> \033[33mcancelled\033[0m" if answer == 'x'
20
+ migration_index = answer.to_i - 1
21
+ raise "Invalid number: #{migration_index}" unless (0..applied_migrations.length) === migration_index
22
+
23
+ version = applied_migrations[migration_index].version
24
+ end
25
+
26
+ raise "Specify VERSION" unless version
27
+ ActiveRecord::Migrator.run(:down, "db/migrate/", version)
28
+ Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby
29
+ end
30
+ desc 'Do a migration (up) by selecting a specific version'
31
+ task :do => :environment do
32
+ version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil
33
+
34
+ unless version
35
+ # puts "\033[0;1mCurrent Version:\033[0m \033[32m#{ActiveRecord::Migrator.current_version}\033[0m"
36
+ pending_migrations = BetterMigrations::Migrator.pending_migrations
37
+ raise "-> \033[33mNo pending migrations found.\033[0m" if pending_migrations.empty?
38
+ puts "\033[0;1mPending migrations:\033[0m"
39
+ BetterMigrations::Utils.list_migrations pending_migrations
40
+
41
+ print "Enter migration number to apply (x to cancel): "
42
+
43
+ answer = STDIN.gets.chomp
44
+ raise "-> \033[33mcancelled\033[0m" if answer == 'x'
45
+ migration_index = answer.to_i - 1
46
+ raise "Invalid number: #{migration_index}" unless (0..pending_migrations.length) === migration_index
47
+
48
+ version = pending_migrations[migration_index].version
49
+ end
50
+
51
+ raise "Specify VERSION" unless version
52
+ ActiveRecord::Migrator.run(:up, "db/migrate/", version)
53
+ Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby
54
+ end
55
+ end
56
+ end
@@ -0,0 +1 @@
1
+ # Include hook code here
@@ -0,0 +1 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'better_migrations', 'tasks'))
@@ -0,0 +1,8 @@
1
+ require 'test_helper'
2
+
3
+ class BetterMigrationsTest < ActiveSupport::TestCase
4
+ # Replace this with your real tests.
5
+ test "the truth" do
6
+ assert true
7
+ end
8
+ end
@@ -0,0 +1,3 @@
1
+ require 'rubygems'
2
+ require 'active_support'
3
+ require 'active_support/test_case'
@@ -0,0 +1 @@
1
+ # Uninstall hook code here
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: better_migrations
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Christopher Hlubek
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-10-07 00:00:00 +02:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Better migration rake tasks for undo / doing specific migrations
17
+ email: hlubek@resoap.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README.textile
24
+ files:
25
+ - .gitignore
26
+ - MIT-LICENSE
27
+ - README.textile
28
+ - Rakefile
29
+ - VERSION
30
+ - better_migrations.gemspec
31
+ - install.rb
32
+ - lib/better_migrations.rb
33
+ - lib/better_migrations/tasks.rb
34
+ - rails/init.rb
35
+ - tasks/better_migrations.rake
36
+ - test/better_migrations_test.rb
37
+ - test/test_helper.rb
38
+ - uninstall.rb
39
+ has_rdoc: true
40
+ homepage: http://github.com/chlu/better_migrations
41
+ licenses: []
42
+
43
+ post_install_message:
44
+ rdoc_options:
45
+ - --charset=UTF-8
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: "0"
53
+ version:
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: "0"
59
+ version:
60
+ requirements: []
61
+
62
+ rubyforge_project:
63
+ rubygems_version: 1.3.3
64
+ signing_key:
65
+ specification_version: 3
66
+ summary: Better migrations for rails
67
+ test_files:
68
+ - test/better_migrations_test.rb
69
+ - test/test_helper.rb