declare_schema 0.12.0.pre.2 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1 -1
- data/Gemfile.lock +1 -1
- data/lib/declare_schema/version.rb +1 -1
- data/lib/generators/declare_schema/migration/migrator.rb +2 -3
- data/spec/lib/declare_schema/api_spec.rb +0 -4
- 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: 741e1030227b2cd6e472d1f3cc9a8f3838c927b3702087428f01b2af09a7c758
|
4
|
+
data.tar.gz: 439d95f21fd5e8f677aea5c1ef4bb52fc37c8321b0066876f0970028e75a654a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b332745b815b6ac442158727c4d6ded6f320144f40b895ff4e303bd0e67a25d305fbed845ab3eedb9d49754078fff0f2b25b58f417fd42e00552b58b4bd67d1a
|
7
|
+
data.tar.gz: 600fb3635f8a65defcb0643501553e73befc7548da6a6821840b3a487c80e66a0933f51cbde7a83679a2ac2dc69f7f54e71aab2d878dd03b9742308cb0d845f5
|
data/CHANGELOG.md
CHANGED
@@ -4,7 +4,7 @@ Inspired by [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
4
4
|
|
5
5
|
Note: this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
-
## [0.12.0] -
|
7
|
+
## [0.12.0] - 2021-04-28
|
8
8
|
### Added
|
9
9
|
- `belongs_to` now always infers the `limit:` of the foreign key to match that of the primary key it points to.
|
10
10
|
Note: this isn't possible for polymorphic foreign keys, so it assumes `limit: 8` there...unless the schema
|
data/Gemfile.lock
CHANGED
@@ -343,16 +343,15 @@ module Generators
|
|
343
343
|
|
344
344
|
db_columns = model.connection.columns(current_table_name).index_by(&:name)
|
345
345
|
if (pk = model._declared_primary_key.presence)
|
346
|
-
|
346
|
+
pk_was_in_db_columns = db_columns.delete(pk)
|
347
347
|
end
|
348
348
|
|
349
349
|
model_column_names = model.field_specs.keys.map(&:to_s)
|
350
350
|
db_column_names = db_columns.keys.map(&:to_s)
|
351
351
|
|
352
352
|
to_add = model_column_names - db_column_names
|
353
|
-
to_add << pk if pk && !
|
353
|
+
to_add << pk if pk && !pk_was_in_db_columns
|
354
354
|
to_remove = db_column_names - model_column_names
|
355
|
-
to_remove -= [pk.to_sym] if pk # TODO: The .to_sym here means this code is always a no-op, right? -Colin
|
356
355
|
|
357
356
|
to_rename = extract_column_renames!(to_add, to_remove, new_table_name)
|
358
357
|
|
@@ -40,8 +40,6 @@ RSpec.describe 'DeclareSchema API' do
|
|
40
40
|
load_models
|
41
41
|
|
42
42
|
if ActiveSupport::VERSION::MAJOR == 5
|
43
|
-
# TODO: get this to work on Travis for Rails 6
|
44
|
-
# TODO: uncomment since we're not on Travis any more? -Colin
|
45
43
|
generate_migrations '-n', '-m'
|
46
44
|
end
|
47
45
|
|
@@ -50,8 +48,6 @@ RSpec.describe 'DeclareSchema API' do
|
|
50
48
|
|
51
49
|
## The Basics
|
52
50
|
|
53
|
-
# The main feature of DeclareSchema, aside from the migration generator, is the ability to declare rich types for your fields. For example, you can declare that a field is an email address, and the field will be automatically validated for correct email address syntax.
|
54
|
-
|
55
51
|
### Field Types
|
56
52
|
|
57
53
|
# Field values are returned as the type you specify.
|
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.12.0
|
4
|
+
version: 0.12.0
|
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-04-
|
11
|
+
date: 2021-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|