declare_schema 0.13.0.pre.1 → 0.13.0.pre.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1 -1
- data/Gemfile.lock +1 -1
- data/README.md +8 -2
- data/lib/declare_schema.rb +12 -4
- data/lib/declare_schema/version.rb +1 -1
- data/spec/lib/declare_schema/migration_generator_spec.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a0a46f7400412223cb7e7bab356450fa5d0a58cf05ee2c70c1bc6b5d9c91ed1
|
4
|
+
data.tar.gz: a3f0ce02021eab5d27dc338634d07d6ac942eae493f868c0ba68850bbb5c0ff9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9cc9136bcadb5bd2426ada4419e08e772a6976e98a0c96a6fe2129d79da4917819f4126966c4b1d0056b2b94e948433cfbc4370c7f6b85cab3f0ab9fd0b3c82
|
7
|
+
data.tar.gz: e5b96f7e05837c4a142651282381dbc7ad7647b8122946b221befcf858992a755ce0a15bf4f893f6d920353393145b305774f6fb38cab922641fc4f8ebda0f75
|
data/CHANGELOG.md
CHANGED
@@ -6,7 +6,7 @@ Note: this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0
|
|
6
6
|
|
7
7
|
## [0.13.0] - Unreleased
|
8
8
|
### Added
|
9
|
-
- Added support for `default_schema
|
9
|
+
- Added support for `default_schema` block to apply a default schema to every model, unless disabled for that model with `default_schema: false`.
|
10
10
|
|
11
11
|
## [0.12.1] - 2021-05-10
|
12
12
|
### Fixed
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -72,10 +72,10 @@ end
|
|
72
72
|
|
73
73
|
### default_schema
|
74
74
|
If there are default columns you would like in the schema for every model, you can define them in a block that is registered with
|
75
|
-
`DeclareSchema.default_schema
|
75
|
+
`DeclareSchema.default_schema`. For example:
|
76
76
|
|
77
77
|
```ruby
|
78
|
-
DeclareSchema.default_schema
|
78
|
+
DeclareSchema.default_schema do
|
79
79
|
timestamps
|
80
80
|
optimistic_lock
|
81
81
|
end
|
@@ -90,6 +90,12 @@ class User < ActiveRecord::Base
|
|
90
90
|
end
|
91
91
|
```
|
92
92
|
|
93
|
+
### clear_default_schema
|
94
|
+
This method clears out any previously declared `default_schema`.
|
95
|
+
```ruby
|
96
|
+
DeclareSchema.clear_default_schema
|
97
|
+
```
|
98
|
+
|
93
99
|
### Global Configuration
|
94
100
|
Configurations can be set at the global level to customize default declaration for the following values:
|
95
101
|
|
data/lib/declare_schema.rb
CHANGED
@@ -37,7 +37,7 @@ module DeclareSchema
|
|
37
37
|
|
38
38
|
class << self
|
39
39
|
attr_reader :default_charset, :default_collation, :default_text_limit, :default_string_limit, :default_null,
|
40
|
-
:default_generate_foreign_keys, :default_generate_indexing, :
|
40
|
+
:default_generate_foreign_keys, :default_generate_indexing, :db_migrate_command
|
41
41
|
|
42
42
|
def to_class(type)
|
43
43
|
case type
|
@@ -85,9 +85,17 @@ module DeclareSchema
|
|
85
85
|
@default_generate_indexing = generate_indexing
|
86
86
|
end
|
87
87
|
|
88
|
-
def default_schema
|
89
|
-
|
90
|
-
|
88
|
+
def default_schema(&block)
|
89
|
+
if block.nil?
|
90
|
+
@default_schema # equivalent to attr_reader :default_schema
|
91
|
+
else
|
92
|
+
block.respond_to?(:call) or raise "default_schema must be passed a block that responds to call"
|
93
|
+
@default_schema = block
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def clear_default_schema
|
98
|
+
@default_schema = nil
|
91
99
|
end
|
92
100
|
|
93
101
|
def db_migrate_command=(db_migrate_command)
|
@@ -2507,11 +2507,11 @@ RSpec.describe 'DeclareSchema Migration Generator' do
|
|
2507
2507
|
end
|
2508
2508
|
|
2509
2509
|
before do
|
2510
|
-
DeclareSchema.default_schema
|
2510
|
+
DeclareSchema.default_schema(&default_schema_block)
|
2511
2511
|
end
|
2512
2512
|
|
2513
2513
|
after do
|
2514
|
-
DeclareSchema.
|
2514
|
+
DeclareSchema.clear_default_schema
|
2515
2515
|
end
|
2516
2516
|
|
2517
2517
|
context 'when unset' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: declare_schema
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.13.0.pre.
|
4
|
+
version: 0.13.0.pre.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Invoca Development adapted from hobo_fields by Tom Locke
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-06-
|
11
|
+
date: 2021-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|