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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ca6f1b673c235b1bdefd3373a34bd56e3d573c2bc9d9e152692937d47335ae58
4
- data.tar.gz: bb3b90351c3cd8b28679fe9abf9c253405c420dbbc80a7ab589357bffd523195
3
+ metadata.gz: 8bfc9a7baeebd6d3e7f9d7c7ba005bb3c9461693de77ad8482d4b066112bbe86
4
+ data.tar.gz: 22276c71c68cdd3c727d12823614b5a90678e4767c4f838fc83de21659ba1c11
5
5
  SHA512:
6
- metadata.gz: 4fbb96858dc176e329b092c7ef6badba3064e75f8256252b83e856b8409192066e78c12ac628539ff6ecf44ac454e050694547cdddc7d2ac24d59ce9c1a6588f
7
- data.tar.gz: 74737e1813ab6e52296db20f5bfc5ab4cab970f73008ba10115b4ba4c44756b6fc3bc3d0489e0e13112948e844001acb590d7fa60c299e2663137033ed28ec13
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
- Comment ||--o{ Post : "comments"
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
 
@@ -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 }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Schemerd
4
- VERSION = "0.1.5"
4
+ VERSION = "0.1.6"
5
5
  end
@@ -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].each do |task_name|
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
- Rake::Task[task_name].enhance do
16
- if Schemerd.configuration.auto_generate
17
- Rake::Task["schemerd:generate"].invoke
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: schemerd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pablo Monfort