migrer 0.0.1 → 0.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.
data/README.md CHANGED
@@ -45,17 +45,17 @@ And install database migrations like so:
45
45
 
46
46
  ## Usage
47
47
 
48
- # 1) Create the data migration
48
+ ### 1) Create the data migration
49
49
 
50
50
  Create a data migration:
51
51
 
52
- $ bundle exec rails generate MyFirstDataMigration "optional description"
52
+ $ bundle exec rails generate data_migration MyFirstDataMigration "optional description"
53
53
 
54
54
  This will create the file: lib/tasks/data_migrations/<timestamp>_my_first_data_migration.rb
55
55
 
56
56
  Open this file and replace "TODO" with your data migration code!
57
57
 
58
- # 2) Run a task
58
+ ### 2) Run a task
59
59
 
60
60
  Unless you have the RAILS_ENV environment variable already set, prepend this to all of the following commands (replace
61
61
  <environment> with the correct Rails environment (development, staging, production, etc.):
@@ -7,12 +7,12 @@ class DataMigration
7
7
  match_data = /^(?<version>\d+)_(?<name>.+)\.rb$/.match(f)
8
8
 
9
9
  record = ActiveRecord::Base.connection.execute(
10
- "SELECT * FROM data_migration_versions WHERE version = #{match_data[:version]}").first
10
+ "SELECT * FROM data_migration_versions WHERE version = '#{match_data[:version]}'").first
11
11
 
12
12
  data_migrations.merge!(
13
13
  match_data[:version] => {
14
14
  basefilename: "#{match_data[:version]}_#{match_data[:name]}",
15
- class_name: match_data[:name].classify,
15
+ class_name: match_data[:name].camelize,
16
16
  filename: "#{match_data[:version]}_#{match_data[:name]}.rb",
17
17
  name: match_data[:name],
18
18
  processed: (record != nil),
@@ -23,4 +23,4 @@ class DataMigration
23
23
 
24
24
  data_migrations
25
25
  end
26
- end
26
+ end
@@ -1,3 +1,3 @@
1
1
  module Migrer
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -30,7 +30,7 @@ namespace :data do
30
30
  unless data_migration[:processed]
31
31
  ActiveRecord::Base.connection.execute(
32
32
  "INSERT INTO data_migration_versions
33
- VALUES (NULL, #{version}, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)" )
33
+ VALUES (NULL, '#{version}', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)" )
34
34
  end
35
35
 
36
36
  puts "#{data_migration[:class_name]}: migrated (#{t_end - t_start}s)"
@@ -54,7 +54,7 @@ namespace :data do
54
54
 
55
55
  ActiveRecord::Base.connection.execute(
56
56
  "INSERT INTO data_migration_versions
57
- VALUES (NULL, #{k}, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)" )
57
+ VALUES (NULL, '#{k}', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)" )
58
58
 
59
59
  puts "#{v[:class_name]}: migrated (#{t_end - t_start}s)"
60
60
  end
@@ -80,7 +80,7 @@ namespace :data do
80
80
  if prompt == "yes"
81
81
  ActiveRecord::Base.connection.execute(
82
82
  "INSERT INTO data_migration_versions
83
- VALUES (NULL, #{version}, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)" )
83
+ VALUES (NULL, '#{version}', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)" )
84
84
 
85
85
  puts "#{data_migration[:class_name]}: marked as migrated"
86
86
  end
@@ -103,7 +103,7 @@ namespace :data do
103
103
  unprocessed_data_migrations.each do |k, v|
104
104
  ActiveRecord::Base.connection.execute(
105
105
  "INSERT INTO data_migration_versions
106
- VALUES (NULL, #{k}, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)" )
106
+ VALUES (NULL, '#{k}', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)" )
107
107
 
108
108
  puts "#{v[:class_name]}: marked as migrated"
109
109
  end
@@ -127,7 +127,7 @@ namespace :data do
127
127
  if prompt == "yes"
128
128
  ActiveRecord::Base.connection.execute(
129
129
  "DELETE FROM data_migration_versions
130
- WHERE version = #{version}" )
130
+ WHERE version = '#{version}'" )
131
131
 
132
132
  puts "#{data_migration[:class_name]}: unmarked as migrated"
133
133
  end
@@ -152,4 +152,4 @@ namespace :data do
152
152
  puts "Data migration records cleared"
153
153
  end
154
154
  end
155
- end
155
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: migrer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-01-12 00:00:00.000000000 Z
13
+ date: 2013-01-13 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord