heroku-schemas 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. data/.gitignore +4 -0
  2. data/Gemfile +3 -0
  3. data/MIT-LICENSE +20 -0
  4. data/README.md +94 -0
  5. data/Rakefile +2 -0
  6. data/features/drop.feature +9 -0
  7. data/features/migration.feature +18 -0
  8. data/features/show.feature +9 -0
  9. data/features/step_definitions/common_steps.rb +8 -0
  10. data/features/step_definitions/drop_steps.rb +12 -0
  11. data/features/step_definitions/migration_steps.rb +57 -0
  12. data/features/step_definitions/show_steps.rb +12 -0
  13. data/features/support/config.example.yml +2 -0
  14. data/features/support/env.rb +42 -0
  15. data/features/support/lib/configuration.rb +23 -0
  16. data/features/support/lib/heroku-schemas/test/app.rb +109 -0
  17. data/features/support/lib/output_buffer.rb +26 -0
  18. data/heroku-schemas.gemspec +29 -0
  19. data/init.rb +1 -0
  20. data/lib/heroku-schemas.rb +19 -0
  21. data/lib/heroku-schemas/current_database.rb +9 -0
  22. data/lib/heroku-schemas/database.rb +63 -0
  23. data/lib/heroku-schemas/drop.rb +22 -0
  24. data/lib/heroku-schemas/migration.rb +109 -0
  25. data/lib/heroku-schemas/pgbackups.rb +18 -0
  26. data/lib/heroku-schemas/schema_command.rb +12 -0
  27. data/lib/heroku-schemas/schema_reference.rb +88 -0
  28. data/lib/heroku-schemas/schema_utilities.rb +45 -0
  29. data/lib/heroku-schemas/show.rb +15 -0
  30. data/lib/heroku-schemas/target_database.rb +9 -0
  31. data/lib/heroku-schemas/version.rb +3 -0
  32. data/lib/heroku/command/schemas.rb +28 -0
  33. data/spec/dummy-app/.gitignore +17 -0
  34. data/spec/dummy-app/Gemfile +37 -0
  35. data/spec/dummy-app/README.rdoc +261 -0
  36. data/spec/dummy-app/Rakefile +7 -0
  37. data/spec/dummy-app/app/assets/javascripts/application.js +15 -0
  38. data/spec/dummy-app/app/assets/stylesheets/application.css +13 -0
  39. data/spec/dummy-app/app/controllers/application_controller.rb +3 -0
  40. data/spec/dummy-app/app/helpers/application_helper.rb +2 -0
  41. data/spec/dummy-app/app/mailers/.gitkeep +0 -0
  42. data/spec/dummy-app/app/models/.gitkeep +0 -0
  43. data/spec/dummy-app/app/models/dummy_record.rb +3 -0
  44. data/spec/dummy-app/app/views/layouts/application.html.erb +14 -0
  45. data/spec/dummy-app/config.ru +4 -0
  46. data/spec/dummy-app/config/application.rb +65 -0
  47. data/spec/dummy-app/config/boot.rb +6 -0
  48. data/spec/dummy-app/config/environment.rb +5 -0
  49. data/spec/dummy-app/config/environments/development.rb +37 -0
  50. data/spec/dummy-app/config/environments/production.rb +67 -0
  51. data/spec/dummy-app/config/environments/test.rb +37 -0
  52. data/spec/dummy-app/config/initializers/backtrace_silencers.rb +7 -0
  53. data/spec/dummy-app/config/initializers/inflections.rb +15 -0
  54. data/spec/dummy-app/config/initializers/mime_types.rb +5 -0
  55. data/spec/dummy-app/config/initializers/secret_token.rb +7 -0
  56. data/spec/dummy-app/config/initializers/session_store.rb +8 -0
  57. data/spec/dummy-app/config/initializers/wrap_parameters.rb +14 -0
  58. data/spec/dummy-app/config/locales/en.yml +5 -0
  59. data/spec/dummy-app/config/routes.rb +58 -0
  60. data/spec/dummy-app/db/migrate/20131106080427_create_dummy_records.rb +9 -0
  61. data/spec/dummy-app/db/schema.rb +22 -0
  62. data/spec/dummy-app/db/seeds.rb +7 -0
  63. data/spec/dummy-app/doc/README_FOR_APP +2 -0
  64. data/spec/dummy-app/lib/assets/.gitkeep +0 -0
  65. data/spec/dummy-app/lib/tasks/.gitkeep +0 -0
  66. data/spec/dummy-app/log/.gitkeep +0 -0
  67. data/spec/dummy-app/script/rails +6 -0
  68. data/spec/dummy-app/test/fixtures/.gitkeep +0 -0
  69. data/spec/dummy-app/test/fixtures/dummy_records.yml +7 -0
  70. data/spec/dummy-app/test/functional/.gitkeep +0 -0
  71. data/spec/dummy-app/test/integration/.gitkeep +0 -0
  72. data/spec/dummy-app/test/performance/browsing_test.rb +12 -0
  73. data/spec/dummy-app/test/test_helper.rb +13 -0
  74. data/spec/dummy-app/test/unit/.gitkeep +0 -0
  75. data/spec/dummy-app/test/unit/dummy_record_test.rb +7 -0
  76. data/spec/dummy-app/vendor/assets/javascripts/.gitkeep +0 -0
  77. data/spec/dummy-app/vendor/assets/stylesheets/.gitkeep +0 -0
  78. data/spec/dummy-app/vendor/plugins/.gitkeep +0 -0
  79. data/spec/heroku-schemas/schema_utilities_spec.rb +46 -0
  80. data/spec/spec_helper.rb +8 -0
  81. metadata +313 -0
File without changes
File without changes
@@ -0,0 +1,12 @@
1
+ require 'test_helper'
2
+ require 'rails/performance_test_help'
3
+
4
+ class BrowsingTest < ActionDispatch::PerformanceTest
5
+ # Refer to the documentation for all available options
6
+ # self.profile_options = { :runs => 5, :metrics => [:wall_time, :memory]
7
+ # :output => 'tmp/performance', :formats => [:flat] }
8
+
9
+ def test_homepage
10
+ get '/'
11
+ end
12
+ end
@@ -0,0 +1,13 @@
1
+ ENV["RAILS_ENV"] = "test"
2
+ require File.expand_path('../../config/environment', __FILE__)
3
+ require 'rails/test_help'
4
+
5
+ class ActiveSupport::TestCase
6
+ # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
7
+ #
8
+ # Note: You'll currently still have to declare fixtures explicitly in integration tests
9
+ # -- they do not yet inherit this setting
10
+ fixtures :all
11
+
12
+ # Add more helper methods to be used by all tests here...
13
+ end
File without changes
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class DummyRecordTest < ActiveSupport::TestCase
4
+ # test "the truth" do
5
+ # assert true
6
+ # end
7
+ end
File without changes
File without changes
File without changes
@@ -0,0 +1,46 @@
1
+ require 'spec_helper'
2
+
3
+ describe HerokuSchemas::SchemaUtilities do
4
+ let(:klass) { HerokuSchemas::SchemaUtilities }
5
+ let(:database_url) { 'postgres://user:pass@host:1234/database' }
6
+
7
+ describe '.add_schema_search_path_to_url' do
8
+ it 'adds schema_search_path if it is not present' do
9
+ klass.add_schema_search_path_to_url(database_url, 'my_schema').should == "#{database_url}?schema_search_path=my_schema"
10
+ end
11
+
12
+ it 'updates schema_search_path if it is present' do
13
+ klass.add_schema_search_path_to_url("#{database_url}?schema_search_path=foo", 'my_schema').should == "#{database_url}?schema_search_path=my_schema"
14
+ end
15
+ end
16
+
17
+ describe '.app_to_schema' do
18
+ it 'transforms a hyphenated app name to a valid schema' do
19
+ klass.app_to_schema('my-app').should == 'my_app'
20
+ end
21
+ end
22
+
23
+ describe '.url_to_schema' do
24
+ it 'returns the public schema if a schema is not present' do
25
+ klass.url_to_schema(database_url).should == 'public'
26
+ end
27
+
28
+ it 'returns the schema if a schema is present' do
29
+ klass.url_to_schema("#{database_url}?schema_search_path=my_schema&foo=bar").should == 'my_schema'
30
+ end
31
+
32
+ it 'returns the schema if the query string has two question marks' do
33
+ klass.url_to_schema("#{database_url}?pool=20?pool=20&schema_search_path=my_schema").should == 'my_schema'
34
+ end
35
+ end
36
+
37
+ describe '.validate_schema' do
38
+ it 'returns true if the schema is valid' do
39
+ klass.validate_schema('my_schema').should be_true
40
+ end
41
+
42
+ it 'returns a message if the schema is not valid' do
43
+ klass.validate_schema('my-schema').should include('Schema must only contain lowercase letters, numbers and underscores.')
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,8 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+
4
+ require 'heroku-schemas'
5
+
6
+ RSpec.configure do |config|
7
+ # some (optional) config here
8
+ end
metadata ADDED
@@ -0,0 +1,313 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: heroku-schemas
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Tom Benner
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-11-30 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: heroku
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 3.0.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 3.0.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: heroku-api
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: pg
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: activerecord
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - '='
68
+ - !ruby/object:Gem::Version
69
+ version: 3.2.0
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - '='
76
+ - !ruby/object:Gem::Version
77
+ version: 3.2.0
78
+ - !ruby/object:Gem::Dependency
79
+ name: rake
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: rspec
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: cucumber
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: aruba
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ description: Run many apps on a single database.
143
+ email:
144
+ - tombenner@gmail.com
145
+ executables: []
146
+ extensions: []
147
+ extra_rdoc_files: []
148
+ files:
149
+ - .gitignore
150
+ - Gemfile
151
+ - MIT-LICENSE
152
+ - README.md
153
+ - Rakefile
154
+ - features/drop.feature
155
+ - features/migration.feature
156
+ - features/show.feature
157
+ - features/step_definitions/common_steps.rb
158
+ - features/step_definitions/drop_steps.rb
159
+ - features/step_definitions/migration_steps.rb
160
+ - features/step_definitions/show_steps.rb
161
+ - features/support/config.example.yml
162
+ - features/support/env.rb
163
+ - features/support/lib/configuration.rb
164
+ - features/support/lib/heroku-schemas/test/app.rb
165
+ - features/support/lib/output_buffer.rb
166
+ - heroku-schemas.gemspec
167
+ - init.rb
168
+ - lib/heroku-schemas.rb
169
+ - lib/heroku-schemas/current_database.rb
170
+ - lib/heroku-schemas/database.rb
171
+ - lib/heroku-schemas/drop.rb
172
+ - lib/heroku-schemas/migration.rb
173
+ - lib/heroku-schemas/pgbackups.rb
174
+ - lib/heroku-schemas/schema_command.rb
175
+ - lib/heroku-schemas/schema_reference.rb
176
+ - lib/heroku-schemas/schema_utilities.rb
177
+ - lib/heroku-schemas/show.rb
178
+ - lib/heroku-schemas/target_database.rb
179
+ - lib/heroku-schemas/version.rb
180
+ - lib/heroku/command/schemas.rb
181
+ - spec/dummy-app/.gitignore
182
+ - spec/dummy-app/Gemfile
183
+ - spec/dummy-app/README.rdoc
184
+ - spec/dummy-app/Rakefile
185
+ - spec/dummy-app/app/assets/javascripts/application.js
186
+ - spec/dummy-app/app/assets/stylesheets/application.css
187
+ - spec/dummy-app/app/controllers/application_controller.rb
188
+ - spec/dummy-app/app/helpers/application_helper.rb
189
+ - spec/dummy-app/app/mailers/.gitkeep
190
+ - spec/dummy-app/app/models/.gitkeep
191
+ - spec/dummy-app/app/models/dummy_record.rb
192
+ - spec/dummy-app/app/views/layouts/application.html.erb
193
+ - spec/dummy-app/config.ru
194
+ - spec/dummy-app/config/application.rb
195
+ - spec/dummy-app/config/boot.rb
196
+ - spec/dummy-app/config/environment.rb
197
+ - spec/dummy-app/config/environments/development.rb
198
+ - spec/dummy-app/config/environments/production.rb
199
+ - spec/dummy-app/config/environments/test.rb
200
+ - spec/dummy-app/config/initializers/backtrace_silencers.rb
201
+ - spec/dummy-app/config/initializers/inflections.rb
202
+ - spec/dummy-app/config/initializers/mime_types.rb
203
+ - spec/dummy-app/config/initializers/secret_token.rb
204
+ - spec/dummy-app/config/initializers/session_store.rb
205
+ - spec/dummy-app/config/initializers/wrap_parameters.rb
206
+ - spec/dummy-app/config/locales/en.yml
207
+ - spec/dummy-app/config/routes.rb
208
+ - spec/dummy-app/db/migrate/20131106080427_create_dummy_records.rb
209
+ - spec/dummy-app/db/schema.rb
210
+ - spec/dummy-app/db/seeds.rb
211
+ - spec/dummy-app/doc/README_FOR_APP
212
+ - spec/dummy-app/lib/assets/.gitkeep
213
+ - spec/dummy-app/lib/tasks/.gitkeep
214
+ - spec/dummy-app/log/.gitkeep
215
+ - spec/dummy-app/script/rails
216
+ - spec/dummy-app/test/fixtures/.gitkeep
217
+ - spec/dummy-app/test/fixtures/dummy_records.yml
218
+ - spec/dummy-app/test/functional/.gitkeep
219
+ - spec/dummy-app/test/integration/.gitkeep
220
+ - spec/dummy-app/test/performance/browsing_test.rb
221
+ - spec/dummy-app/test/test_helper.rb
222
+ - spec/dummy-app/test/unit/.gitkeep
223
+ - spec/dummy-app/test/unit/dummy_record_test.rb
224
+ - spec/dummy-app/vendor/assets/javascripts/.gitkeep
225
+ - spec/dummy-app/vendor/assets/stylesheets/.gitkeep
226
+ - spec/dummy-app/vendor/plugins/.gitkeep
227
+ - spec/heroku-schemas/schema_utilities_spec.rb
228
+ - spec/spec_helper.rb
229
+ homepage: https://github.com/tombenner/heroku-schemas
230
+ licenses: []
231
+ post_install_message:
232
+ rdoc_options: []
233
+ require_paths:
234
+ - lib
235
+ required_ruby_version: !ruby/object:Gem::Requirement
236
+ none: false
237
+ requirements:
238
+ - - ! '>='
239
+ - !ruby/object:Gem::Version
240
+ version: '0'
241
+ required_rubygems_version: !ruby/object:Gem::Requirement
242
+ none: false
243
+ requirements:
244
+ - - ! '>='
245
+ - !ruby/object:Gem::Version
246
+ version: '0'
247
+ requirements: []
248
+ rubyforge_project: heroku-schemas
249
+ rubygems_version: 1.8.24
250
+ signing_key:
251
+ specification_version: 3
252
+ summary: Run many apps on a single database.
253
+ test_files:
254
+ - features/drop.feature
255
+ - features/migration.feature
256
+ - features/show.feature
257
+ - features/step_definitions/common_steps.rb
258
+ - features/step_definitions/drop_steps.rb
259
+ - features/step_definitions/migration_steps.rb
260
+ - features/step_definitions/show_steps.rb
261
+ - features/support/config.example.yml
262
+ - features/support/env.rb
263
+ - features/support/lib/configuration.rb
264
+ - features/support/lib/heroku-schemas/test/app.rb
265
+ - features/support/lib/output_buffer.rb
266
+ - spec/dummy-app/.gitignore
267
+ - spec/dummy-app/Gemfile
268
+ - spec/dummy-app/README.rdoc
269
+ - spec/dummy-app/Rakefile
270
+ - spec/dummy-app/app/assets/javascripts/application.js
271
+ - spec/dummy-app/app/assets/stylesheets/application.css
272
+ - spec/dummy-app/app/controllers/application_controller.rb
273
+ - spec/dummy-app/app/helpers/application_helper.rb
274
+ - spec/dummy-app/app/mailers/.gitkeep
275
+ - spec/dummy-app/app/models/.gitkeep
276
+ - spec/dummy-app/app/models/dummy_record.rb
277
+ - spec/dummy-app/app/views/layouts/application.html.erb
278
+ - spec/dummy-app/config.ru
279
+ - spec/dummy-app/config/application.rb
280
+ - spec/dummy-app/config/boot.rb
281
+ - spec/dummy-app/config/environment.rb
282
+ - spec/dummy-app/config/environments/development.rb
283
+ - spec/dummy-app/config/environments/production.rb
284
+ - spec/dummy-app/config/environments/test.rb
285
+ - spec/dummy-app/config/initializers/backtrace_silencers.rb
286
+ - spec/dummy-app/config/initializers/inflections.rb
287
+ - spec/dummy-app/config/initializers/mime_types.rb
288
+ - spec/dummy-app/config/initializers/secret_token.rb
289
+ - spec/dummy-app/config/initializers/session_store.rb
290
+ - spec/dummy-app/config/initializers/wrap_parameters.rb
291
+ - spec/dummy-app/config/locales/en.yml
292
+ - spec/dummy-app/config/routes.rb
293
+ - spec/dummy-app/db/migrate/20131106080427_create_dummy_records.rb
294
+ - spec/dummy-app/db/schema.rb
295
+ - spec/dummy-app/db/seeds.rb
296
+ - spec/dummy-app/doc/README_FOR_APP
297
+ - spec/dummy-app/lib/assets/.gitkeep
298
+ - spec/dummy-app/lib/tasks/.gitkeep
299
+ - spec/dummy-app/log/.gitkeep
300
+ - spec/dummy-app/script/rails
301
+ - spec/dummy-app/test/fixtures/.gitkeep
302
+ - spec/dummy-app/test/fixtures/dummy_records.yml
303
+ - spec/dummy-app/test/functional/.gitkeep
304
+ - spec/dummy-app/test/integration/.gitkeep
305
+ - spec/dummy-app/test/performance/browsing_test.rb
306
+ - spec/dummy-app/test/test_helper.rb
307
+ - spec/dummy-app/test/unit/.gitkeep
308
+ - spec/dummy-app/test/unit/dummy_record_test.rb
309
+ - spec/dummy-app/vendor/assets/javascripts/.gitkeep
310
+ - spec/dummy-app/vendor/assets/stylesheets/.gitkeep
311
+ - spec/dummy-app/vendor/plugins/.gitkeep
312
+ - spec/heroku-schemas/schema_utilities_spec.rb
313
+ - spec/spec_helper.rb