schemerd 0.1.5 → 0.1.6
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/README.md +17 -3
- data/lib/schemerd/generator.rb +3 -0
- data/lib/schemerd/version.rb +1 -1
- data/lib/tasks/schemerd.rake +7 -6
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8bfc9a7baeebd6d3e7f9d7c7ba005bb3c9461693de77ad8482d4b066112bbe86
|
|
4
|
+
data.tar.gz: 22276c71c68cdd3c727d12823614b5a90678e4767c4f838fc83de21659ba1c11
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3e3c5bb20dab79446b4a21ac7e9cf72fa407918282a47dacb745b5b4ffad0328bc37f51bcbc0ccfae06db843235a120b39b23a09ff48500e075f3893afde3640
|
|
7
|
+
data.tar.gz: 677080d8d7311ec32de0592be0d407b6462955522e33e7cbf79e1041e01c5d6fbcf31b75be145b55e8c9d9ee3613e72cf1a858b1424448f92dbc30cddb2375d7
|
data/README.md
CHANGED
|
@@ -68,6 +68,12 @@ Schemerd.configure do |config|
|
|
|
68
68
|
end
|
|
69
69
|
```
|
|
70
70
|
|
|
71
|
+
## Features
|
|
72
|
+
|
|
73
|
+
- **Consistent column ordering** — PK first, then alphabetical, timestamps (`created_at`, `updated_at`) last
|
|
74
|
+
- **STI support** — child models are filtered out; the `type` column is annotated with subclass names (e.g. `string type "Car, Truck"`)
|
|
75
|
+
- **All association types** — `belongs_to`, `has_many`, `has_one`, and `has_and_belongs_to_many`
|
|
76
|
+
|
|
71
77
|
## Output Example
|
|
72
78
|
|
|
73
79
|
The generated file contains a fenced Mermaid code block:
|
|
@@ -80,24 +86,32 @@ Auto-generated from ActiveRecord models. Do not edit manually.
|
|
|
80
86
|
```mermaid
|
|
81
87
|
erDiagram
|
|
82
88
|
Post }o--|| User : "author"
|
|
83
|
-
|
|
89
|
+
Post }o--o{ Tag : "tags"
|
|
84
90
|
|
|
85
91
|
User {
|
|
86
92
|
integer id PK
|
|
87
|
-
string name
|
|
88
93
|
string email
|
|
94
|
+
string name
|
|
89
95
|
datetime created_at
|
|
90
96
|
datetime updated_at
|
|
91
97
|
}
|
|
92
98
|
|
|
93
99
|
Post {
|
|
94
100
|
integer id PK
|
|
95
|
-
string title
|
|
96
101
|
text body
|
|
102
|
+
string title
|
|
97
103
|
integer user_id
|
|
98
104
|
datetime created_at
|
|
99
105
|
datetime updated_at
|
|
100
106
|
}
|
|
107
|
+
|
|
108
|
+
Vehicle {
|
|
109
|
+
integer id PK
|
|
110
|
+
string name
|
|
111
|
+
string type "Car, Truck"
|
|
112
|
+
datetime created_at
|
|
113
|
+
datetime updated_at
|
|
114
|
+
}
|
|
101
115
|
```
|
|
102
116
|
~~~
|
|
103
117
|
|
data/lib/schemerd/generator.rb
CHANGED
|
@@ -24,6 +24,7 @@ module Schemerd
|
|
|
24
24
|
private
|
|
25
25
|
|
|
26
26
|
def load_models
|
|
27
|
+
ActiveRecord::Base.connection.schema_cache.clear!
|
|
27
28
|
Rails.application.eager_load!
|
|
28
29
|
|
|
29
30
|
base = @config.base_class.constantize
|
|
@@ -32,6 +33,8 @@ module Schemerd
|
|
|
32
33
|
.reject { |m| excluded?(m.name) }
|
|
33
34
|
.select { |m| m.table_exists? rescue false }
|
|
34
35
|
|
|
36
|
+
all_models.each(&:reset_column_information)
|
|
37
|
+
|
|
35
38
|
@sti_children = Hash.new { |h, k| h[k] = [] }
|
|
36
39
|
sti, non_sti = all_models.partition { |m| sti_child?(m) }
|
|
37
40
|
sti.each { |m| @sti_children[m.superclass.name] << m.name }
|
data/lib/schemerd/version.rb
CHANGED
data/lib/tasks/schemerd.rake
CHANGED
|
@@ -7,14 +7,15 @@ namespace :schemerd do
|
|
|
7
7
|
end
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
-
# Auto-run after migrations in development
|
|
11
10
|
if defined?(Rails) && Rails.env.development?
|
|
12
|
-
%w[db:migrate db:migrate:up db:migrate:down db:migrate:redo]
|
|
13
|
-
next unless Rake::Task.task_defined?(task_name)
|
|
11
|
+
migration_tasks = %w[db:migrate db:migrate:up db:migrate:down db:migrate:redo db:rollback]
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
migration_tasks.each do |task|
|
|
14
|
+
next unless Rake::Task.task_defined?(task)
|
|
15
|
+
|
|
16
|
+
Rake::Task[task].enhance do
|
|
17
|
+
Rake::Task[Rake.application.top_level_tasks.last].enhance do
|
|
18
|
+
Schemerd.generate if Schemerd.configuration.auto_generate
|
|
18
19
|
end
|
|
19
20
|
end
|
|
20
21
|
end
|