schema_plus 2.0.0.pre2 → 2.0.0.pre3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -3
- data/Gemfile +2 -0
- data/README.md +4 -4
- data/TODO.md +3 -10
- data/gemfiles/{rails-4.2 → activerecord-4.2}/Gemfile.base +1 -1
- data/gemfiles/{rails-4.2 → activerecord-4.2}/Gemfile.mysql2 +0 -0
- data/gemfiles/{rails-4.2 → activerecord-4.2}/Gemfile.postgresql +0 -0
- data/gemfiles/{rails-4.2 → activerecord-4.2}/Gemfile.sqlite3 +0 -0
- data/lib/schema_plus.rb +13 -121
- data/lib/schema_plus/version.rb +1 -1
- data/lib/schema_plus_columns.rb +7 -0
- data/lib/{schema_column_plus → schema_plus_columns}/active_record/connection_adapters/column.rb +1 -1
- data/lib/schema_plus_columns/middleware/model.rb +16 -0
- data/lib/schema_plus_db_default.rb +13 -0
- data/lib/{schema_db_default → schema_plus_db_default}/active_record/attribute.rb +4 -4
- data/lib/{schema_db_default → schema_plus_db_default}/db_default.rb +1 -1
- data/lib/schema_plus_db_default/middleware.rb +30 -0
- data/lib/{schema_default_expr.rb → schema_plus_default_expr.rb} +6 -6
- data/lib/{schema_default_expr → schema_plus_default_expr}/active_record/connection_adapters/mysql2_adapter.rb +1 -1
- data/lib/{schema_default_expr → schema_plus_default_expr}/active_record/connection_adapters/postgresql_adapter.rb +1 -1
- data/lib/{schema_default_expr → schema_plus_default_expr}/active_record/connection_adapters/sqlite3_adapter.rb +1 -1
- data/lib/{schema_default_expr → schema_plus_default_expr}/middleware.rb +21 -19
- data/lib/schema_plus_enums.rb +6 -0
- data/lib/{schema_pg_enums → schema_plus_enums}/active_record.rb +1 -1
- data/lib/schema_plus_enums/middleware.rb +22 -0
- data/lib/schema_plus_foreign_keys.rb +96 -0
- data/lib/{schema_plus → schema_plus_foreign_keys}/active_record/base.rb +2 -2
- data/lib/{schema_plus → schema_plus_foreign_keys}/active_record/connection_adapters/abstract_adapter.rb +7 -7
- data/lib/{schema_plus → schema_plus_foreign_keys}/active_record/connection_adapters/foreign_key_definition.rb +4 -4
- data/lib/{schema_plus → schema_plus_foreign_keys}/active_record/connection_adapters/mysql2_adapter.rb +9 -9
- data/lib/{schema_plus → schema_plus_foreign_keys}/active_record/connection_adapters/postgresql_adapter.rb +5 -5
- data/lib/schema_plus_foreign_keys/active_record/connection_adapters/schema_statements.rb +33 -0
- data/lib/{schema_plus → schema_plus_foreign_keys}/active_record/connection_adapters/sqlite3_adapter.rb +5 -5
- data/lib/{schema_plus → schema_plus_foreign_keys}/active_record/connection_adapters/table_definition.rb +8 -8
- data/lib/{schema_plus → schema_plus_foreign_keys}/active_record/migration/command_recorder.rb +5 -5
- data/lib/{schema_plus → schema_plus_foreign_keys}/active_record/schema.rb +7 -7
- data/lib/{schema_plus → schema_plus_foreign_keys}/middleware/dumper.rb +11 -26
- data/lib/{schema_plus → schema_plus_foreign_keys}/middleware/migration.rb +14 -15
- data/lib/schema_plus_foreign_keys/middleware/model.rb +15 -0
- data/lib/schema_plus_foreign_keys/version.rb +3 -0
- data/lib/schema_plus_views.rb +16 -0
- data/lib/{schema_views → schema_plus_views}/active_record/connection_adapters/abstract_adapter.rb +1 -1
- data/lib/{schema_views → schema_plus_views}/active_record/connection_adapters/mysql2_adapter.rb +1 -1
- data/lib/{schema_views → schema_plus_views}/active_record/connection_adapters/postgresql_adapter.rb +1 -1
- data/lib/{schema_views → schema_plus_views}/active_record/connection_adapters/sqlite3_adapter.rb +1 -1
- data/lib/schema_plus_views/middleware.rb +49 -0
- data/schema_dev.yml +1 -1
- data/schema_plus.gemspec +3 -2
- data/spec/{schema_column_plus → schema_plus_columns}/column_spec.rb +0 -0
- data/spec/{schema_db_default → schema_plus_db_default}/column_spec.rb +1 -1
- data/spec/{schema_default_expr → schema_plus_default_expr}/column_default_spec.rb +0 -0
- data/spec/schema_plus_default_expr/migration_spec.rb +44 -0
- data/spec/{schema_default_expr → schema_plus_default_expr}/schema_dumper_spec.rb +2 -2
- data/spec/{schema_pg_enums → schema_plus_enums}/enum_spec.rb +0 -0
- data/spec/{schema_pg_enums → schema_plus_enums}/schema_dumper_spec.rb +0 -0
- data/spec/{foreign_key_definition_spec.rb → schema_plus_foreign_keys/foreign_key_definition_spec.rb} +0 -0
- data/spec/{foreign_key_spec.rb → schema_plus_foreign_keys/foreign_key_spec.rb} +2 -2
- data/spec/{migration_spec.rb → schema_plus_foreign_keys/migration_spec.rb} +13 -29
- data/spec/{named_schemas_spec.rb → schema_plus_foreign_keys/named_schemas_spec.rb} +0 -0
- data/spec/{schema_dumper_spec.rb → schema_plus_foreign_keys/schema_dumper_spec.rb} +2 -2
- data/spec/{schema_spec.rb → schema_plus_foreign_keys/schema_spec.rb} +7 -7
- data/spec/{schema_views → schema_plus_views}/named_schemas_spec.rb +7 -7
- data/spec/{schema_views → schema_plus_views}/views_spec.rb +0 -0
- data/spec/spec_helper.rb +3 -3
- metadata +102 -81
- data/init.rb +0 -1
- data/lib/schema_column_plus.rb +0 -7
- data/lib/schema_column_plus/middleware/model.rb +0 -22
- data/lib/schema_db_default.rb +0 -13
- data/lib/schema_db_default/middleware.rb +0 -30
- data/lib/schema_pg_enums.rb +0 -6
- data/lib/schema_pg_enums/middleware.rb +0 -23
- data/lib/schema_plus/active_record/connection_adapters/schema_statements.rb +0 -34
- data/lib/schema_plus/middleware/model.rb +0 -17
- data/lib/schema_views.rb +0 -16
- data/lib/schema_views/middleware.rb +0 -47
- data/spec/connection_spec.rb +0 -10
File without changes
|
@@ -4,8 +4,8 @@ require 'stringio'
|
|
4
4
|
describe "Schema dump" do
|
5
5
|
|
6
6
|
before(:all) do
|
7
|
-
|
8
|
-
config.
|
7
|
+
SchemaPlusForeignKeys.setup do |config|
|
8
|
+
config.auto_create = false
|
9
9
|
end
|
10
10
|
ActiveRecord::Migration.suppress_messages do
|
11
11
|
ActiveRecord::Schema.define do
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe ActiveRecord::Schema do
|
4
4
|
|
@@ -77,22 +77,22 @@ describe ActiveRecord::Schema do
|
|
77
77
|
|
78
78
|
|
79
79
|
def with_auto_index(value = true)
|
80
|
-
old_value =
|
81
|
-
|
80
|
+
old_value = SchemaPlusForeignKeys.config.auto_index
|
81
|
+
SchemaPlusForeignKeys.config.auto_index = value
|
82
82
|
begin
|
83
83
|
yield
|
84
84
|
ensure
|
85
|
-
|
85
|
+
SchemaPlusForeignKeys.config.auto_index = old_value
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
89
89
|
def with_auto_create(value = true)
|
90
|
-
old_value =
|
91
|
-
|
90
|
+
old_value = SchemaPlusForeignKeys.config.auto_create
|
91
|
+
SchemaPlusForeignKeys.config.auto_create = value
|
92
92
|
begin
|
93
93
|
yield
|
94
94
|
ensure
|
95
|
-
|
95
|
+
SchemaPlusForeignKeys.config.auto_create = old_value
|
96
96
|
end
|
97
97
|
end
|
98
98
|
|
@@ -7,9 +7,9 @@ describe "with multiple schemas" do
|
|
7
7
|
|
8
8
|
before(:all) do
|
9
9
|
newdb = case connection.adapter_name
|
10
|
-
when /^mysql/i then "CREATE SCHEMA IF NOT EXISTS
|
11
|
-
when /^postgresql/i then "CREATE SCHEMA
|
12
|
-
when /^sqlite/i then "ATTACH ':memory:' AS
|
10
|
+
when /^mysql/i then "CREATE SCHEMA IF NOT EXISTS schema_plus_views_test2"
|
11
|
+
when /^postgresql/i then "CREATE SCHEMA schema_plus_views_test2"
|
12
|
+
when /^sqlite/i then "ATTACH ':memory:' AS schema_plus_views_test2"
|
13
13
|
end
|
14
14
|
begin
|
15
15
|
ActiveRecord::Base.connection.execute newdb
|
@@ -27,8 +27,8 @@ describe "with multiple schemas" do
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
connection.execute 'DROP TABLE IF EXISTS
|
31
|
-
connection.execute 'CREATE TABLE
|
30
|
+
connection.execute 'DROP TABLE IF EXISTS schema_plus_views_test2.users'
|
31
|
+
connection.execute 'CREATE TABLE schema_plus_views_test2.users (id ' + case connection.adapter_name
|
32
32
|
when /^mysql/i then "integer primary key auto_increment"
|
33
33
|
when /^postgresql/i then "serial primary key"
|
34
34
|
when /^sqlite/i then "integer primary key autoincrement"
|
@@ -40,14 +40,14 @@ describe "with multiple schemas" do
|
|
40
40
|
begin
|
41
41
|
example.run
|
42
42
|
ensure
|
43
|
-
connection.execute 'DROP VIEW
|
43
|
+
connection.execute 'DROP VIEW schema_plus_views_test2.myview' rescue nil
|
44
44
|
connection.execute 'DROP VIEW myview' rescue nil
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
48
|
before(:each) do
|
49
49
|
connection.views.each { |view| connection.drop_view view }
|
50
|
-
connection.execute 'CREATE VIEW
|
50
|
+
connection.execute 'CREATE VIEW schema_plus_views_test2.myview AS SELECT * FROM users'
|
51
51
|
end
|
52
52
|
|
53
53
|
it "should not find views in other schema" do
|
File without changes
|
data/spec/spec_helper.rb
CHANGED
@@ -24,12 +24,12 @@ RSpec.configure do |config|
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def with_fk_config(opts, &block)
|
27
|
-
save = Hash[opts.keys.collect{|key| [key,
|
27
|
+
save = Hash[opts.keys.collect{|key| [key, SchemaPlusForeignKeys.config.send(key)]}]
|
28
28
|
begin
|
29
|
-
|
29
|
+
SchemaPlusForeignKeys.config.update_attributes(opts)
|
30
30
|
yield
|
31
31
|
ensure
|
32
|
-
|
32
|
+
SchemaPlusForeignKeys.config.update_attributes(save)
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: schema_plus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0.
|
4
|
+
version: 2.0.0.pre3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ronen Barzel
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-02-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -45,14 +45,40 @@ dependencies:
|
|
45
45
|
requirements:
|
46
46
|
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: '0
|
48
|
+
version: '1.0'
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: 1.0.1
|
49
52
|
type: :runtime
|
50
53
|
prerelease: false
|
51
54
|
version_requirements: !ruby/object:Gem::Requirement
|
52
55
|
requirements:
|
53
56
|
- - "~>"
|
54
57
|
- !ruby/object:Gem::Version
|
55
|
-
version: '0
|
58
|
+
version: '1.0'
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.0.1
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: schema_monkey_rails
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.1'
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: 0.1.1
|
72
|
+
type: :runtime
|
73
|
+
prerelease: false
|
74
|
+
version_requirements: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - "~>"
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0.1'
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: 0.1.1
|
56
82
|
- !ruby/object:Gem::Dependency
|
57
83
|
name: schema_plus_indexes
|
58
84
|
requirement: !ruby/object:Gem::Requirement
|
@@ -87,20 +113,14 @@ dependencies:
|
|
87
113
|
requirements:
|
88
114
|
- - "~>"
|
89
115
|
- !ruby/object:Gem::Version
|
90
|
-
version: '
|
91
|
-
- - ">="
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
version: 2.0.3
|
116
|
+
version: '3.0'
|
94
117
|
type: :development
|
95
118
|
prerelease: false
|
96
119
|
version_requirements: !ruby/object:Gem::Requirement
|
97
120
|
requirements:
|
98
121
|
- - "~>"
|
99
122
|
- !ruby/object:Gem::Version
|
100
|
-
version: '
|
101
|
-
- - ">="
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: 2.0.3
|
123
|
+
version: '3.0'
|
104
124
|
- !ruby/object:Gem::Dependency
|
105
125
|
name: rake
|
106
126
|
requirement: !ruby/object:Gem::Requirement
|
@@ -191,71 +211,72 @@ files:
|
|
191
211
|
- Rakefile
|
192
212
|
- TODO.md
|
193
213
|
- gemfiles/Gemfile.base
|
194
|
-
- gemfiles/
|
195
|
-
- gemfiles/
|
196
|
-
- gemfiles/
|
197
|
-
- gemfiles/
|
198
|
-
- init.rb
|
199
|
-
- lib/schema_column_plus.rb
|
200
|
-
- lib/schema_column_plus/active_record/connection_adapters/column.rb
|
201
|
-
- lib/schema_column_plus/middleware/model.rb
|
202
|
-
- lib/schema_db_default.rb
|
203
|
-
- lib/schema_db_default/active_record/attribute.rb
|
204
|
-
- lib/schema_db_default/db_default.rb
|
205
|
-
- lib/schema_db_default/middleware.rb
|
206
|
-
- lib/schema_default_expr.rb
|
207
|
-
- lib/schema_default_expr/active_record/connection_adapters/mysql2_adapter.rb
|
208
|
-
- lib/schema_default_expr/active_record/connection_adapters/postgresql_adapter.rb
|
209
|
-
- lib/schema_default_expr/active_record/connection_adapters/sqlite3_adapter.rb
|
210
|
-
- lib/schema_default_expr/middleware.rb
|
211
|
-
- lib/schema_pg_enums.rb
|
212
|
-
- lib/schema_pg_enums/active_record.rb
|
213
|
-
- lib/schema_pg_enums/middleware.rb
|
214
|
+
- gemfiles/activerecord-4.2/Gemfile.base
|
215
|
+
- gemfiles/activerecord-4.2/Gemfile.mysql2
|
216
|
+
- gemfiles/activerecord-4.2/Gemfile.postgresql
|
217
|
+
- gemfiles/activerecord-4.2/Gemfile.sqlite3
|
214
218
|
- lib/schema_plus.rb
|
215
|
-
- lib/schema_plus/active_record/base.rb
|
216
|
-
- lib/schema_plus/active_record/connection_adapters/abstract_adapter.rb
|
217
|
-
- lib/schema_plus/active_record/connection_adapters/foreign_key_definition.rb
|
218
|
-
- lib/schema_plus/active_record/connection_adapters/mysql2_adapter.rb
|
219
|
-
- lib/schema_plus/active_record/connection_adapters/postgresql_adapter.rb
|
220
|
-
- lib/schema_plus/active_record/connection_adapters/schema_statements.rb
|
221
|
-
- lib/schema_plus/active_record/connection_adapters/sqlite3_adapter.rb
|
222
|
-
- lib/schema_plus/active_record/connection_adapters/table_definition.rb
|
223
|
-
- lib/schema_plus/active_record/migration/command_recorder.rb
|
224
|
-
- lib/schema_plus/active_record/schema.rb
|
225
|
-
- lib/schema_plus/middleware/dumper.rb
|
226
|
-
- lib/schema_plus/middleware/migration.rb
|
227
|
-
- lib/schema_plus/middleware/model.rb
|
228
219
|
- lib/schema_plus/version.rb
|
220
|
+
- lib/schema_plus_columns.rb
|
221
|
+
- lib/schema_plus_columns/active_record/connection_adapters/column.rb
|
222
|
+
- lib/schema_plus_columns/middleware/model.rb
|
223
|
+
- lib/schema_plus_db_default.rb
|
224
|
+
- lib/schema_plus_db_default/active_record/attribute.rb
|
225
|
+
- lib/schema_plus_db_default/db_default.rb
|
226
|
+
- lib/schema_plus_db_default/middleware.rb
|
227
|
+
- lib/schema_plus_default_expr.rb
|
228
|
+
- lib/schema_plus_default_expr/active_record/connection_adapters/mysql2_adapter.rb
|
229
|
+
- lib/schema_plus_default_expr/active_record/connection_adapters/postgresql_adapter.rb
|
230
|
+
- lib/schema_plus_default_expr/active_record/connection_adapters/sqlite3_adapter.rb
|
231
|
+
- lib/schema_plus_default_expr/middleware.rb
|
232
|
+
- lib/schema_plus_enums.rb
|
233
|
+
- lib/schema_plus_enums/active_record.rb
|
234
|
+
- lib/schema_plus_enums/middleware.rb
|
235
|
+
- lib/schema_plus_foreign_keys.rb
|
236
|
+
- lib/schema_plus_foreign_keys/active_record/base.rb
|
237
|
+
- lib/schema_plus_foreign_keys/active_record/connection_adapters/abstract_adapter.rb
|
238
|
+
- lib/schema_plus_foreign_keys/active_record/connection_adapters/foreign_key_definition.rb
|
239
|
+
- lib/schema_plus_foreign_keys/active_record/connection_adapters/mysql2_adapter.rb
|
240
|
+
- lib/schema_plus_foreign_keys/active_record/connection_adapters/postgresql_adapter.rb
|
241
|
+
- lib/schema_plus_foreign_keys/active_record/connection_adapters/schema_statements.rb
|
242
|
+
- lib/schema_plus_foreign_keys/active_record/connection_adapters/sqlite3_adapter.rb
|
243
|
+
- lib/schema_plus_foreign_keys/active_record/connection_adapters/table_definition.rb
|
244
|
+
- lib/schema_plus_foreign_keys/active_record/migration/command_recorder.rb
|
245
|
+
- lib/schema_plus_foreign_keys/active_record/schema.rb
|
246
|
+
- lib/schema_plus_foreign_keys/middleware/dumper.rb
|
247
|
+
- lib/schema_plus_foreign_keys/middleware/migration.rb
|
248
|
+
- lib/schema_plus_foreign_keys/middleware/model.rb
|
249
|
+
- lib/schema_plus_foreign_keys/version.rb
|
229
250
|
- lib/schema_plus_tables.rb
|
230
251
|
- lib/schema_plus_tables/active_record/connection_adapters/abstract_adapter.rb
|
231
252
|
- lib/schema_plus_tables/active_record/connection_adapters/mysql2_adapter.rb
|
232
253
|
- lib/schema_plus_tables/active_record/connection_adapters/postgresql_adapter.rb
|
233
254
|
- lib/schema_plus_tables/active_record/connection_adapters/sqlite3_adapter.rb
|
234
|
-
- lib/
|
235
|
-
- lib/
|
236
|
-
- lib/
|
237
|
-
- lib/
|
238
|
-
- lib/
|
239
|
-
- lib/
|
255
|
+
- lib/schema_plus_views.rb
|
256
|
+
- lib/schema_plus_views/active_record/connection_adapters/abstract_adapter.rb
|
257
|
+
- lib/schema_plus_views/active_record/connection_adapters/mysql2_adapter.rb
|
258
|
+
- lib/schema_plus_views/active_record/connection_adapters/postgresql_adapter.rb
|
259
|
+
- lib/schema_plus_views/active_record/connection_adapters/sqlite3_adapter.rb
|
260
|
+
- lib/schema_plus_views/middleware.rb
|
240
261
|
- schema_dev.yml
|
241
262
|
- schema_plus.gemspec
|
242
|
-
- spec/connection_spec.rb
|
243
|
-
- spec/foreign_key_definition_spec.rb
|
244
|
-
- spec/foreign_key_spec.rb
|
245
|
-
- spec/migration_spec.rb
|
246
|
-
- spec/named_schemas_spec.rb
|
247
263
|
- spec/schema/auto_schema.rb
|
248
264
|
- spec/schema/core_schema.rb
|
249
|
-
- spec/
|
250
|
-
- spec/
|
251
|
-
- spec/
|
252
|
-
- spec/
|
253
|
-
- spec/schema_dumper_spec.rb
|
254
|
-
- spec/
|
255
|
-
- spec/
|
256
|
-
- spec/
|
257
|
-
- spec/
|
258
|
-
- spec/
|
265
|
+
- spec/schema_plus_columns/column_spec.rb
|
266
|
+
- spec/schema_plus_db_default/column_spec.rb
|
267
|
+
- spec/schema_plus_default_expr/column_default_spec.rb
|
268
|
+
- spec/schema_plus_default_expr/migration_spec.rb
|
269
|
+
- spec/schema_plus_default_expr/schema_dumper_spec.rb
|
270
|
+
- spec/schema_plus_enums/enum_spec.rb
|
271
|
+
- spec/schema_plus_enums/schema_dumper_spec.rb
|
272
|
+
- spec/schema_plus_foreign_keys/foreign_key_definition_spec.rb
|
273
|
+
- spec/schema_plus_foreign_keys/foreign_key_spec.rb
|
274
|
+
- spec/schema_plus_foreign_keys/migration_spec.rb
|
275
|
+
- spec/schema_plus_foreign_keys/named_schemas_spec.rb
|
276
|
+
- spec/schema_plus_foreign_keys/schema_dumper_spec.rb
|
277
|
+
- spec/schema_plus_foreign_keys/schema_spec.rb
|
278
|
+
- spec/schema_plus_views/named_schemas_spec.rb
|
279
|
+
- spec/schema_plus_views/views_spec.rb
|
259
280
|
- spec/spec_helper.rb
|
260
281
|
- spec/support/helpers.rb
|
261
282
|
- spec/support/matchers/automatic_foreign_key_matchers.rb
|
@@ -287,23 +308,23 @@ specification_version: 4
|
|
287
308
|
summary: Enhances ActiveRecord schema mechanism, including more DRY index creation
|
288
309
|
and support for foreign key constraints and views.
|
289
310
|
test_files:
|
290
|
-
- spec/connection_spec.rb
|
291
|
-
- spec/foreign_key_definition_spec.rb
|
292
|
-
- spec/foreign_key_spec.rb
|
293
|
-
- spec/migration_spec.rb
|
294
|
-
- spec/named_schemas_spec.rb
|
295
311
|
- spec/schema/auto_schema.rb
|
296
312
|
- spec/schema/core_schema.rb
|
297
|
-
- spec/
|
298
|
-
- spec/
|
299
|
-
- spec/
|
300
|
-
- spec/
|
301
|
-
- spec/schema_dumper_spec.rb
|
302
|
-
- spec/
|
303
|
-
- spec/
|
304
|
-
- spec/
|
305
|
-
- spec/
|
306
|
-
- spec/
|
313
|
+
- spec/schema_plus_columns/column_spec.rb
|
314
|
+
- spec/schema_plus_db_default/column_spec.rb
|
315
|
+
- spec/schema_plus_default_expr/column_default_spec.rb
|
316
|
+
- spec/schema_plus_default_expr/migration_spec.rb
|
317
|
+
- spec/schema_plus_default_expr/schema_dumper_spec.rb
|
318
|
+
- spec/schema_plus_enums/enum_spec.rb
|
319
|
+
- spec/schema_plus_enums/schema_dumper_spec.rb
|
320
|
+
- spec/schema_plus_foreign_keys/foreign_key_definition_spec.rb
|
321
|
+
- spec/schema_plus_foreign_keys/foreign_key_spec.rb
|
322
|
+
- spec/schema_plus_foreign_keys/migration_spec.rb
|
323
|
+
- spec/schema_plus_foreign_keys/named_schemas_spec.rb
|
324
|
+
- spec/schema_plus_foreign_keys/schema_dumper_spec.rb
|
325
|
+
- spec/schema_plus_foreign_keys/schema_spec.rb
|
326
|
+
- spec/schema_plus_views/named_schemas_spec.rb
|
327
|
+
- spec/schema_plus_views/views_spec.rb
|
307
328
|
- spec/spec_helper.rb
|
308
329
|
- spec/support/helpers.rb
|
309
330
|
- spec/support/matchers/automatic_foreign_key_matchers.rb
|
data/init.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require 'schema_plus' unless defined?(SchemaPlus)
|
data/lib/schema_column_plus.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
module SchemaColumnPlus
|
2
|
-
module Middleware
|
3
|
-
module Model
|
4
|
-
|
5
|
-
def self.insert
|
6
|
-
SchemaMonkey::Middleware::Model::Columns.append AddModels
|
7
|
-
end
|
8
|
-
|
9
|
-
class AddModels < SchemaMonkey::Middleware::Base
|
10
|
-
def call(env)
|
11
|
-
continue env
|
12
|
-
|
13
|
-
env.columns.each do |column|
|
14
|
-
column.model = env.model
|
15
|
-
end
|
16
|
-
|
17
|
-
env.columns
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
data/lib/schema_db_default.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
require 'schema_monkey'
|
2
|
-
|
3
|
-
require_relative 'schema_db_default/active_record/attribute'
|
4
|
-
require_relative 'schema_db_default/db_default'
|
5
|
-
require_relative 'schema_db_default/middleware'
|
6
|
-
|
7
|
-
module SchemaDbDefault
|
8
|
-
def self.insert
|
9
|
-
::ActiveRecord.const_set(:DB_DEFAULT, SchemaDbDefault::DB_DEFAULT)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
SchemaMonkey.register(SchemaDbDefault)
|
@@ -1,30 +0,0 @@
|
|
1
|
-
module SchemaDbDefault
|
2
|
-
module Middleware
|
3
|
-
module PostgresqlAdapter
|
4
|
-
def self.insert
|
5
|
-
SchemaMonkey::Middleware::Query::ExecCache.prepend BindDbDefault
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
# Middleware to replace each ActiveRecord::DB_DEFAULT with a literal
|
10
|
-
# DEFAULT in the sql string, for postgresql. The underlying pg gem provides no
|
11
|
-
# way to bind a value that will replace $n with DEFAULT.
|
12
|
-
class BindDbDefault < SchemaMonkey::Middleware::Base
|
13
|
-
def call(env)
|
14
|
-
if env.binds.any?{ |col, val| val.equal? ::ActiveRecord::DB_DEFAULT}
|
15
|
-
j = 0
|
16
|
-
env.binds.each_with_index do |(col, val), i|
|
17
|
-
if val.equal? ::ActiveRecord::DB_DEFAULT
|
18
|
-
env.sql = env.sql.sub(/\$#{i+1}/, 'DEFAULT')
|
19
|
-
else
|
20
|
-
env.sql = env.sql.sub(/\$#{i+1}/, "$#{j+1}") if i != j
|
21
|
-
j += 1
|
22
|
-
end
|
23
|
-
end
|
24
|
-
env.binds = env.binds.reject{|col, val| val.equal? ::ActiveRecord::DB_DEFAULT}
|
25
|
-
end
|
26
|
-
continue env
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|