schema_plus_views 0.4.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/prs.yml +329 -0
  3. data/.gitignore +1 -0
  4. data/.simplecov +20 -0
  5. data/Gemfile +4 -1
  6. data/README.md +27 -15
  7. data/Rakefile +2 -0
  8. data/gemfiles/activerecord-6.0/Gemfile.base +4 -0
  9. data/gemfiles/activerecord-6.0/Gemfile.mysql2 +10 -0
  10. data/gemfiles/activerecord-6.0/Gemfile.postgresql +10 -0
  11. data/gemfiles/activerecord-6.0/Gemfile.sqlite3 +10 -0
  12. data/gemfiles/activerecord-6.1/Gemfile.base +4 -0
  13. data/gemfiles/activerecord-6.1/Gemfile.mysql2 +10 -0
  14. data/gemfiles/activerecord-6.1/Gemfile.postgresql +10 -0
  15. data/gemfiles/activerecord-6.1/Gemfile.sqlite3 +10 -0
  16. data/gemfiles/activerecord-7.0/Gemfile.base +4 -0
  17. data/gemfiles/activerecord-7.0/Gemfile.mysql2 +10 -0
  18. data/gemfiles/activerecord-7.0/Gemfile.postgresql +10 -0
  19. data/gemfiles/activerecord-7.0/Gemfile.sqlite3 +10 -0
  20. data/lib/schema_plus/views/active_record/connection_adapters/abstract_adapter.rb +2 -0
  21. data/lib/schema_plus/views/active_record/connection_adapters/mysql2_adapter.rb +2 -0
  22. data/lib/schema_plus/views/active_record/connection_adapters/postgresql_adapter.rb +2 -0
  23. data/lib/schema_plus/views/active_record/connection_adapters/sqlite3_adapter.rb +2 -0
  24. data/lib/schema_plus/views/active_record/migration/command_recorder.rb +2 -0
  25. data/lib/schema_plus/views/middleware.rb +3 -20
  26. data/lib/schema_plus/views/schema_dump.rb +28 -0
  27. data/lib/schema_plus/views/version.rb +3 -1
  28. data/lib/schema_plus/views.rb +3 -0
  29. data/lib/schema_plus_views.rb +2 -0
  30. data/schema_dev.yml +7 -2
  31. data/schema_plus_views.gemspec +9 -8
  32. data/spec/dumper_spec.rb +2 -0
  33. data/spec/introspection_spec.rb +2 -0
  34. data/spec/middleware_spec.rb +2 -0
  35. data/spec/migration_spec.rb +2 -0
  36. data/spec/named_schemas_spec.rb +2 -0
  37. data/spec/sanity_spec.rb +2 -0
  38. data/spec/spec_helper.rb +3 -2
  39. metadata +35 -43
  40. data/.travis.yml +0 -89
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4ff5c6a7f05fbebbb07b6b84ec71761cc533640f3affe94d3e3153645a5599cc
4
- data.tar.gz: 8f79673795c32b02c6ca0ff80495e115cdd3c9caf24e73c8fcf7c4ade95b4923
3
+ metadata.gz: 8488b18b4bda00ae806bf8dcd52367e6f59b22b2dd5e01cf34ae1749aed7a067
4
+ data.tar.gz: 832ccae549c83a189933034e2e8eb28f7d1ff7d4a1fd0306a125a09ee3401cff
5
5
  SHA512:
6
- metadata.gz: 928a52a3e5e42e5e745754a35ad03244dba6fadb7d8681dc48b20643aaaa34675ce0e9befd4d58a6a3139bdaafab132cc5815d4f7be021f78a77eddbf8486ab8
7
- data.tar.gz: 674f0f9bcb0d7cbda52e9d32a2b21d67e3a095f9c2970a34b55db9146d8bee78379fe4e83c37f951b8aacf8c838d11159a35af12169f27bedf97b1ef6ea4adb2
6
+ metadata.gz: 0e88b4ffe5417e860f3fb1d1f6a07aeff83352f976d75a0b3ffbb46d90d27b58e19527a802d25ea0f29536cdd138c121157c7272364003ee21b474d2f8677fad
7
+ data.tar.gz: 2b1d72485341f1ad9bf464540a9222cfb3d3c231c976323a8bd7110038f22268361e4fd8088532190f41267a61ca32b2d7d3aa94976b834e447d4909abfd83db
@@ -0,0 +1,329 @@
1
+ # This file was auto-generated by the schema_dev tool, based on the data in
2
+ # ./schema_dev.yml
3
+ # Please do not edit this file; any changes will be overwritten next time
4
+ # schema_dev gets run.
5
+ ---
6
+ name: CI PR Builds
7
+ 'on':
8
+ push:
9
+ branches:
10
+ - master
11
+ pull_request:
12
+ concurrency:
13
+ group: ci-${{ github.ref }}
14
+ cancel-in-progress: true
15
+ jobs:
16
+ test:
17
+ runs-on: ubuntu-latest
18
+ strategy:
19
+ fail-fast: false
20
+ matrix:
21
+ ruby:
22
+ - '2.5'
23
+ - '2.7'
24
+ - '3.0'
25
+ - '3.1'
26
+ activerecord:
27
+ - '5.2'
28
+ - '6.0'
29
+ - '6.1'
30
+ - '7.0'
31
+ db:
32
+ - mysql2
33
+ - sqlite3
34
+ - skip
35
+ dbversion:
36
+ - skip
37
+ exclude:
38
+ - ruby: '3.0'
39
+ activerecord: '5.2'
40
+ - ruby: '3.1'
41
+ activerecord: '5.2'
42
+ - ruby: '2.5'
43
+ activerecord: '7.0'
44
+ - db: skip
45
+ dbversion: skip
46
+ include:
47
+ - ruby: '2.5'
48
+ activerecord: '5.2'
49
+ db: postgresql
50
+ dbversion: '9.6'
51
+ - ruby: '2.5'
52
+ activerecord: '5.2'
53
+ db: postgresql
54
+ dbversion: '10'
55
+ - ruby: '2.5'
56
+ activerecord: '5.2'
57
+ db: postgresql
58
+ dbversion: '11'
59
+ - ruby: '2.5'
60
+ activerecord: '5.2'
61
+ db: postgresql
62
+ dbversion: '12'
63
+ - ruby: '2.5'
64
+ activerecord: '6.0'
65
+ db: postgresql
66
+ dbversion: '9.6'
67
+ - ruby: '2.5'
68
+ activerecord: '6.0'
69
+ db: postgresql
70
+ dbversion: '10'
71
+ - ruby: '2.5'
72
+ activerecord: '6.0'
73
+ db: postgresql
74
+ dbversion: '11'
75
+ - ruby: '2.5'
76
+ activerecord: '6.0'
77
+ db: postgresql
78
+ dbversion: '12'
79
+ - ruby: '2.5'
80
+ activerecord: '6.1'
81
+ db: postgresql
82
+ dbversion: '9.6'
83
+ - ruby: '2.5'
84
+ activerecord: '6.1'
85
+ db: postgresql
86
+ dbversion: '10'
87
+ - ruby: '2.5'
88
+ activerecord: '6.1'
89
+ db: postgresql
90
+ dbversion: '11'
91
+ - ruby: '2.5'
92
+ activerecord: '6.1'
93
+ db: postgresql
94
+ dbversion: '12'
95
+ - ruby: '2.7'
96
+ activerecord: '5.2'
97
+ db: postgresql
98
+ dbversion: '9.6'
99
+ - ruby: '2.7'
100
+ activerecord: '5.2'
101
+ db: postgresql
102
+ dbversion: '10'
103
+ - ruby: '2.7'
104
+ activerecord: '5.2'
105
+ db: postgresql
106
+ dbversion: '11'
107
+ - ruby: '2.7'
108
+ activerecord: '5.2'
109
+ db: postgresql
110
+ dbversion: '12'
111
+ - ruby: '2.7'
112
+ activerecord: '6.0'
113
+ db: postgresql
114
+ dbversion: '9.6'
115
+ - ruby: '2.7'
116
+ activerecord: '6.0'
117
+ db: postgresql
118
+ dbversion: '10'
119
+ - ruby: '2.7'
120
+ activerecord: '6.0'
121
+ db: postgresql
122
+ dbversion: '11'
123
+ - ruby: '2.7'
124
+ activerecord: '6.0'
125
+ db: postgresql
126
+ dbversion: '12'
127
+ - ruby: '2.7'
128
+ activerecord: '6.1'
129
+ db: postgresql
130
+ dbversion: '9.6'
131
+ - ruby: '2.7'
132
+ activerecord: '6.1'
133
+ db: postgresql
134
+ dbversion: '10'
135
+ - ruby: '2.7'
136
+ activerecord: '6.1'
137
+ db: postgresql
138
+ dbversion: '11'
139
+ - ruby: '2.7'
140
+ activerecord: '6.1'
141
+ db: postgresql
142
+ dbversion: '12'
143
+ - ruby: '2.7'
144
+ activerecord: '7.0'
145
+ db: postgresql
146
+ dbversion: '9.6'
147
+ - ruby: '2.7'
148
+ activerecord: '7.0'
149
+ db: postgresql
150
+ dbversion: '10'
151
+ - ruby: '2.7'
152
+ activerecord: '7.0'
153
+ db: postgresql
154
+ dbversion: '11'
155
+ - ruby: '2.7'
156
+ activerecord: '7.0'
157
+ db: postgresql
158
+ dbversion: '12'
159
+ - ruby: '3.0'
160
+ activerecord: '6.0'
161
+ db: postgresql
162
+ dbversion: '9.6'
163
+ - ruby: '3.0'
164
+ activerecord: '6.0'
165
+ db: postgresql
166
+ dbversion: '10'
167
+ - ruby: '3.0'
168
+ activerecord: '6.0'
169
+ db: postgresql
170
+ dbversion: '11'
171
+ - ruby: '3.0'
172
+ activerecord: '6.0'
173
+ db: postgresql
174
+ dbversion: '12'
175
+ - ruby: '3.0'
176
+ activerecord: '6.1'
177
+ db: postgresql
178
+ dbversion: '9.6'
179
+ - ruby: '3.0'
180
+ activerecord: '6.1'
181
+ db: postgresql
182
+ dbversion: '10'
183
+ - ruby: '3.0'
184
+ activerecord: '6.1'
185
+ db: postgresql
186
+ dbversion: '11'
187
+ - ruby: '3.0'
188
+ activerecord: '6.1'
189
+ db: postgresql
190
+ dbversion: '12'
191
+ - ruby: '3.0'
192
+ activerecord: '7.0'
193
+ db: postgresql
194
+ dbversion: '9.6'
195
+ - ruby: '3.0'
196
+ activerecord: '7.0'
197
+ db: postgresql
198
+ dbversion: '10'
199
+ - ruby: '3.0'
200
+ activerecord: '7.0'
201
+ db: postgresql
202
+ dbversion: '11'
203
+ - ruby: '3.0'
204
+ activerecord: '7.0'
205
+ db: postgresql
206
+ dbversion: '12'
207
+ - ruby: '3.1'
208
+ activerecord: '6.0'
209
+ db: postgresql
210
+ dbversion: '9.6'
211
+ - ruby: '3.1'
212
+ activerecord: '6.0'
213
+ db: postgresql
214
+ dbversion: '10'
215
+ - ruby: '3.1'
216
+ activerecord: '6.0'
217
+ db: postgresql
218
+ dbversion: '11'
219
+ - ruby: '3.1'
220
+ activerecord: '6.0'
221
+ db: postgresql
222
+ dbversion: '12'
223
+ - ruby: '3.1'
224
+ activerecord: '6.1'
225
+ db: postgresql
226
+ dbversion: '9.6'
227
+ - ruby: '3.1'
228
+ activerecord: '6.1'
229
+ db: postgresql
230
+ dbversion: '10'
231
+ - ruby: '3.1'
232
+ activerecord: '6.1'
233
+ db: postgresql
234
+ dbversion: '11'
235
+ - ruby: '3.1'
236
+ activerecord: '6.1'
237
+ db: postgresql
238
+ dbversion: '12'
239
+ - ruby: '3.1'
240
+ activerecord: '7.0'
241
+ db: postgresql
242
+ dbversion: '9.6'
243
+ - ruby: '3.1'
244
+ activerecord: '7.0'
245
+ db: postgresql
246
+ dbversion: '10'
247
+ - ruby: '3.1'
248
+ activerecord: '7.0'
249
+ db: postgresql
250
+ dbversion: '11'
251
+ - ruby: '3.1'
252
+ activerecord: '7.0'
253
+ db: postgresql
254
+ dbversion: '12'
255
+ env:
256
+ BUNDLE_GEMFILE: "${{ github.workspace }}/gemfiles/activerecord-${{ matrix.activerecord }}/Gemfile.${{ matrix.db }}"
257
+ MYSQL_DB_HOST: 127.0.0.1
258
+ MYSQL_DB_USER: root
259
+ MYSQL_DB_PASS: database
260
+ POSTGRESQL_DB_HOST: 127.0.0.1
261
+ POSTGRESQL_DB_USER: schema_plus_test
262
+ POSTGRESQL_DB_PASS: database
263
+ steps:
264
+ - uses: actions/checkout@v2
265
+ - name: Set up Ruby
266
+ uses: ruby/setup-ruby@v1
267
+ with:
268
+ ruby-version: "${{ matrix.ruby }}"
269
+ bundler-cache: true
270
+ - name: Run bundle update
271
+ run: bundle update
272
+ - name: Start Mysql
273
+ if: matrix.db == 'mysql2'
274
+ run: |
275
+ docker run --rm --detach \
276
+ -e MYSQL_ROOT_PASSWORD=$MYSQL_DB_PASS \
277
+ -p 3306:3306 \
278
+ --health-cmd "mysqladmin ping --host=127.0.0.1 --password=$MYSQL_DB_PASS --silent" \
279
+ --health-interval 5s \
280
+ --health-timeout 5s \
281
+ --health-retries 5 \
282
+ --name database mysql:5.6
283
+ - name: Start Postgresql
284
+ if: matrix.db == 'postgresql'
285
+ run: |
286
+ docker run --rm --detach \
287
+ -e POSTGRES_USER=$POSTGRESQL_DB_USER \
288
+ -e POSTGRES_PASSWORD=$POSTGRESQL_DB_PASS \
289
+ -p 5432:5432 \
290
+ --health-cmd "pg_isready -q" \
291
+ --health-interval 5s \
292
+ --health-timeout 5s \
293
+ --health-retries 5 \
294
+ --name database postgres:${{ matrix.dbversion }}
295
+ - name: Wait for database to start
296
+ if: "(matrix.db == 'postgresql' || matrix.db == 'mysql2')"
297
+ run: |
298
+ COUNT=0
299
+ ATTEMPTS=20
300
+ until [[ $COUNT -eq $ATTEMPTS ]]; do
301
+ [ "$(docker inspect -f {{.State.Health.Status}} database)" == "healthy" ] && break
302
+ echo $(( COUNT++ )) > /dev/null
303
+ sleep 2
304
+ done
305
+ - name: Create testing database
306
+ if: "(matrix.db == 'postgresql' || matrix.db == 'mysql2')"
307
+ run: bundle exec rake create_ci_database
308
+ - name: Run tests
309
+ run: bundle exec rake spec
310
+ - name: Shutdown database
311
+ if: always() && (matrix.db == 'postgresql' || matrix.db == 'mysql2')
312
+ run: docker stop database
313
+ - name: Coveralls Parallel
314
+ if: "${{ !env.ACT }}"
315
+ uses: coverallsapp/github-action@master
316
+ with:
317
+ github-token: "${{ secrets.GITHUB_TOKEN }}"
318
+ flag-name: run-${{ matrix.ruby }}-${{ matrix.activerecord }}-${{ matrix.db }}-${{ matrix.dbversion }}
319
+ parallel: true
320
+ finish:
321
+ needs: test
322
+ runs-on: ubuntu-latest
323
+ steps:
324
+ - name: Coveralls Finished
325
+ if: "${{ !env.ACT }}"
326
+ uses: coverallsapp/github-action@master
327
+ with:
328
+ github-token: "${{ secrets.GITHUB_TOKEN }}"
329
+ parallel-finished: true
data/.gitignore CHANGED
@@ -2,6 +2,7 @@
2
2
  /tmp
3
3
  /pkg
4
4
  /Gemfile.local
5
+ /.idea
5
6
 
6
7
  *.lock
7
8
  *.log
data/.simplecov ADDED
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ SimpleCov.configure do
4
+ enable_coverage :branch
5
+ add_filter '/spec/'
6
+
7
+ add_group 'Binaries', '/bin/'
8
+ add_group 'Libraries', '/lib/'
9
+
10
+ if ENV['CI']
11
+ require 'simplecov-lcov'
12
+
13
+ SimpleCov::Formatter::LcovFormatter.config do |c|
14
+ c.report_with_single_file = true
15
+ c.single_report_path = 'coverage/lcov.info'
16
+ end
17
+
18
+ formatter SimpleCov::Formatter::LcovFormatter
19
+ end
20
+ end
data/Gemfile CHANGED
@@ -1,5 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source "http://rubygems.org"
2
4
 
3
5
  gemspec
4
6
 
5
- File.exist?(gemfile_local = File.expand_path('../Gemfile.local', __FILE__)) and eval File.read(gemfile_local), binding, gemfile_local
7
+ gemfile_local = File.expand_path '../Gemfile.local', __FILE__
8
+ eval File.read(gemfile_local), binding, gemfile_local if File.exist? gemfile_local
data/README.md CHANGED
@@ -1,7 +1,6 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/schema_plus_views.svg)](http://badge.fury.io/rb/schema_plus_views)
2
- [![Build Status](https://secure.travis-ci.org/SchemaPlus/schema_plus_views.svg)](http://travis-ci.org/SchemaPlus/schema_plus_views)
3
- [![Coverage Status](https://img.shields.io/coveralls/SchemaPlus/schema_plus_views.svg)](https://coveralls.io/r/SchemaPlus/schema_plus_views)
4
- [![Dependency Status](https://gemnasium.com/lomba/schema_plus_views.svg)](https://gemnasium.com/SchemaPlus/schema_plus_views)
2
+ [![Build Status](https://github.com/SchemaPlus/schema_plus_views/actions/workflows/pr.yml/badge.svg)](http://github.com/SchemaPlus/schema_plus_views/actions)
3
+ [![Coverage Status](https://coveralls.io/github/SchemaPlus/schema_plus_views/badge.svg)](https://coveralls.io/github/SchemaPlus/schema_plus_views)
5
4
 
6
5
  # SchemaPlus::Views
7
6
 
@@ -28,8 +27,19 @@ SchemaPlus::Views is tested on:
28
27
 
29
28
  <!-- SCHEMA_DEV: MATRIX - begin -->
30
29
  <!-- These lines are auto-generated by schema_dev based on schema_dev.yml -->
31
- * ruby **2.5.9** with activerecord **5.2**, using **mysql2**, **sqlite3** or **postgresql**
32
- * ruby **2.7.3** with activerecord **5.2**, using **mysql2**, **sqlite3** or **postgresql**
30
+ * ruby **2.5** with activerecord **5.2**, using **mysql2**, **sqlite3**, **postgresql:9.6**, **postgresql:10**, **postgresql:11** or **postgresql:12**
31
+ * ruby **2.5** with activerecord **6.0**, using **mysql2**, **sqlite3**, **postgresql:9.6**, **postgresql:10**, **postgresql:11** or **postgresql:12**
32
+ * ruby **2.5** with activerecord **6.1**, using **mysql2**, **sqlite3**, **postgresql:9.6**, **postgresql:10**, **postgresql:11** or **postgresql:12**
33
+ * ruby **2.7** with activerecord **5.2**, using **mysql2**, **sqlite3**, **postgresql:9.6**, **postgresql:10**, **postgresql:11** or **postgresql:12**
34
+ * ruby **2.7** with activerecord **6.0**, using **mysql2**, **sqlite3**, **postgresql:9.6**, **postgresql:10**, **postgresql:11** or **postgresql:12**
35
+ * ruby **2.7** with activerecord **6.1**, using **mysql2**, **sqlite3**, **postgresql:9.6**, **postgresql:10**, **postgresql:11** or **postgresql:12**
36
+ * ruby **2.7** with activerecord **7.0**, using **mysql2**, **sqlite3**, **postgresql:9.6**, **postgresql:10**, **postgresql:11** or **postgresql:12**
37
+ * ruby **3.0** with activerecord **6.0**, using **mysql2**, **sqlite3**, **postgresql:9.6**, **postgresql:10**, **postgresql:11** or **postgresql:12**
38
+ * ruby **3.0** with activerecord **6.1**, using **mysql2**, **sqlite3**, **postgresql:9.6**, **postgresql:10**, **postgresql:11** or **postgresql:12**
39
+ * ruby **3.0** with activerecord **7.0**, using **mysql2**, **sqlite3**, **postgresql:9.6**, **postgresql:10**, **postgresql:11** or **postgresql:12**
40
+ * ruby **3.1** with activerecord **6.0**, using **mysql2**, **sqlite3**, **postgresql:9.6**, **postgresql:10**, **postgresql:11** or **postgresql:12**
41
+ * ruby **3.1** with activerecord **6.1**, using **mysql2**, **sqlite3**, **postgresql:9.6**, **postgresql:10**, **postgresql:11** or **postgresql:12**
42
+ * ruby **3.1** with activerecord **7.0**, using **mysql2**, **sqlite3**, **postgresql:9.6**, **postgresql:10**, **postgresql:11** or **postgresql:12**
33
43
 
34
44
  <!-- SCHEMA_DEV: MATRIX - end -->
35
45
 
@@ -189,16 +199,19 @@ options in `env.options`
189
199
 
190
200
  ## History
191
201
 
192
- * 0.4.0 - Added support for Rails 5.2 and materialized views in PostgreSQL
193
- * 0.3.1 - Upgrade schema_plus_core and schema_dev dependencies
194
- * 0.3.0
202
+ * **1.0.1** - Add AR 6.1, 7.0 and Ruby 3.1 support
203
+ * **1.0.0** - Add ruby 3 and AR 6.0, drop Ruy < 2.5
204
+ * **0.4.1** - Corrected spacing around dumped schema
205
+ * **0.4.0** - Added support for Rails 5.2 and materialized views in PostgreSQL
206
+ * **0.3.1** - Upgrade schema_plus_core and schema_dev dependencies
207
+ * **0.3.0**
195
208
  - Added middleware stacks
196
209
  - Bug fix: view_definition: strip white space from result (postgresql)
197
- * 0.2.3 - Remove unnecessary escaping in dump; use single-quote heredoc
198
- * 0.2.2 - Prettier dumps: use heredoc for definition string
199
- * 0.2.1 - Fix db:rollback
200
- * 0.2.0 - Added :allow_replace option (thanks to [@hcarver](https://github.com/hcarver))
201
- * 0.1.0 - Initial release, extracted from schema_plus 1.x
210
+ * **0.2.3** - Remove unnecessary escaping in dump; use single-quote heredoc
211
+ * **0.2.2** - Prettier dumps: use heredoc for definition string
212
+ * **0.2.1** - Fix db:rollback
213
+ * **0.2.0** - Added :allow_replace option (thanks to [@hcarver](https://github.com/hcarver))
214
+ * **0.1.0** - Initial release, extracted from schema_plus 1.x
202
215
 
203
216
  ## Development & Testing
204
217
 
@@ -211,7 +224,7 @@ Some things to know about to help you develop and test:
211
224
  * **schema_dev**: SchemaPlus::Views uses [schema_dev](https://github.com/SchemaPlus/schema_dev) to
212
225
  facilitate running rspec tests on the matrix of ruby, activerecord, and database
213
226
  versions that the gem supports, both locally and on
214
- [travis-ci](http://travis-ci.org/SchemaPlus/schema_plus_views)
227
+ [github actions](https://github.com/SchemaPlus/schema_plus_views/actions)
215
228
 
216
229
  To to run rspec locally on the full matrix, do:
217
230
 
@@ -223,7 +236,6 @@ Some things to know about to help you develop and test:
223
236
  The matrix of configurations is specified in `schema_dev.yml` in
224
237
  the project root.
225
238
 
226
-
227
239
  <!-- SCHEMA_DEV: TEMPLATE USES SCHEMA_DEV - end -->
228
240
 
229
241
  <!-- SCHEMA_DEV: TEMPLATE USES SCHEMA_PLUS_CORE - begin -->
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler'
2
4
  Bundler::GemHelper.install_tasks
3
5
 
@@ -0,0 +1,4 @@
1
+ base_gemfile = File.expand_path('../../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile)
3
+
4
+ gem "activerecord", ">= 6.0", "< 6.1"
@@ -0,0 +1,10 @@
1
+ base_gemfile = File.expand_path('../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile), binding, base_gemfile
3
+
4
+ platform :ruby do
5
+ gem "mysql2"
6
+ end
7
+
8
+ platform :jruby do
9
+ gem 'activerecord-jdbcmysql-adapter'
10
+ end
@@ -0,0 +1,10 @@
1
+ base_gemfile = File.expand_path('../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile), binding, base_gemfile
3
+
4
+ platform :ruby do
5
+ gem "pg"
6
+ end
7
+
8
+ platform :jruby do
9
+ gem 'activerecord-jdbcpostgresql-adapter'
10
+ end
@@ -0,0 +1,10 @@
1
+ base_gemfile = File.expand_path('../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile), binding, base_gemfile
3
+
4
+ platform :ruby do
5
+ gem "sqlite3"
6
+ end
7
+
8
+ platform :jruby do
9
+ gem 'activerecord-jdbcsqlite3-adapter', '>=1.3.0.beta2'
10
+ end
@@ -0,0 +1,4 @@
1
+ base_gemfile = File.expand_path('../../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile)
3
+
4
+ gem "activerecord", ">= 6.1", "< 6.2"
@@ -0,0 +1,10 @@
1
+ base_gemfile = File.expand_path('../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile), binding, base_gemfile
3
+
4
+ platform :ruby do
5
+ gem "mysql2"
6
+ end
7
+
8
+ platform :jruby do
9
+ gem 'activerecord-jdbcmysql-adapter'
10
+ end
@@ -0,0 +1,10 @@
1
+ base_gemfile = File.expand_path('../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile), binding, base_gemfile
3
+
4
+ platform :ruby do
5
+ gem "pg"
6
+ end
7
+
8
+ platform :jruby do
9
+ gem 'activerecord-jdbcpostgresql-adapter'
10
+ end
@@ -0,0 +1,10 @@
1
+ base_gemfile = File.expand_path('../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile), binding, base_gemfile
3
+
4
+ platform :ruby do
5
+ gem "sqlite3"
6
+ end
7
+
8
+ platform :jruby do
9
+ gem 'activerecord-jdbcsqlite3-adapter', '>=1.3.0.beta2'
10
+ end
@@ -0,0 +1,4 @@
1
+ base_gemfile = File.expand_path('../../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile)
3
+
4
+ gem "activerecord", ">= 7.0", "< 7.1"
@@ -0,0 +1,10 @@
1
+ base_gemfile = File.expand_path('../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile), binding, base_gemfile
3
+
4
+ platform :ruby do
5
+ gem "mysql2"
6
+ end
7
+
8
+ platform :jruby do
9
+ gem 'activerecord-jdbcmysql-adapter'
10
+ end
@@ -0,0 +1,10 @@
1
+ base_gemfile = File.expand_path('../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile), binding, base_gemfile
3
+
4
+ platform :ruby do
5
+ gem "pg"
6
+ end
7
+
8
+ platform :jruby do
9
+ gem 'activerecord-jdbcpostgresql-adapter'
10
+ end
@@ -0,0 +1,10 @@
1
+ base_gemfile = File.expand_path('../Gemfile.base', __FILE__)
2
+ eval File.read(base_gemfile), binding, base_gemfile
3
+
4
+ platform :ruby do
5
+ gem "sqlite3"
6
+ end
7
+
8
+ platform :jruby do
9
+ gem 'activerecord-jdbcsqlite3-adapter', '>=1.3.0.beta2'
10
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SchemaPlus::Views
2
4
  module ActiveRecord
3
5
  module ConnectionAdapters
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SchemaPlus::Views
2
4
  module ActiveRecord
3
5
  module ConnectionAdapters
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SchemaPlus::Views
2
4
  module ActiveRecord
3
5
  module ConnectionAdapters
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SchemaPlus::Views
2
4
  module ActiveRecord
3
5
  module ConnectionAdapters
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SchemaPlus::Views
2
4
  module ActiveRecord
3
5
  module Migration
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SchemaPlus::Views
2
4
  module Middleware
3
5
 
@@ -21,7 +23,7 @@ module SchemaPlus::Views
21
23
  end
22
24
  end
23
25
 
24
- view = View.new(
26
+ view = ::SchemaPlus::Views::SchemaDump::View.new(
25
27
  name: view_name,
26
28
  definition: definition,
27
29
  view_type: view_type,
@@ -47,25 +49,6 @@ module SchemaPlus::Views
47
49
 
48
50
  options
49
51
  end
50
-
51
- # quacks like a SchemaMonkey Dump::Table
52
- class View < KeyStruct[:name, :definition, :view_type, :indexes]
53
- def assemble(stream)
54
- extra_options = ", materialized: true" if view_type == :materialized
55
- heredelim = "END_VIEW_#{name.upcase}"
56
- stream.puts <<~ENDVIEW
57
- create_view "#{name}", <<-'#{heredelim}', :force => true#{extra_options}
58
- #{definition}
59
- #{heredelim}
60
- ENDVIEW
61
-
62
- indexes.each do |index|
63
- stream.write "add_index \"#{name}\", "
64
- index.assemble(stream)
65
- stream.puts ""
66
- end
67
- end
68
- end
69
52
  end
70
53
  end
71
54
 
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SchemaPlus
4
+ module Views
5
+ class SchemaDump
6
+ # quacks like a SchemaMonkey Dump::Table
7
+ class View < Struct.new(:name, :definition, :view_type, :indexes, keyword_init: true)
8
+ def assemble(stream)
9
+ extra_options = ", materialized: true" if view_type == :materialized
10
+ heredelim = "END_VIEW_#{name.upcase}"
11
+ stream.puts <<~ENDVIEW
12
+ create_view "#{name}", <<-'#{heredelim}', :force => true#{extra_options}
13
+ #{definition}
14
+ #{heredelim}
15
+ ENDVIEW
16
+ stream.puts
17
+
18
+ indexes.each do |index|
19
+ stream.write " add_index \"#{name}\", "
20
+ index.assemble(stream)
21
+ stream.puts ""
22
+ end
23
+ stream.puts ""
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SchemaPlus
2
4
  module Views
3
- VERSION = "0.4.0"
5
+ VERSION = '1.0.1'
4
6
  end
5
7
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'schema_plus/core'
2
4
 
3
5
  module SchemaPlus
@@ -9,6 +11,7 @@ require_relative 'views/version'
9
11
  require_relative 'views/active_record/connection_adapters/abstract_adapter'
10
12
  require_relative 'views/active_record/migration/command_recorder'
11
13
  require_relative 'views/middleware'
14
+ require_relative 'views/schema_dump'
12
15
 
13
16
  module SchemaPlus::Views
14
17
  module ActiveRecord
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'schema_plus/views'
data/schema_dev.yml CHANGED
@@ -1,8 +1,13 @@
1
1
  ruby:
2
- - 2.5.9
3
- - 2.7.3
2
+ - 2.5
3
+ - 2.7
4
+ - 3.0
5
+ - 3.1
4
6
  activerecord:
5
7
  - 5.2
8
+ - 6.0
9
+ - 6.1
10
+ - 7.0
6
11
  db:
7
12
  - mysql2
8
13
  - sqlite3
@@ -1,4 +1,5 @@
1
- # coding: utf-8
1
+ # frozen_string_literal: true
2
+
2
3
  lib = File.expand_path('../lib', __FILE__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require 'schema_plus/views/version'
@@ -17,13 +18,13 @@ Gem::Specification.new do |gem|
17
18
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
19
  gem.require_paths = ["lib"]
19
20
 
20
- gem.add_dependency "activerecord", "~> 5.2"
21
- gem.add_dependency "schema_plus_core"
21
+ gem.required_ruby_version = '>= 2.5'
22
+
23
+ gem.add_dependency "activerecord", '>= 5.2', '< 7.1'
24
+ gem.add_dependency "schema_plus_core", '~> 3.1.0'
22
25
 
23
26
  gem.add_development_dependency "bundler"
24
- gem.add_development_dependency "rake", "~> 10.0"
25
- gem.add_development_dependency "rspec", "~> 3.0"
26
- gem.add_development_dependency "schema_dev", "~> 3.13.1"
27
- gem.add_development_dependency "simplecov"
28
- gem.add_development_dependency "simplecov-gem-profile"
27
+ gem.add_development_dependency "rake", '~> 13.0'
28
+ gem.add_development_dependency "rspec", '~> 3.0'
29
+ gem.add_development_dependency "schema_dev", '~> 4.2.0'
29
30
  end
data/spec/dumper_spec.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  class Item < ActiveRecord::Base
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  class Item < ActiveRecord::Base
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  module TestMiddleware
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  class Item < ActiveRecord::Base
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe "with multiple schemas" do
data/spec/sanity_spec.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
 
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'simplecov'
2
- require 'simplecov-gem-profile'
3
- SimpleCov.start "gem"
4
+ SimpleCov.start unless SimpleCov.running
4
5
 
5
6
  $LOAD_PATH.unshift(File.dirname(__FILE__))
6
7
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
metadata CHANGED
@@ -1,43 +1,49 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: schema_plus_views
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ronen barzel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-14 00:00:00.000000000 Z
11
+ date: 2022-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '5.2'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '7.1'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
25
28
  - !ruby/object:Gem::Version
26
29
  version: '5.2'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '7.1'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: schema_plus_core
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
- - - ">="
37
+ - - "~>"
32
38
  - !ruby/object:Gem::Version
33
- version: '0'
39
+ version: 3.1.0
34
40
  type: :runtime
35
41
  prerelease: false
36
42
  version_requirements: !ruby/object:Gem::Requirement
37
43
  requirements:
38
- - - ">="
44
+ - - "~>"
39
45
  - !ruby/object:Gem::Version
40
- version: '0'
46
+ version: 3.1.0
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: bundler
43
49
  requirement: !ruby/object:Gem::Requirement
@@ -58,14 +64,14 @@ dependencies:
58
64
  requirements:
59
65
  - - "~>"
60
66
  - !ruby/object:Gem::Version
61
- version: '10.0'
67
+ version: '13.0'
62
68
  type: :development
63
69
  prerelease: false
64
70
  version_requirements: !ruby/object:Gem::Requirement
65
71
  requirements:
66
72
  - - "~>"
67
73
  - !ruby/object:Gem::Version
68
- version: '10.0'
74
+ version: '13.0'
69
75
  - !ruby/object:Gem::Dependency
70
76
  name: rspec
71
77
  requirement: !ruby/object:Gem::Requirement
@@ -86,42 +92,14 @@ dependencies:
86
92
  requirements:
87
93
  - - "~>"
88
94
  - !ruby/object:Gem::Version
89
- version: 3.13.1
95
+ version: 4.2.0
90
96
  type: :development
91
97
  prerelease: false
92
98
  version_requirements: !ruby/object:Gem::Requirement
93
99
  requirements:
94
100
  - - "~>"
95
101
  - !ruby/object:Gem::Version
96
- version: 3.13.1
97
- - !ruby/object:Gem::Dependency
98
- name: simplecov
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
- - !ruby/object:Gem::Dependency
112
- name: simplecov-gem-profile
113
- requirement: !ruby/object:Gem::Requirement
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
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- version: '0'
102
+ version: 4.2.0
125
103
  description:
126
104
  email:
127
105
  - ronen@barzel.org
@@ -129,8 +107,9 @@ executables: []
129
107
  extensions: []
130
108
  extra_rdoc_files: []
131
109
  files:
110
+ - ".github/workflows/prs.yml"
132
111
  - ".gitignore"
133
- - ".travis.yml"
112
+ - ".simplecov"
134
113
  - Gemfile
135
114
  - LICENSE.txt
136
115
  - README.md
@@ -140,6 +119,18 @@ files:
140
119
  - gemfiles/activerecord-5.2/Gemfile.mysql2
141
120
  - gemfiles/activerecord-5.2/Gemfile.postgresql
142
121
  - gemfiles/activerecord-5.2/Gemfile.sqlite3
122
+ - gemfiles/activerecord-6.0/Gemfile.base
123
+ - gemfiles/activerecord-6.0/Gemfile.mysql2
124
+ - gemfiles/activerecord-6.0/Gemfile.postgresql
125
+ - gemfiles/activerecord-6.0/Gemfile.sqlite3
126
+ - gemfiles/activerecord-6.1/Gemfile.base
127
+ - gemfiles/activerecord-6.1/Gemfile.mysql2
128
+ - gemfiles/activerecord-6.1/Gemfile.postgresql
129
+ - gemfiles/activerecord-6.1/Gemfile.sqlite3
130
+ - gemfiles/activerecord-7.0/Gemfile.base
131
+ - gemfiles/activerecord-7.0/Gemfile.mysql2
132
+ - gemfiles/activerecord-7.0/Gemfile.postgresql
133
+ - gemfiles/activerecord-7.0/Gemfile.sqlite3
143
134
  - lib/schema_plus/views.rb
144
135
  - lib/schema_plus/views/active_record/connection_adapters/abstract_adapter.rb
145
136
  - lib/schema_plus/views/active_record/connection_adapters/mysql2_adapter.rb
@@ -147,6 +138,7 @@ files:
147
138
  - lib/schema_plus/views/active_record/connection_adapters/sqlite3_adapter.rb
148
139
  - lib/schema_plus/views/active_record/migration/command_recorder.rb
149
140
  - lib/schema_plus/views/middleware.rb
141
+ - lib/schema_plus/views/schema_dump.rb
150
142
  - lib/schema_plus/views/version.rb
151
143
  - lib/schema_plus_views.rb
152
144
  - schema_dev.yml
@@ -170,14 +162,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
170
162
  requirements:
171
163
  - - ">="
172
164
  - !ruby/object:Gem::Version
173
- version: '0'
165
+ version: '2.5'
174
166
  required_rubygems_version: !ruby/object:Gem::Requirement
175
167
  requirements:
176
168
  - - ">="
177
169
  - !ruby/object:Gem::Version
178
170
  version: '0'
179
171
  requirements: []
180
- rubygems_version: 3.0.8
172
+ rubygems_version: 3.1.6
181
173
  signing_key:
182
174
  specification_version: 4
183
175
  summary: Adds support for views to ActiveRecord
data/.travis.yml DELETED
@@ -1,89 +0,0 @@
1
- # This file was auto-generated by the schema_dev tool, based on the data in
2
- # ./schema_dev.yml
3
- # Please do not edit this file; any changes will be overwritten next time
4
- # schema_dev gets run.
5
- ---
6
- rvm:
7
- - 2.5.9
8
- - 2.7.3
9
- gemfile:
10
- - gemfiles/activerecord-5.2/Gemfile.sqlite3
11
- before_script: bundle exec rake create_databases
12
- after_script: bundle exec rake drop_databases
13
- script: bundle exec rake travis
14
- jobs:
15
- include:
16
- - gemfile: gemfiles/activerecord-5.2/Gemfile.mysql2
17
- rvm: 2.5.9
18
- services:
19
- - mysql
20
- env: MYSQL_DB_USER=travis
21
- - gemfile: gemfiles/activerecord-5.2/Gemfile.postgresql
22
- rvm: 2.5.9
23
- addons:
24
- postgresql: '10'
25
- apt:
26
- packages:
27
- - postgresql-10
28
- - postgresql-client-10
29
- env: POSTGRESQL_DB_USER=postgres
30
- - gemfile: gemfiles/activerecord-5.2/Gemfile.postgresql
31
- rvm: 2.5.9
32
- addons:
33
- postgresql: '11'
34
- apt:
35
- packages:
36
- - postgresql-11
37
- - postgresql-client-11
38
- env: POSTGRESQL_DB_USER=travis PGPORT=5433
39
- - gemfile: gemfiles/activerecord-5.2/Gemfile.postgresql
40
- rvm: 2.5.9
41
- addons:
42
- postgresql: '12'
43
- apt:
44
- packages:
45
- - postgresql-12
46
- - postgresql-client-12
47
- env: POSTGRESQL_DB_USER=travis PGPORT=5433
48
- - gemfile: gemfiles/activerecord-5.2/Gemfile.postgresql
49
- rvm: 2.5.9
50
- addons:
51
- postgresql: '9.6'
52
- env: POSTGRESQL_DB_USER=postgres
53
- - gemfile: gemfiles/activerecord-5.2/Gemfile.mysql2
54
- rvm: 2.7.3
55
- services:
56
- - mysql
57
- env: MYSQL_DB_USER=travis
58
- - gemfile: gemfiles/activerecord-5.2/Gemfile.postgresql
59
- rvm: 2.7.3
60
- addons:
61
- postgresql: '11'
62
- apt:
63
- packages:
64
- - postgresql-11
65
- - postgresql-client-11
66
- env: POSTGRESQL_DB_USER=travis PGPORT=5433
67
- - gemfile: gemfiles/activerecord-5.2/Gemfile.postgresql
68
- rvm: 2.7.3
69
- addons:
70
- postgresql: '12'
71
- apt:
72
- packages:
73
- - postgresql-12
74
- - postgresql-client-12
75
- env: POSTGRESQL_DB_USER=travis PGPORT=5433
76
- - gemfile: gemfiles/activerecord-5.2/Gemfile.postgresql
77
- rvm: 2.7.3
78
- addons:
79
- postgresql: '10'
80
- apt:
81
- packages:
82
- - postgresql-10
83
- - postgresql-client-10
84
- env: POSTGRESQL_DB_USER=postgres
85
- - gemfile: gemfiles/activerecord-5.2/Gemfile.postgresql
86
- rvm: 2.7.3
87
- addons:
88
- postgresql: '9.6'
89
- env: POSTGRESQL_DB_USER=postgres