justonedb 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -37,6 +37,16 @@ The PostgreSQL client program 'pg_dump' must be installed in order to use the mi
37
37
  $ justonedb heroku purge-old
38
38
  Purging JustOneDB 'OLD' configuration variables
39
39
 
40
+ * Set default Heroku database to connect to JustOneDB
41
+ $ justonedb heroku make-default
42
+ Making JUSTONEDB_DBI_URL the default Rails database
43
+ DATABASE_URL now points directly to the JustOneDB database; application restarting
44
+
45
+ * Reset default Heroku database from saved settings
46
+ $ justonedb heroku reset-default
47
+ Resetting DATABASE_URL from JUSTONEDB_SAVED_DATABASE_URL
48
+ DATABASE_URL has now been reset, application restarting
49
+
40
50
  == License
41
51
 
42
52
  Released under the [MIT license](http://www.opensource.org/licenses/mit-license.php).
@@ -6,7 +6,7 @@ Gem::Specification.new do |spec|
6
6
 
7
7
  spec.authors = ["JustOneDB"]
8
8
  spec.date = "2012-01-18"
9
- spec.description = "Command-line tool for JustOneDB to assist in deployments on Heroku"
9
+ spec.description = "Command-line tool for JustOneDB to assist with deployments on Heroku"
10
10
  spec.email = "support@justonedb.com"
11
11
  spec.executables = ["justonedb"]
12
12
  spec.files = `svn ls -R`.split("\n")
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "justonedb"
5
+ spec.version = "1.1.0"
6
+
7
+ spec.authors = ["JustOneDB"]
8
+ spec.date = "2012-02-03"
9
+ spec.description = "Command-line tool for JustOneDB to assist with deployments on Heroku"
10
+ spec.email = "support@justonedb.com"
11
+ spec.executables = ["justonedb"]
12
+ spec.files = `svn ls -R`.split("\n")
13
+ spec.homepage = "http://www.justonedb.com/"
14
+ spec.require_paths = ['lib']
15
+ spec.rubygems_version = "1.8.10"
16
+ spec.summary = "Command-line tool for JustOneDB database deployed on Heroku."
17
+
18
+ spec.required_rubygems_version = Gem::Requirement.new(">= 0") if spec.respond_to? :required_rubygems_version=
19
+ spec.add_dependency 'heroku', '~> 2.15'
20
+ spec.add_dependency 'require_all', '~> 1.2.1'
21
+ end
@@ -44,6 +44,22 @@ module JustOneDB::Command
44
44
  :summary => "Purge 'OLD' JustOneDB variables",
45
45
  :options => NIL
46
46
  },
47
+ {
48
+ :cmd_class => self,
49
+ :method => self.instance_method(:make_justone_default_database),
50
+ :platform => "heroku",
51
+ :command => "make-default",
52
+ :summary => "Make JustOneDB the default Heroku database",
53
+ :options => NIL
54
+ },
55
+ {
56
+ :cmd_class => self,
57
+ :method => self.instance_method(:reset_default_database),
58
+ :platform => "heroku",
59
+ :command => "reset-default",
60
+ :summary => "Reset the default Heroku database using DATABASE_URL_DEFAULT",
61
+ :options => NIL
62
+ },
47
63
  ]
48
64
  end
49
65
  end
@@ -0,0 +1,34 @@
1
+ require 'justonedb/command/base'
2
+ require 'heroku/auth'
3
+ require 'heroku/command'
4
+ require 'heroku/command/base'
5
+
6
+ module JustOneDB::Command
7
+ class Heroku < JustOneDB::Command::Base
8
+ # Make JustOneDB the default Rails database in heroku, by assigning JUSTONEDB_DBI_URL to DATABASE_URL
9
+ def make_justone_default_database(args, options)
10
+ herokuapi = ::Heroku::Command::BaseWithApp.new(args, options)
11
+
12
+ vars = herokuapi.heroku.config_vars(herokuapi.app)
13
+
14
+ raise InvalidAppConfig, "JUSTONEDB_DBI_URL undefined" unless vars["JUSTONEDB_DBI_URL"]
15
+
16
+ if vars["DATABASE_URL"] && vars["DATABASE_URL"] == vars["JUSTONEDB_DBI_URL"]
17
+ raise InvalidAppConfig, "DATABASE_URL is already using the JustOne database"
18
+ end
19
+
20
+ puts "Making JUSTONEDB_DBI_URL the default Rails database"
21
+
22
+ detected_app = herokuapi.app
23
+
24
+ if vars["DATABASE_URL"]
25
+ # Save the old one ...
26
+ herokuapi.heroku.add_config_vars(detected_app, { "JUSTONEDB_SAVED_DATABASE_URL" => vars["DATABASE_URL"] })
27
+ end
28
+
29
+ herokuapi.heroku.add_config_vars(detected_app, { "DATABASE_URL" => vars["JUSTONEDB_DBI_URL"] })
30
+
31
+ puts "DATABASE_URL now points directly to the JustOneDB database; application restarting"
32
+ end
33
+ end
34
+ end
@@ -7,6 +7,7 @@ require 'tmpdir'
7
7
 
8
8
  module JustOneDB::Command
9
9
  class Heroku < JustOneDB::Command::Base
10
+ # Migrate JustOne database data from JUSTONEDB_DBI_URL to JUSTONEDB_NEW_DBI_URL
10
11
  def migrate(args, options)
11
12
  # Migrate data from JUSTONEDB_DBI_URL to JUSTONEDB_NEW_DBI_URL
12
13
  # -d, --directory # Specify temporary dump directory
@@ -6,6 +6,7 @@ require 'heroku/command/base'
6
6
  module JustOneDB::Command
7
7
  class Heroku < JustOneDB::Command::Base
8
8
 
9
+ # Promote 'NEW' JustOne database to current
9
10
  def promote(args, options)
10
11
  herokuapi = ::Heroku::Command::BaseWithApp.new(args, options)
11
12
 
@@ -6,6 +6,7 @@ require 'heroku/command/base'
6
6
  module JustOneDB::Command
7
7
  class Heroku < JustOneDB::Command::Base
8
8
 
9
+ # Purge 'OLD' JustOneDB environment variables
9
10
  def purge_old(args, options)
10
11
  herokuapi = ::Heroku::Command::BaseWithApp.new(args, options)
11
12
 
@@ -0,0 +1,25 @@
1
+ require 'justonedb/command/base'
2
+ require 'heroku/auth'
3
+ require 'heroku/command'
4
+ require 'heroku/command/base'
5
+
6
+ module JustOneDB::Command
7
+ class Heroku < JustOneDB::Command::Base
8
+ # Set DATABASE_URL back to JUSTONEDB_SAVED_DATABASE_URL
9
+ def reset_default_database(args, options)
10
+ herokuapi = ::Heroku::Command::BaseWithApp.new(args, options)
11
+
12
+ vars = herokuapi.heroku.config_vars(herokuapi.app)
13
+
14
+ raise InvalidAppConfig, "JUSTONEDB_SAVED_DATABASE_URL undefined" unless vars["JUSTONEDB_SAVED_DATABASE_URL"]
15
+
16
+ puts "Resetting DATABASE_URL from JUSTONEDB_SAVED_DATABASE_URL"
17
+
18
+ detected_app = herokuapi.app
19
+
20
+ herokuapi.heroku.add_config_vars(detected_app, { "DATABASE_URL" => vars["JUSTONEDB_SAVED_DATABASE_URL"] })
21
+
22
+ puts "DATABASE_URL has now been reset; application restarting"
23
+ end
24
+ end
25
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: justonedb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-18 00:00:00.000000000Z
12
+ date: 2012-02-03 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: heroku
16
- requirement: &74934430 !ruby/object:Gem::Requirement
16
+ requirement: &74239400 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '2.15'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *74934430
24
+ version_requirements: *74239400
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: require_all
27
- requirement: &74934000 !ruby/object:Gem::Requirement
27
+ requirement: &74238590 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,8 +32,8 @@ dependencies:
32
32
  version: 1.2.1
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *74934000
36
- description: Command-line tool for JustOneDB to assist in deployments on Heroku
35
+ version_requirements: *74238590
36
+ description: Command-line tool for JustOneDB to assist with deployments on Heroku
37
37
  email: support@justonedb.com
38
38
  executables:
39
39
  - justonedb
@@ -44,11 +44,14 @@ files:
44
44
  - README.rdoc
45
45
  - bin/justonedb
46
46
  - justonedb-1.0.0.gemspec
47
+ - justonedb-1.1.0.gemspec
47
48
  - lib/justonedb/command/base.rb
48
49
  - lib/justonedb/command/heroku/base.rb
50
+ - lib/justonedb/command/heroku/make-default.rb
49
51
  - lib/justonedb/command/heroku/migrate.rb
50
52
  - lib/justonedb/command/heroku/promote.rb
51
53
  - lib/justonedb/command/heroku/purge-old.rb
54
+ - lib/justonedb/command/heroku/reset-default.rb
52
55
  - lib/justonedb/command.rb
53
56
  homepage: http://www.justonedb.com/
54
57
  licenses: []
@@ -73,6 +76,6 @@ rubyforge_project:
73
76
  rubygems_version: 1.8.10
74
77
  signing_key:
75
78
  specification_version: 3
76
- summary: Command-line tool for JustOneDB database deployed on Heroku, or AppHarbor.
79
+ summary: Command-line tool for JustOneDB database deployed on Heroku.
77
80
  test_files: []
78
81
  has_rdoc: