data_migrate 2.0.1 → 2.1.0

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: 2867f4c1b8e7a37696ea3c640e83babb573e8996
4
- data.tar.gz: 1e67d3ce5fd3517d60a8687afcf9df3c151de4b7
3
+ metadata.gz: 1a61a9b037890457c24cc8cea7276360ae1fd56c
4
+ data.tar.gz: f5f4fd95f631b962accb8c1709967ada6a771d22
5
5
  SHA512:
6
- metadata.gz: 1c5548f92419a80bd209316e505a6bc08342bc17942296bd68c5e7a248a8c3ef689b7b440d48c09caf36e633db145068fcbd17b5f1ca840eeef3a68daff075b8
7
- data.tar.gz: d4341fa69a92b91308975b9b8ebc18709f39576891fd4e32a2e04caf809eb9197fc0b7be558d08898016a0489429f97cc2a98a0b2adf70098a3d8f97051d621b
6
+ metadata.gz: 71d3e595a3ecc3e49b9509b6ae6250394c89514900d35b992480a609527d0a7413940c3ba06b274f74f5968d53a6b77bcf362c839e27c8f60d1352ff92c346a5
7
+ data.tar.gz: b98a1f2a4ab114da88312dbfb56ef1710ecdc3aebf61c2f68d10240daa95eadafad8aa688611d3011aa32682134082635b2d78437bf6db091e5ececd72670c88
data/.gitignore CHANGED
@@ -1,2 +1,3 @@
1
+
1
2
  /.rvmrc
2
3
  *.gem
data/Changelog.md ADDED
@@ -0,0 +1,7 @@
1
+ Changelog
2
+ =========
3
+
4
+ ## 2.1.0
5
+
6
+ User `Rails.application.config.paths["db/migrate"]` instead of hard coded
7
+ path to db migrations
@@ -39,6 +39,27 @@ module DataMigrate
39
39
  def migrations_path
40
40
  'db/data'
41
41
  end
42
+
43
+ def assure_data_schema_table
44
+ config = ActiveRecord::Base.configurations[Rails.env || 'development'] || ENV["DATABASE_URL"]
45
+ ActiveRecord::Base.establish_connection(config)
46
+ sm_table = DataMigrate::DataMigrator.schema_migrations_table_name
47
+
48
+ unless ActiveRecord::Base.connection.table_exists?(sm_table)
49
+ ActiveRecord::Base.connection.create_table(sm_table, :id => false) do |schema_migrations_table|
50
+ schema_migrations_table.column :version, :string, :null => false
51
+ end
52
+
53
+ suffix = ActiveRecord::Base.table_name_suffix
54
+ prefix = ActiveRecord::Base.table_name_prefix
55
+ index_name = "#{prefix}unique_data_migrations#{suffix}"
56
+
57
+ ActiveRecord::Base.connection.add_index sm_table, :version,
58
+ :unique => true,
59
+ :name => index_name
60
+ end
61
+ end
62
+
42
63
  end
43
64
  end
44
65
  end
@@ -1,3 +1,3 @@
1
1
  module DataMigrate
2
- VERSION = "2.0.1"
2
+ VERSION = "2.1.0"
3
3
  end
data/tasks/databases.rake CHANGED
@@ -49,7 +49,11 @@ namespace :db do
49
49
  DataMigrate::DataMigrator.run(migration[:direction], "db/data/", migration[:version])
50
50
  else
51
51
  ActiveRecord::Migration.write("== %s %s" % ['Schema', "=" * 69])
52
- ActiveRecord::Migrator.run(migration[:direction], "db/migrate/", migration[:version])
52
+ ActiveRecord::Migrator.run(
53
+ migration[:direction],
54
+ Rails.application.config.paths["db/migrate"],
55
+ migration[:version]
56
+ )
53
57
  end
54
58
  end
55
59
 
@@ -312,11 +316,17 @@ def pending_migrations
312
316
  end
313
317
 
314
318
  def pending_data_migrations
315
- sort_migrations DataMigrate::DataMigrator.new(:up, 'db/data').pending_migrations.map{|m| { :version => m.version, :kind => :data }}
319
+ data_migrations = DataMigrate::DataMigrator.migrations('db/data')
320
+ sort_migrations DataMigrate::DataMigrator.new(:up, data_migrations ).
321
+ pending_migrations.map{|m| { :version => m.version, :kind => :data }}
316
322
  end
317
323
 
318
324
  def pending_schema_migrations
319
- sort_migrations ActiveRecord::Migrator.new(:up, 'db/migrate').pending_migrations.map{|m| { :version => m.version, :kind => :schema }}
325
+ all_migrations = ActiveRecord::Migrator.migrations(Rails.application.config.paths["db/migrate"])
326
+ sort_migrations(
327
+ ActiveRecord::Migrator.new(:up, all_migrations).
328
+ pending_migrations.
329
+ map{|m| { :version => m.version, :kind => :schema }})
320
330
  end
321
331
 
322
332
  def sort_migrations set_1, set_2=nil
@@ -353,14 +363,5 @@ def past_migrations sort=nil
353
363
  end
354
364
 
355
365
  def assure_data_schema_table
356
- config = ActiveRecord::Base.configurations[Rails.env || 'development'] || ENV["DATABASE_URL"]
357
- ActiveRecord::Base.establish_connection(config)
358
- sm_table = DataMigrate::DataMigrator.schema_migrations_table_name
359
-
360
- unless ActiveRecord::Base.connection.table_exists?(sm_table)
361
- ActiveRecord::Base.connection.create_table(sm_table, :id => false) do |schema_migrations_table|
362
- schema_migrations_table.column :version, :string, :null => false
363
- end
364
- ActiveRecord::Base.connection.add_index sm_table, :version, :unique => true, :name => "#{ActiveRecord::Base.table_name_prefix}unique_data_migrations#{ActiveRecord::Base.table_name_suffix}"
365
- end
366
+ DataMigrate::DataMigrator.assure_data_schema_table
366
367
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: data_migrate
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew J Vargo
@@ -9,20 +9,20 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-03-07 00:00:00.000000000 Z
12
+ date: 2016-03-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ">="
18
+ - - '>='
19
19
  - !ruby/object:Gem::Version
20
20
  version: '4.0'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - ">="
25
+ - - '>='
26
26
  - !ruby/object:Gem::Version
27
27
  version: '4.0'
28
28
  description: Rake tasks to migrate data alongside schema changes.
@@ -33,7 +33,8 @@ executables: []
33
33
  extensions: []
34
34
  extra_rdoc_files: []
35
35
  files:
36
- - ".gitignore"
36
+ - .gitignore
37
+ - Changelog.md
37
38
  - Gemfile
38
39
  - LICENSE
39
40
  - README.md
@@ -61,17 +62,17 @@ require_paths:
61
62
  - lib
62
63
  required_ruby_version: !ruby/object:Gem::Requirement
63
64
  requirements:
64
- - - ">="
65
+ - - '>='
65
66
  - !ruby/object:Gem::Version
66
67
  version: '0'
67
68
  required_rubygems_version: !ruby/object:Gem::Requirement
68
69
  requirements:
69
- - - ">="
70
+ - - '>='
70
71
  - !ruby/object:Gem::Version
71
72
  version: '0'
72
73
  requirements: []
73
74
  rubyforge_project: data_migrate
74
- rubygems_version: 2.4.8
75
+ rubygems_version: 2.0.14.1
75
76
  signing_key:
76
77
  specification_version: 4
77
78
  summary: Rake tasks to migrate data alongside schema changes.