standalone_migrations 0.1.1 → 0.1.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.
data/README.markdown CHANGED
@@ -1,17 +1,16 @@
1
1
  Rails migrations in non-Rails (and non Ruby) projects.
2
- For this code to work you need Ruby, Gems, ActiveRecord, Rake and a suitable database driver installed.
3
2
 
4
3
  USAGE
5
4
  =====
6
- Install Ruby, RubyGems then:
5
+ Install Ruby, RubyGems and a ruby-database driver (e.g. `gem install mysql`) then:
7
6
  sudo gem install standalone_migrations
8
7
 
9
8
  Add to `Rakefile` in your projects base directory:
10
9
  begin
11
10
  require 'standalone_migrations'
12
11
  StandaloneMigrations.tasks
13
- rescue LoadError
14
- puts 'gem install standalone_migrations to get db:migrate:* tasks!'
12
+ rescue LoadError => e
13
+ puts "gem install standalone_migrations to get db:migrate:* tasks! (Error: #{e})"
15
14
  end
16
15
 
17
16
  Add database configuration to `config/database.yml` in your projects base directory e.g.:
@@ -28,38 +27,43 @@ Add database configuration to `config/database.yml` in your projects base direct
28
27
  test:
29
28
  ...something similar...
30
29
 
31
- To create a new database migration run:
30
+ ### To create a new database migration:
32
31
 
33
32
  rake db:new_migration name=FooBarMigration
34
33
  edit migrations/20081220234130_foo_bar_migration.rb
35
34
 
36
- and fill in the up and down migrations. To apply your newest migration
35
+ ... and fill in the up and down migrations [Cheatsheet](http://dizzy.co.uk/ruby_on_rails/cheatsheets/rails-migrations).
36
+
37
+ If you're lazy and want to just execute raw SQL:
38
+
39
+ def self.up
40
+ execute "insert into foo values (123,'something');"
41
+ end
42
+
43
+ def self.down
44
+ execute "delete from foo where field='something';"
45
+ end
46
+
47
+ ### To apply your newest migration:
37
48
 
38
49
  rake db:migrate
39
50
 
40
- To migrate to a specific version (for example to rollback)
51
+ ### To migrate to a specific version (for example to rollback)
41
52
 
42
53
  rake db:migrate VERSION=20081220234130
43
54
 
44
- To migrate a specific database (for example your "testing" database)
55
+ ### To migrate a specific database (for example your "testing" database)
45
56
 
46
57
  rake db:migrate RAILS_ENV=test
47
58
 
48
- CREDIT
49
- ======
50
- This work is based on Lincoln Stoll's blog post: http://lstoll.net/2008/04/stand-alone-activerecord-migrations/
51
- and David Welton's post http://journal.dedasys.com/2007/01/28/using-migrations-outside-of-rails
59
+ ### To execute a specific up/down of one single migration
52
60
 
53
- FURTHER HELP
54
- ============
55
- A good source to learn how to use migrations is:
56
- http://dizzy.co.uk/ruby_on_rails/cheatsheets/rails-migrations
57
- or if you're lazy and want to just execute raw SQL
61
+ rake db:migrate:up VERSION=20081220234130
58
62
 
59
- def self.up
60
- execute "insert into foo values (123,'something');"
61
- end
63
+ Contributors
64
+ ============
65
+ This work is based on [Lincoln Stoll's blog post](http://lstoll.net/2008/04/stand-alone-activerecord-migrations/) and [David Welton's post](http://journal.dedasys.com/2007/01/28/using-migrations-outside-of-rails).
62
66
 
63
- def self.down
64
- execute "delete from foo where field='something';"
65
- end
67
+ - [Todd Huss](http://gabrito.com/)
68
+ - [Steve Hodgkiss](http://stevehodgkiss.com/)`s [activerecord-migrator-standalone](http://github.com/stevehodgkiss/activerecord-migrator-standalone)
69
+ - [Michael Grosser](http://pragmatig.wordpress.com)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{standalone_migrations}
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Michael Grosser"]
12
- s.date = %q{2010-03-15}
12
+ s.date = %q{2010-03-16}
13
13
  s.email = %q{grosser.michael@gmail.com}
14
14
  s.extra_rdoc_files = [
15
15
  "README.markdown"
@@ -1,4 +1,5 @@
1
1
  APP_BASE = File.expand_path('.') unless defined? APP_BASE
2
+ MIGRATIONS_DIR = APP_BASE + "/migrations/"
2
3
 
3
4
  # Add to load_path every "lib/" directory in vendor
4
5
  Dir["#{File.dirname(__FILE__)}/../vendor/**/lib"].each { |p| $LOAD_PATH << p }
@@ -18,10 +19,28 @@ namespace :db do
18
19
  task :migrate => :ar_init do
19
20
  require "#{File.dirname(__FILE__)}/../vendor/migration_helpers/init"
20
21
  ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
21
- ActiveRecord::Migrator.migrate(APP_BASE + "/migrations/", ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
22
+ ActiveRecord::Migrator.migrate(MIGRATIONS_DIR, ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
22
23
  Rake::Task[ "db:schema:dump" ].execute
23
24
  end
24
25
 
26
+ namespace :migrate do
27
+ desc 'Runs the "up" for a given migration VERSION.'
28
+ task :up => :ar_init do
29
+ version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil
30
+ raise "VERSION is required" unless version
31
+ ActiveRecord::Migrator.run(:up, MIGRATIONS_DIR, version)
32
+ Rake::Task["db:schema:dump"].execute
33
+ end
34
+
35
+ desc 'Runs the "down" for a given migration VERSION.'
36
+ task :down => :ar_init do
37
+ version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil
38
+ raise "VERSION is required" unless version
39
+ ActiveRecord::Migrator.run(:down, MIGRATIONS_DIR, version)
40
+ Rake::Task["db:schema:dump"].execute
41
+ end
42
+ end
43
+
25
44
  namespace :schema do
26
45
  desc "Create schema.rb file that can be portably used against any DB supported by AR"
27
46
  task :dump => :ar_init do
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 1
9
- version: 0.1.1
8
+ - 2
9
+ version: 0.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Michael Grosser
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-03-15 00:00:00 +01:00
17
+ date: 2010-03-16 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency