schema_to_dbml 0.0.6 → 0.0.7
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/.rubocop.yml +6 -0
- data/Gemfile.lock +11 -9
- data/README.md +6 -1
- data/Rakefile +1 -0
- data/lib/configuration.rb +3 -1
- data/lib/rake_tasks/schema_to_dbml.rake +5 -2
- data/lib/schema_to_dbml/dbml_tables_formatter.rb +5 -3
- data/lib/schema_to_dbml/formatters/fields_formatter.rb +2 -0
- data/lib/schema_to_dbml/version.rb +1 -1
- 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: 4108364b1e7c9cd89e4ae413c1282b2140bcb6b4ce5758eeb37ded7eabe26dcf
|
4
|
+
data.tar.gz: 9ad7bf887518c4cefdb84101e3ab5bd1c76876e973dd3d0fc49148739034cb2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc6519ae82320a59e075f63069455dec421c0cc4cfc15897a4d10dbb3a51d3a1e8ce8916efcddfa6075e44da2d6989613eea2c927efa26c0a1a56f5d5e8cef4f
|
7
|
+
data.tar.gz: 5748195dbe7347e88672f6ca0171cc4d00091a94cb6120d1a4c49780ba2461e0104542c36dbbcf9002f1468d4c5508e032a8be4009262ccf5f04dbbe8e39b062
|
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -7,7 +7,7 @@ PATH
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
activesupport (7.1.3.
|
10
|
+
activesupport (7.1.3.4)
|
11
11
|
base64
|
12
12
|
bigdecimal
|
13
13
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
@@ -19,18 +19,18 @@ GEM
|
|
19
19
|
tzinfo (~> 2.0)
|
20
20
|
ast (2.4.2)
|
21
21
|
base64 (0.2.0)
|
22
|
-
bigdecimal (3.1.
|
22
|
+
bigdecimal (3.1.8)
|
23
23
|
byebug (11.1.3)
|
24
|
-
concurrent-ruby (1.
|
24
|
+
concurrent-ruby (1.3.3)
|
25
25
|
connection_pool (2.4.1)
|
26
26
|
diff-lcs (1.5.1)
|
27
27
|
docile (1.4.0)
|
28
28
|
drb (2.2.1)
|
29
|
-
i18n (1.14.
|
29
|
+
i18n (1.14.5)
|
30
30
|
concurrent-ruby (~> 1.0)
|
31
|
-
json (2.7.
|
31
|
+
json (2.7.2)
|
32
32
|
language_server-protocol (3.17.0.3)
|
33
|
-
minitest (5.
|
33
|
+
minitest (5.24.0)
|
34
34
|
mutex_m (0.2.0)
|
35
35
|
parallel (1.24.0)
|
36
36
|
parser (3.3.0.5)
|
@@ -38,9 +38,10 @@ GEM
|
|
38
38
|
racc
|
39
39
|
racc (1.7.3)
|
40
40
|
rainbow (3.1.1)
|
41
|
-
rake (13.2.
|
41
|
+
rake (13.2.1)
|
42
42
|
regexp_parser (2.9.0)
|
43
|
-
rexml (3.2.
|
43
|
+
rexml (3.2.8)
|
44
|
+
strscan (>= 3.0.9)
|
44
45
|
rspec (3.13.0)
|
45
46
|
rspec-core (~> 3.13.0)
|
46
47
|
rspec-expectations (~> 3.13.0)
|
@@ -71,7 +72,7 @@ GEM
|
|
71
72
|
rubocop (~> 1.41)
|
72
73
|
rubocop-factory_bot (2.25.1)
|
73
74
|
rubocop (~> 1.41)
|
74
|
-
rubocop-rspec (2.
|
75
|
+
rubocop-rspec (2.29.1)
|
75
76
|
rubocop (~> 1.40)
|
76
77
|
rubocop-capybara (~> 2.17)
|
77
78
|
rubocop-factory_bot (~> 2.22)
|
@@ -85,6 +86,7 @@ GEM
|
|
85
86
|
simplecov_json_formatter (~> 0.1)
|
86
87
|
simplecov-html (0.12.3)
|
87
88
|
simplecov_json_formatter (0.1.4)
|
89
|
+
strscan (3.1.0)
|
88
90
|
tzinfo (2.0.6)
|
89
91
|
concurrent-ruby (~> 1.0)
|
90
92
|
unicode-display_width (2.5.0)
|
data/README.md
CHANGED
@@ -80,7 +80,7 @@ custom_project_notes: |
|
|
80
80
|
custom_dbml_content: |
|
81
81
|
enum object_status {
|
82
82
|
created [note: 'Initial status']
|
83
|
-
pending
|
83
|
+
pending
|
84
84
|
finished
|
85
85
|
cancelled
|
86
86
|
}
|
@@ -89,6 +89,11 @@ custom_dbml_content: |
|
|
89
89
|
table_2
|
90
90
|
table_3
|
91
91
|
}
|
92
|
+
custom_tables:
|
93
|
+
my_table:
|
94
|
+
attributes:
|
95
|
+
my_attribute:
|
96
|
+
type: object_status
|
92
97
|
```
|
93
98
|
|
94
99
|
After that, you can use the SchemaToDbml to generate the DBML content as usual.
|
data/Rakefile
CHANGED
data/lib/configuration.rb
CHANGED
@@ -8,6 +8,7 @@ class Configuration
|
|
8
8
|
@custom_primary_key = yaml_data['custom_primary_key']
|
9
9
|
@custom_project_name = yaml_data['custom_project_name']
|
10
10
|
@custom_project_notes = yaml_data['custom_project_notes']
|
11
|
+
@custom_tables = yaml_data['custom_tables']
|
11
12
|
end
|
12
13
|
|
13
14
|
attr_accessor :custom_database_type,
|
@@ -15,5 +16,6 @@ class Configuration
|
|
15
16
|
:custom_dbml_file_path,
|
16
17
|
:custom_primary_key,
|
17
18
|
:custom_project_name,
|
18
|
-
:custom_project_notes
|
19
|
+
:custom_project_notes,
|
20
|
+
:custom_tables
|
19
21
|
end
|
@@ -1,9 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
namespace :schema_to_dbml do
|
4
|
-
desc '
|
5
|
-
task :generate,
|
4
|
+
desc 'Build dbml.yml'
|
5
|
+
task :generate, [:schema_path] do |_t, args|
|
6
6
|
schema = args[:schema_path]
|
7
|
+
raise 'Schema path must be provided' unless schema
|
8
|
+
|
9
|
+
SchemaToDbml.load_configuration_from_yaml
|
7
10
|
SchemaToDbml.new.generate(schema:)
|
8
11
|
end
|
9
12
|
end
|
@@ -14,7 +14,7 @@ class DbmlTablesFormatter
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def format(table_name:, table_comment:, table_attributes:)
|
17
|
-
columns = build_columns(table_attributes)
|
17
|
+
columns = build_columns(table_name, table_attributes)
|
18
18
|
indexes = build_indexes(table_attributes)
|
19
19
|
|
20
20
|
format_dbml(table_name, columns, indexes, table_comment)
|
@@ -22,14 +22,16 @@ class DbmlTablesFormatter
|
|
22
22
|
|
23
23
|
private
|
24
24
|
|
25
|
-
def build_columns(table_attributes)
|
25
|
+
def build_columns(table_name, table_attributes)
|
26
26
|
columns = []
|
27
27
|
|
28
|
+
custom_table_attributes = configuration.custom_tables&.dig(table_name, 'attributes')
|
28
29
|
table_attributes.scan(COLUMNS_REGEXP).each do |type, name, default, null, comment, _precision, array, limit|
|
29
30
|
formatted_comment = format_comment(comment:)
|
30
31
|
formatted_default = format_default(default:)
|
31
32
|
formatted_null = format_null(null:)
|
32
|
-
|
33
|
+
custom_type = custom_table_attributes&.dig(name, 'type')
|
34
|
+
formatted_type = format_type(type: custom_type || type, array:, limit:)
|
33
35
|
|
34
36
|
final_values = [formatted_default, formatted_null, formatted_comment].compact.reject(&:empty?)
|
35
37
|
columns << build_line(name, formatted_type, final_values)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: schema_to_dbml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ricardo Ribeiro
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-06-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|