rake_migrations 1.0.3 → 1.0.4

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: 292320d685c80045889ee0c2787b3495f8f546b6
4
- data.tar.gz: b52392b99fba2a4c7c75ab5cd18c5fb57b51a3bf
3
+ metadata.gz: b3695f1183b6f5d7930b0c9ab6ca0f2e9745b451
4
+ data.tar.gz: bce3edbed33811e85b4d619b64edad0dbb9dd4d6
5
5
  SHA512:
6
- metadata.gz: 5e8f8fb180f47e42e6a2cfa9c2f1e48b75c81b84a70c4d615966040364290d8472cbe78ed559be60c2ae376bae2a2747da5252f61661fbc53641302411e5b1d5
7
- data.tar.gz: 88321a2b6a6f60ab400413ade1180df2c70669c283150abd3f9fd41bc986a3fa987bcb041fdbe04c6abdc94d913d4a414414e1a40bc4c1a67bee3d8599a146cb
6
+ metadata.gz: 74eef0356c290cbcb6e16377b204246254e88eee1b26ed6f6bc6fd41b534ed1ce15612b8ad623dc11404f517c42c5bc629a45f5ed8b82755e47467343fcaadb3
7
+ data.tar.gz: da19fe5e786af645586f72199bf541a18c1ee7e5117c4053c9059dde13517df6c8b7eb8520522d16e1f8599093e20e9246084e69ef96fc133bd5f32a9d926db4
data/README.md CHANGED
@@ -7,7 +7,7 @@ Rake Migrations
7
7
  This gem helps you and your team members keep track of 'run once' rake tasks.
8
8
 
9
9
  ## Requirements
10
- At the moment I have only tested this on Rails 3.2.X running mysql2 on Mac OS X.
10
+ At the moment I have only tested this on Rails 3.2.X running mysql (uses mysql2 gem) or postgresql on Mac OS X.
11
11
  If you can help by testing this on different versions, databases and platforms, let me know.
12
12
 
13
13
  ## Installation
@@ -19,14 +19,25 @@ gem 'rake_migrations'
19
19
  Then, run:
20
20
  ```ruby
21
21
  bundle install
22
+
23
+ # For mysql
22
24
  rails g rake_migrations:install
25
+
26
+ # For postgresql
27
+ rails g rake_migrations:install pg
28
+
29
+ # Don't forget to migrate (both for mysql and pg)
23
30
  rake db:migrate
24
31
  ```
25
32
 
26
- Finally, open the file 'config/rake_migrations_check.rb' and replace "<database name>" with your database's name:
33
+ Finally, open the file 'config/rake_migrations_check.rb' in your project and replace "database name" with your database's name and the "username" with your database's username (remove smaller/greater than symbols):
27
34
 
28
35
  ```ruby
29
- client = Mysql2::Client.new(host: "localhost", username: "root", database: "<database name>")
36
+ # For mysql2
37
+ client = Mysql2::Client.new(host: "localhost", username: "<username>", database: "<database name>")
38
+
39
+ # For postgresql
40
+ client = PG.connect(host: "localhost", user: "<username>", dbname: "<database name>")
30
41
  ```
31
42
 
32
43
  ## Use
@@ -85,4 +96,4 @@ Feel free to open issues, send suggestions and fork this repository.
85
96
 
86
97
  This gem was developed during my work at [Samanage](http://www.samanage.com/).
87
98
 
88
- Thanks and Enjoy! :)
99
+ Thanks and Enjoy! :)
@@ -10,7 +10,13 @@ module RakeMigrations
10
10
 
11
11
  def create_migration_file
12
12
  migration_template "migration.rb", "db/migrate/create_rake_migrations_table.rb"
13
- template("rake_migrations_check.rb", "config/rake_migrations_check.rb")
13
+
14
+ if args.first == "pg"
15
+ template("rake_migrations_check_pg.rb", "config/rake_migrations_check.rb")
16
+ else
17
+ template("rake_migrations_check.rb", "config/rake_migrations_check.rb")
18
+ end
19
+
14
20
  write_to_post_merge_hook
15
21
  end
16
22
 
@@ -2,7 +2,7 @@ require 'mysql2'
2
2
 
3
3
  module RakeMigrationsCheck
4
4
  def self.check
5
- client = Mysql2::Client.new(host: "localhost", username: "root", database: "<database name>")
5
+ client = Mysql2::Client.new(host: "localhost", username: "<username>", database: "<database name>")
6
6
  results = client.query("select * from rake_migrations").map {|res| res["version"] }
7
7
  rake_migrations_lib = "#{`pwd`.strip}/lib/tasks/rake_migrations/*"
8
8
 
@@ -0,0 +1,29 @@
1
+ require 'pg'
2
+
3
+ module RakeMigrationsCheck
4
+ def self.check
5
+ client = PG.connect(host: "localhost", user: "<username>", dbname: "<database name>")
6
+ results = client.exec("select * from rake_migrations").map {|res| res["version"] }
7
+
8
+ rake_migrations_lib = "#{`pwd`.strip}/lib/tasks/rake_migrations/*"
9
+
10
+ rake_files = Dir[rake_migrations_lib].map do |file|
11
+ if !results.include?(file[/\d+/])
12
+ file = File.read(file)
13
+ namespace = file[/namespace :(.*?)do/m, 1].strip
14
+ task = file[/task (.*?):/m, 1]
15
+ "rake #{namespace}:#{task}"
16
+ end
17
+ end.compact
18
+
19
+ if !rake_files.empty?
20
+ puts "\n"
21
+ puts "You need to run the following rakes:"
22
+ puts "------------------------------------"
23
+ rake_files.each { |file| puts "\e[31m#{file}\e[0m" }
24
+ puts "\n"
25
+ end
26
+ end
27
+ end
28
+
29
+ RakeMigrationsCheck.check
@@ -1,3 +1,3 @@
1
1
  module RakeMigrations
2
- VERSION = "1.0.3"
2
+ VERSION = "1.0.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rake_migrations
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eyal Eizenberg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-06 00:00:00.000000000 Z
11
+ date: 2014-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -52,6 +52,7 @@ files:
52
52
  - lib/rails/generators/rake_migrations/install_generator.rb
53
53
  - lib/rails/generators/rake_migrations/templates/migration.rb
54
54
  - lib/rails/generators/rake_migrations/templates/rake_migrations_check.rb
55
+ - lib/rails/generators/rake_migrations/templates/rake_migrations_check_pg.rb
55
56
  - lib/rails/generators/task/USAGE
56
57
  - lib/rails/generators/task/task_generator.rb
57
58
  - lib/rails/generators/task/templates/task.rb