active_record_migrations 4.0.0.1 → 4.0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cf33226909efd3e751235683e135cb4be1e21429
4
- data.tar.gz: 7b53898aeb54800aa143b2aeb87b382b8332a9cf
3
+ metadata.gz: 655161c611f3a9f7c93e18b12292d40625590f0d
4
+ data.tar.gz: e29d6f4e20a8870c291875fd41bb687b1324c28f
5
5
  SHA512:
6
- metadata.gz: 484d935fd8708ab1d067f376e6b0c8a03d30ae641f3abdde7505b67bd635622c5cf0985d3b865c24f7d1ca2fccbdde826aa337064f4594ec04f4e1fbca4dbc2c
7
- data.tar.gz: 4d9523e66f9190c893ce5aa5df2bcda2caa648a39a123d04fdb26cb1b673f2f9339609e981b6525d957648d7b47e1ceb4a5e775a266b22f60bc3cfce2524dcae
6
+ metadata.gz: e1cc63493dfecb61cdea12cc5c99552460f9d24199b5ae1bd3b30c03fb77ac032ea119782d8dbbecee881fe313638123a47e5949048db96d779f5c501a9bfcce
7
+ data.tar.gz: c1c16b583be55e32cd251d2e920ebc4a07d82290c992f78306d9ea888937716a2fbd0ea8ebd1424ef1e083457c3b1398909611cd04a08637f7e53a278794382e
data/README.md CHANGED
@@ -23,6 +23,7 @@ Create a Rakefile:
23
23
  By default, your database configurations will be read from `db/config.yml` and your migration files
24
24
  will be created under `db/migrate`. If you want to keep with the defaults, create your `db/config.yml`:
25
25
 
26
+ ```yaml
26
27
  development:
27
28
  adapter: postgresql
28
29
  database: my_db
@@ -36,21 +37,24 @@ will be created under `db/migrate`. If you want to keep with the defaults, creat
36
37
  database: db/test.sqlite3
37
38
  pool: 5
38
39
  timeout: 5000
39
-
40
- If you prefer to specify your settings in plain Ruby, add this to your Rakefile:
41
-
42
- ```ruby
43
- ActiveRecordMigrations.configure do |c|
44
- c.database_configuration = {
45
- 'development' => {'adapter' => 'sqlite3', 'database' => 'db/custom.sqlite3'},
46
- }
47
- # Other settings:
48
- c.schema_format = :sql # default is :ruby
49
- # c.yaml_config = 'db/config.yml'
50
- # c.environment = ENV['db']
51
- # c.db_dir = 'db'
52
- end
53
- ```
40
+ ```
41
+
42
+ If you prefer to specify your settings in plain Ruby, add this to your Rakefile,
43
+ before calling `ActiveRecordMigrations.load_taks`:
44
+
45
+ ```ruby
46
+ ActiveRecordMigrations.configure do |c|
47
+ c.database_configuration = {
48
+ 'development' => {'adapter' => 'sqlite3', 'database' => 'db/custom.sqlite3'},
49
+ }
50
+ # Other settings:
51
+ c.schema_format = :sql # default is :ruby
52
+ # c.yaml_config = 'db/config.yml'
53
+ # c.environment = ENV['db']
54
+ # c.db_dir = 'db'
55
+ # c.migrations_paths = ['db/migrate'] # the first entry will be used by the generator
56
+ end
57
+ ```
54
58
 
55
59
  Take a look at the [Migrations Guide](http://guides.rubyonrails.org/migrations.html) for more details.
56
60
 
@@ -20,7 +20,13 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.3"
22
22
  spec.add_dependency "rake"
23
- spec.add_dependency "railties", "~> 4.0.0"
24
- spec.add_dependency "activerecord", "~> 4.0.0"
23
+ # spec.add_dependency "railties", "~> 4.0.0"
24
+ # spec.add_dependency "activerecord", "~> 4.0.0"
25
+ # We rely on a kind of monkey patch for allowing us to override the migrations path.
26
+ # So it's better to fix on an specific version of AR and check if the override of
27
+ # ActiveRecord::Generators::MigrationGenerator#create_migration_file is correct
28
+ # before upgrading AR dependency. See ARM::Generators::MigrationGenerator impl.
29
+ spec.add_dependency "railties", "4.0.0"
30
+ spec.add_dependency "activerecord", "4.0.0"
25
31
  end
26
32
 
@@ -1,7 +1,7 @@
1
1
  require "active_record_migrations/version"
2
2
  require 'active_record'
3
3
  require 'active_record/tasks/database_tasks'
4
- require 'active_record/railtie'
4
+ require 'rails'
5
5
  require 'rails/application'
6
6
  require_relative 'active_record_migrations/configurations'
7
7
 
@@ -16,7 +16,7 @@ module ActiveRecordMigrations
16
16
  def self.load_tasks
17
17
  create_rails_app_if_not_exists
18
18
 
19
- ActiveRecord::Railtie.run_tasks_blocks Rails.application
19
+ load "active_record/railties/databases.rake"
20
20
  load 'active_record_migrations/tasks/new_migration.rake'
21
21
 
22
22
  ActiveRecord::Base.schema_format = configurations.schema_format
@@ -26,6 +26,7 @@ module ActiveRecordMigrations
26
26
  configurations.database_configuration
27
27
  DatabaseTasks.current_config = configurations.database_configuration[configurations.environment]
28
28
  DatabaseTasks.db_dir = configurations.db_dir
29
+ DatabaseTasks.migrations_paths = configurations.migrations_paths
29
30
  end
30
31
 
31
32
  private
@@ -5,12 +5,13 @@ module ActiveRecordMigrations
5
5
  class Configurations
6
6
  include Singleton
7
7
 
8
- attr_accessor :yaml_config, :database_configuration, :environment, :db_dir, :schema_format, :seed_loader
8
+ attr_accessor :yaml_config, :database_configuration, :environment, :db_dir, :migrations_paths, :schema_format, :seed_loader
9
9
 
10
10
  def initialize
11
11
  @yaml_config = 'db/config.yml'
12
12
  @environment = ENV['db'] || Rails.env
13
13
  @db_dir = 'db'
14
+ @migrations_paths = ['db/migrate']
14
15
  @schema_format = :ruby # or :sql
15
16
  @seed_loader = Rails.application
16
17
  end
@@ -0,0 +1,18 @@
1
+ require 'rails/generators/active_record/migration/migration_generator'
2
+ require 'active_record/tasks/database_tasks'
3
+
4
+ module ActiveRecordMigrations
5
+ module Generators
6
+ class MigrationGenerator < ::ActiveRecord::Generators::MigrationGenerator
7
+ source_root ::ActiveRecord::Generators::MigrationGenerator.source_root
8
+
9
+ def create_migration_file
10
+ set_local_assigns!
11
+ validate_file_name!
12
+ dir = ::ActiveRecord::Tasks::DatabaseTasks.migrations_paths.first
13
+ migration_template @migration_template, "#{dir}/#{file_name}.rb"
14
+ end
15
+ end
16
+ end
17
+ end
18
+
@@ -2,16 +2,13 @@ require 'rails/generators'
2
2
  require 'active_record'
3
3
  require 'active_record/tasks/database_tasks'
4
4
  require 'active_record_migrations/configurations'
5
-
6
- Rake::Task['db:load_config'].clear
5
+ require 'active_record_migrations/generators/migration'
7
6
 
8
7
  task environment: 'db:load_config' do
9
8
  ActiveRecord::Base.establish_connection ActiveRecord::Tasks::DatabaseTasks.current_config
10
9
  end
11
10
 
12
11
  namespace :db do
13
- task(:load_config){} # db tasks depend on load_config
14
-
15
12
  desc "Creates a new migration file with the specified name"
16
13
  task :new_migration, :name, :options do |t, args|
17
14
  name = args[:name] || ENV['name']
@@ -29,7 +26,9 @@ namespace :db do
29
26
  end
30
27
  params = [name]
31
28
  params.concat options.split(' ') if options
32
- Rails::Generators.invoke "active_record:migration", params, behavior: :invoke, destination_root: Rails.root
29
+ #Rails::Generators.invoke "active_record:migration", params,
30
+ Rails::Generators.invoke "active_record_migrations:migration", params,
31
+ behavior: :invoke, destination_root: Rails.root
33
32
  end
34
33
  end
35
34
 
@@ -1,3 +1,3 @@
1
1
  module ActiveRecordMigrations
2
- VERSION = "4.0.0.1"
2
+ VERSION = "4.0.0.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_record_migrations
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0.1
4
+ version: 4.0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rodrigo Rosenfeld Rosas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-19 00:00:00.000000000 Z
11
+ date: 2013-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -42,28 +42,28 @@ dependencies:
42
42
  name: railties
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - '='
46
46
  - !ruby/object:Gem::Version
47
47
  version: 4.0.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - '='
53
53
  - !ruby/object:Gem::Version
54
54
  version: 4.0.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: activerecord
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - '='
60
60
  - !ruby/object:Gem::Version
61
61
  version: 4.0.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - '='
67
67
  - !ruby/object:Gem::Version
68
68
  version: 4.0.0
69
69
  description: ActiveRecord Stand-alone migrations
@@ -81,6 +81,7 @@ files:
81
81
  - active_record_migrations.gemspec
82
82
  - lib/active_record_migrations.rb
83
83
  - lib/active_record_migrations/configurations.rb
84
+ - lib/active_record_migrations/generators/migration.rb
84
85
  - lib/active_record_migrations/tasks/new_migration.rake
85
86
  - lib/active_record_migrations/version.rb
86
87
  homepage: http://github.com/rosenfeld/active_record_migrations
@@ -103,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
104
  version: '0'
104
105
  requirements: []
105
106
  rubyforge_project:
106
- rubygems_version: 2.0.3
107
+ rubygems_version: 2.1.2
107
108
  signing_key:
108
109
  specification_version: 4
109
110
  summary: Use AR migrations from outside of a Rails project