interactive_migrations 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,11 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = "interactive_migrations"
|
3
|
+
s.version = '0.0.2'
|
4
|
+
s.authors = ["James Tippett"]
|
5
|
+
s.email = ["hi@jamestippett.com"]
|
6
|
+
|
7
|
+
s.summary = "A rake task giving you interactive migrations in your rails 3 project"
|
8
|
+
s.description = "If your rails project has migrations, you are prompted to run each one, with a printout of the code which will be run. You have the option of running or skipping the migration. Useful for production deploys where migrations are a delicate task. Extracted from a large production web app."
|
9
|
+
s.homepage = "http://github.com/jtippett/interactive_migrations"
|
10
|
+
s.files = `git ls-files`.split("\n")
|
11
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
namespace :db do
|
2
|
+
namespace :migrate do
|
3
|
+
|
4
|
+
desc "Migrate Interactively"
|
5
|
+
task :interactive => :environment do
|
6
|
+
pending_migrations = ActiveRecord::Migrator.new(:up, 'db/migrate').pending_migrations
|
7
|
+
|
8
|
+
logger = Logger.new(Rails.root.join('log', 'migrations.log'))
|
9
|
+
|
10
|
+
if pending_migrations.any?
|
11
|
+
changed = false
|
12
|
+
puts "You have #{pending_migrations.size} pending migrations:"
|
13
|
+
pending_migrations.each do |pending_migration|
|
14
|
+
puts '--------------------------------'
|
15
|
+
puts '%4d %s' % [pending_migration.version, pending_migration.name]
|
16
|
+
puts '--------------------------------'
|
17
|
+
file = Rails.root.join pending_migration.filename
|
18
|
+
puts File.read(file)
|
19
|
+
puts '--------------------------------'
|
20
|
+
if agree("run this migration? y/n")
|
21
|
+
begin
|
22
|
+
time = Benchmark.measure { ActiveRecord::Migrator.run(:up, "db/migrate/", pending_migration.version) }
|
23
|
+
logger.info ('== %4d %s ' % [pending_migration.version, pending_migration.name]).ljust(100, '=') + "\n"
|
24
|
+
logger.info File.read(file)
|
25
|
+
logger.info ('== Migrated in %.4fs ' % time.real).ljust(100, '=') + "\n"
|
26
|
+
changed = true
|
27
|
+
rescue Exception => e
|
28
|
+
puts "Migration #{pending_migration.version} failed or was cancelled and returned this message:"
|
29
|
+
puts e
|
30
|
+
puts "Continuing.."
|
31
|
+
end
|
32
|
+
else
|
33
|
+
puts "skipping #{pending_migration.name}.\n"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
if changed
|
37
|
+
if agree("You have performed one or more migrations. Rewrite schema.rb? y/n")
|
38
|
+
Rake::Task["db:schema:dump"].invoke
|
39
|
+
end
|
40
|
+
end
|
41
|
+
puts "done, with #{ActiveRecord::Migrator.new(:up, 'db/migrate').pending_migrations.size} further migrations pending"
|
42
|
+
else
|
43
|
+
puts "no migrations pending."
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end # :migration
|
48
|
+
end # :db
|
metadata
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: interactive_migrations
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- James Tippett
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-09-20 00:00:00.000000000Z
|
13
|
+
dependencies: []
|
14
|
+
description: If your rails project has migrations, you are prompted to run each one,
|
15
|
+
with a printout of the code which will be run. You have the option of running or
|
16
|
+
skipping the migration. Useful for production deploys where migrations are a delicate
|
17
|
+
task. Extracted from a large production web app.
|
18
|
+
email:
|
19
|
+
- hi@jamestippett.com
|
20
|
+
executables: []
|
21
|
+
extensions: []
|
22
|
+
extra_rdoc_files: []
|
23
|
+
files:
|
24
|
+
- interactive_migrations.gemspec
|
25
|
+
- lib/interactive_migrations.rb
|
26
|
+
- lib/interactive_migrations/railtie.rb
|
27
|
+
- lib/tasks/interactive_migrations.rake
|
28
|
+
homepage: http://github.com/jtippett/interactive_migrations
|
29
|
+
licenses: []
|
30
|
+
post_install_message:
|
31
|
+
rdoc_options: []
|
32
|
+
require_paths:
|
33
|
+
- lib
|
34
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
35
|
+
none: false
|
36
|
+
requirements:
|
37
|
+
- - ! '>='
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
requirements: []
|
47
|
+
rubyforge_project:
|
48
|
+
rubygems_version: 1.8.10
|
49
|
+
signing_key:
|
50
|
+
specification_version: 3
|
51
|
+
summary: A rake task giving you interactive migrations in your rails 3 project
|
52
|
+
test_files: []
|