erd 0.6.0 → 0.7.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/.gitignore +1 -0
- data/.travis.yml +9 -11
- data/README.rdoc +1 -1
- data/app/controllers/erd/erd_controller.rb +100 -65
- data/app/views/erd/erd/_column.html.erb +8 -4
- data/app/views/erd/erd/_model.html.erb +23 -17
- data/app/views/erd/erd/edit.html.erb +87 -0
- data/app/views/erd/erd/erd.html.erb +1 -1
- data/app/views/erd/erd/index.html.erb +12 -81
- data/app/views/layouts/erd/application.html.erb +3 -2
- data/config/routes.rb +1 -0
- data/erd.gemspec +1 -1
- data/gemfiles/rails_32.gemfile +1 -1
- data/gemfiles/rails_40.gemfile +1 -0
- data/gemfiles/rails_41.gemfile +1 -0
- data/gemfiles/rails_42.gemfile +1 -0
- data/gemfiles/rails_50.gemfile +1 -0
- data/gemfiles/rails_51.gemfile +1 -0
- data/gemfiles/rails_52.gemfile +1 -0
- data/gemfiles/rails_60.gemfile +9 -0
- data/gemfiles/rails_edge.gemfile +1 -0
- data/lib/erd.rb +7 -1
- data/lib/erd/engine.rb +12 -0
- data/lib/erd/migrator.rb +3 -1
- data/lib/erd/version.rb +1 -1
- data/{vendor/assets/images → public}/erd/angle-left.png +0 -0
- data/{vendor/assets/images → public}/erd/angle-right.png +0 -0
- data/{vendor/assets/images → public}/erd/animated-overlay.gif +0 -0
- data/{vendor/assets/images → public}/erd/background.png +0 -0
- data/{vendor/assets/images → public}/erd/cancel.png +0 -0
- data/{vendor/assets/images → public}/erd/close.png +0 -0
- data/public/erd/erd.css +598 -0
- data/{app/assets/javascripts/erd/erd.js.js → public/erd/erd.js} +14 -3
- data/{app → src}/assets/stylesheets/erd/erd.css.scss +7 -7
- data/test/test_helper.rb +2 -0
- metadata +20 -21
- data/app/assets/javascripts/erd/application.js +0 -14
- data/app/assets/stylesheets/erd/application.css +0 -13
- data/lib/erd/railtie.rb +0 -21
- data/vendor/assets/javascripts/raphael-min.js +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35c1ad5ad3318d07d2faeb5836b2ec12e8132088994985d6d0f0342addd7685d
|
4
|
+
data.tar.gz: 77ce179c5b2c8cbe58095320d012e5aab188c3aa0d23d73e9de5036564e2cf1f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c02778a0c99593cd9ae3b8f5c27ccb0ea11f8ad6aa719a023f8de9ad40a51352ac33d17e92035afec8faad65ad7f1944eb032a65c98d9570f4840843121f65d5
|
7
|
+
data.tar.gz: 5f227492c2234358069825ca797188e6ec92e74cab71172de589077c1e52d4e3d104e04eedbd3e3e3b84b54dea911c8e61970893fdf9c7b4cd7ada16a2b98d31
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -13,16 +13,15 @@ cache:
|
|
13
13
|
- bundler
|
14
14
|
|
15
15
|
before_install:
|
16
|
-
- sudo apt update -qq
|
17
16
|
- sudo apt install -y chromium-chromedriver
|
18
|
-
-
|
19
|
-
- gem install bundler
|
17
|
+
- gem i bundler -v '<2'
|
20
18
|
|
21
19
|
rvm:
|
22
|
-
- 2.
|
20
|
+
- 2.6.0
|
23
21
|
- 2.0.0
|
24
22
|
|
25
23
|
gemfile:
|
24
|
+
- gemfiles/rails_60.gemfile
|
26
25
|
- gemfiles/rails_52.gemfile
|
27
26
|
- gemfiles/rails_51.gemfile
|
28
27
|
- gemfiles/rails_50.gemfile
|
@@ -33,20 +32,19 @@ gemfile:
|
|
33
32
|
|
34
33
|
matrix:
|
35
34
|
exclude:
|
35
|
+
- rvm: 2.0.0
|
36
|
+
gemfile: gemfiles/rails_60.gemfile
|
36
37
|
- rvm: 2.0.0
|
37
38
|
gemfile: gemfiles/rails_52.gemfile
|
38
39
|
- rvm: 2.0.0
|
39
40
|
gemfile: gemfiles/rails_51.gemfile
|
40
41
|
- rvm: 2.0.0
|
41
42
|
gemfile: gemfiles/rails_50.gemfile
|
42
|
-
- rvm: 2.
|
43
|
+
- rvm: 2.6.0
|
43
44
|
gemfile: gemfiles/rails_42.gemfile
|
44
|
-
- rvm: 2.
|
45
|
+
- rvm: 2.6.0
|
45
46
|
gemfile: gemfiles/rails_41.gemfile
|
46
|
-
- rvm: 2.
|
47
|
+
- rvm: 2.6.0
|
47
48
|
gemfile: gemfiles/rails_40.gemfile
|
48
|
-
- rvm: 2.
|
49
|
-
gemfile: gemfiles/rails_32.gemfile
|
50
|
-
include:
|
51
|
-
- rvm: 1.8.7
|
49
|
+
- rvm: 2.6.0
|
52
50
|
gemfile: gemfiles/rails_32.gemfile
|
data/README.rdoc
CHANGED
@@ -1,70 +1,69 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'nokogiri'
|
4
|
-
require '
|
4
|
+
require 'ruby-graphviz'
|
5
5
|
require 'erd/application_controller'
|
6
6
|
|
7
7
|
module Erd
|
8
8
|
class ErdController < ::Erd::ApplicationController
|
9
|
+
POSITIONS_JSON_FILE = Rails.root.join('tmp/erd_positions.json').freeze
|
10
|
+
|
9
11
|
def index
|
10
|
-
|
11
|
-
|
12
|
-
RailsERD::Diagram::Graphviz.create
|
13
|
-
plain = Rails.root.join('tmp/erd.plain').read
|
14
|
-
positions = if (json = Rails.root.join('tmp/erd_positions.json')).exist?
|
15
|
-
ActiveSupport::JSON.decode json.read
|
16
|
-
else
|
17
|
-
{}
|
18
|
-
end
|
19
|
-
@erd = render_plain plain, positions
|
12
|
+
@erd = render_plain generate_plain, saved_positions
|
13
|
+
end
|
20
14
|
|
15
|
+
def edit
|
16
|
+
@erd = render_plain generate_plain, saved_positions, true
|
21
17
|
@migrations = Erd::Migrator.status
|
22
18
|
end
|
23
19
|
|
24
20
|
def update
|
25
|
-
|
21
|
+
if params[:position_changes].present?
|
22
|
+
position_changes = ActiveSupport::JSON.decode(params[:position_changes])
|
23
|
+
positions = saved_positions
|
24
|
+
positions.merge! position_changes.transform_keys(&:tableize)
|
25
|
+
POSITIONS_JSON_FILE.open('w') {|f| f.write positions.to_json }
|
26
|
+
end
|
27
|
+
|
28
|
+
changes = params[:changes].present? ? ActiveSupport::JSON.decode(params[:changes]) : []
|
26
29
|
executed_migrations, failed_migrations = [], []
|
27
30
|
changes.each do |row|
|
28
31
|
begin
|
29
32
|
action, model, column, from, to = row['action'], row['model'], row['column'], row['from'], row['to']
|
30
|
-
|
33
|
+
|
34
|
+
case action
|
35
|
+
when 'create_model'
|
36
|
+
columns = column.split(' ').compact
|
37
|
+
generated_migration_file = Erd::GenaratorRunner.execute_generate_model model, columns
|
38
|
+
when 'remove_model'
|
31
39
|
model = model.tableize
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
40
|
+
generated_migration_file = Erd::GenaratorRunner.execute_generate_migration "drop_#{model}"
|
41
|
+
gsub_file generated_migration_file, /def (up|change).* end/m, "def change\n drop_table :#{model}\n end"
|
42
|
+
when 'rename_model'
|
43
|
+
_model, from, to = from.tableize, to.tableize, model.tableize
|
44
|
+
generated_migration_file = Erd::GenaratorRunner.execute_generate_migration "rename_#{from}_to_#{to}"
|
45
|
+
gsub_file generated_migration_file, /def (up|change).* end/m, "def change\n rename_table :#{from}, :#{to}\n end"
|
46
|
+
when 'add_column'
|
47
|
+
model = model.tableize
|
48
|
+
name_and_type = column.scan(/(.*)\((.*?)\)/).first
|
49
|
+
name, type = name_and_type[0], name_and_type[1]
|
50
|
+
generated_migration_file = Erd::GenaratorRunner.execute_generate_migration "add_#{name}_to_#{model}", ["#{name}:#{type}"]
|
51
|
+
when 'rename_column'
|
52
|
+
model = model.tableize
|
53
|
+
generated_migration_file = Erd::GenaratorRunner.execute_generate_migration "rename_#{model}_#{from}_to_#{to}"
|
54
|
+
gsub_file generated_migration_file, /def (up|change).* end/m, "def change\n rename_column :#{model}, :#{from}, :#{to}\n end"
|
55
|
+
when 'alter_column'
|
56
|
+
model = model.tableize
|
57
|
+
generated_migration_file = Erd::GenaratorRunner.execute_generate_migration "change_#{model}_#{column}_type_to_#{to}"
|
58
|
+
gsub_file generated_migration_file, /def (up|change).* end/m, "def change\n change_column :#{model}, :#{column}, :#{to}\n end"
|
59
|
+
when 'move'
|
60
|
+
# do nothing
|
36
61
|
else
|
37
|
-
|
38
|
-
when 'create_model'
|
39
|
-
columns = column.split(' ').compact
|
40
|
-
generated_migration_file = Erd::GenaratorRunner.execute_generate_model model, columns
|
41
|
-
when 'remove_model'
|
42
|
-
model = model.tableize
|
43
|
-
generated_migration_file = Erd::GenaratorRunner.execute_generate_migration "drop_#{model}"
|
44
|
-
gsub_file generated_migration_file, /def (up|change).* end/m, "def change\n drop_table :#{model}\n end"
|
45
|
-
when 'rename_model'
|
46
|
-
_model, from, to = from.tableize, to.tableize, model.tableize
|
47
|
-
generated_migration_file = Erd::GenaratorRunner.execute_generate_migration "rename_#{from}_to_#{to}"
|
48
|
-
gsub_file generated_migration_file, /def (up|change).* end/m, "def change\n rename_table :#{from}, :#{to}\n end"
|
49
|
-
when 'add_column'
|
50
|
-
model = model.tableize
|
51
|
-
name_and_type = column.scan(/(.*)\((.*?)\)/).first
|
52
|
-
name, type = name_and_type[0], name_and_type[1]
|
53
|
-
generated_migration_file = Erd::GenaratorRunner.execute_generate_migration "add_#{name}_to_#{model}", ["#{name}:#{type}"]
|
54
|
-
when 'rename_column'
|
55
|
-
model = model.tableize
|
56
|
-
generated_migration_file = Erd::GenaratorRunner.execute_generate_migration "rename_#{model}_#{from}_to_#{to}"
|
57
|
-
gsub_file generated_migration_file, /def (up|change).* end/m, "def change\n rename_column :#{model}, :#{from}, :#{to}\n end"
|
58
|
-
when 'alter_column'
|
59
|
-
model = model.tableize
|
60
|
-
generated_migration_file = Erd::GenaratorRunner.execute_generate_migration "change_#{model}_#{column}_type_to_#{to}"
|
61
|
-
gsub_file generated_migration_file, /def (up|change).* end/m, "def change\n change_column :#{model}, :#{column}, :#{to}\n end"
|
62
|
-
else
|
63
|
-
raise "unexpected action: #{action}"
|
64
|
-
end
|
65
|
-
Erd::Migrator.run_migrations :up => generated_migration_file
|
66
|
-
executed_migrations << generated_migration_file
|
62
|
+
raise "unexpected action: #{action}"
|
67
63
|
end
|
64
|
+
|
65
|
+
Erd::Migrator.run_migrations :up => generated_migration_file
|
66
|
+
executed_migrations << generated_migration_file
|
68
67
|
rescue ::Erd::MigrationError => e
|
69
68
|
failed_migrations << e.message
|
70
69
|
end
|
@@ -79,28 +78,64 @@ module Erd
|
|
79
78
|
end
|
80
79
|
|
81
80
|
private
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
81
|
+
|
82
|
+
def saved_positions
|
83
|
+
POSITIONS_JSON_FILE.exist? ? ActiveSupport::JSON.decode(POSITIONS_JSON_FILE.read) : {}
|
84
|
+
end
|
85
|
+
|
86
|
+
def generate_plain
|
87
|
+
if Rails.respond_to?(:autoloaders) && Rails.autoloaders.try(:zeitwerk_enabled?)
|
88
|
+
Zeitwerk::Loader.eager_load_all
|
89
|
+
else
|
90
|
+
Rails.application.eager_load!
|
91
|
+
end
|
92
|
+
ar_descendants = ActiveRecord::Base.descendants.reject {|m| m.name.in?(%w(ActiveRecord::SchemaMigration ActiveRecord::InternalMetadata ApplicationRecord)) }
|
93
|
+
ar_descendants.reject! {|m| !m.table_exists? }
|
94
|
+
|
95
|
+
g = GraphViz.new('ERD', :type => :digraph, :rankdir => 'LR', :labelloc => :t, :ranksep => '1.5', :nodesep => '1.8', :margin => '0,0', :splines => 'spline') {|g|
|
96
|
+
nodes = ar_descendants.each_with_object({}) do |model, hash|
|
97
|
+
next if model.name.start_with? 'HABTM_'
|
98
|
+
hash[model.name] = model.columns.reject {|c| c.name.in? %w(id created_at updated_at) }.map {|c| [c.name, c.type]}
|
99
|
+
end
|
100
|
+
|
101
|
+
edges = []
|
102
|
+
ar_descendants.each do |model|
|
103
|
+
model.reflect_on_all_associations.each do |reflection|
|
104
|
+
next unless nodes.key? model.name
|
105
|
+
next if reflection.macro == :belongs_to
|
106
|
+
next unless nodes.key?(reflection.klass.name)
|
107
|
+
|
108
|
+
edges << [model.name, reflection.klass.name]
|
109
|
+
# don't include the FKs in the diagram
|
110
|
+
nodes[reflection.klass.name].delete_if {|col, _type| col == reflection.foreign_key }
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
nodes.each_pair do |model_name, cols|
|
115
|
+
g.add_nodes model_name, 'shape' => 'record', 'label' => "#{model_name}|#{cols.map {|name, type| "#{name}(#{type})"}.join('\l')}"
|
116
|
+
end
|
117
|
+
edges.each do |from, to|
|
118
|
+
g.add_edge g.search_node(from), g.search_node(to)
|
95
119
|
end
|
120
|
+
}
|
121
|
+
g.output('plain' => String)
|
122
|
+
end
|
123
|
+
|
124
|
+
def render_plain(plain, positions, edit_mode = false)
|
125
|
+
_scale, svg_width, svg_height = plain.scan(/\Agraph ([\d\.]+) ([\d\.]+) ([\d\.]+)$/).first
|
126
|
+
# node name x y width height label style shape color fillcolor
|
127
|
+
models = plain.scan(/^node ([^ ]+) ([\d\.]+) ([\d\.]+) ([\d\.]+) ([\d\.]+) ([^ ]+) [^ ]+ [^ ]+ [^ ]+ [^ ]+\n/m).map {|model_name, x, y, width, height, label|
|
128
|
+
columns = label.gsub("\\\n", '').split('|')[1].split('\l').map {|name_and_type| name_and_type.scan(/(.*?)\((.*?)\)/).first }.map {|n, t| {:name => n, :type => t} }
|
96
129
|
custom_x, custom_y = positions[model_name.tableize].try(:split, ',')
|
97
|
-
|
98
|
-
max_model_x, max_model_y = [h[:x].to_i + h[:width].to_i, max_model_x, 1024].max, [h[:y].to_i + h[:height].to_i, max_model_y, 768].max
|
99
|
-
h
|
130
|
+
{:model => model_name, :x => (custom_x || (BigDecimal(x) * 72).round), :y => (custom_y || (BigDecimal(y) * 72).round), :width => (BigDecimal(width) * 72).round, :height => (BigDecimal(height) * 72).round, :columns => columns}
|
100
131
|
}.compact
|
132
|
+
max_model_x = models.map {|m| m[:x].to_f + m[:width].to_f }.max
|
133
|
+
erd_width = [[(BigDecimal(svg_width) * 72).round, max_model_x].min + 150, 1024].max
|
134
|
+
max_model_y = models.map {|m| m[:y].to_f + m[:height].to_f }.max
|
135
|
+
erd_height = [[(BigDecimal(svg_height) * 72).round, max_model_y].min + 150, 768].max
|
101
136
|
# edge tail head n x1 y1 .. xn yn [label xl yl] style color
|
102
|
-
edges = plain.scan(/^edge ([^ ]+)+ ([^ ]+)/).map {|from, to| {:from => from
|
103
|
-
render_to_string 'erd/erd/erd', :layout => nil, :locals => {:width =>
|
137
|
+
edges = plain.scan(/^edge ([^ ]+)+ ([^ ]+)/).map {|from, to| {:from => from, :to => to}}
|
138
|
+
render_to_string 'erd/erd/erd', :layout => nil, :locals => {:width => erd_width, :height => erd_height, :models => models, :edges => edges, :edit_mode => edit_mode}
|
104
139
|
end
|
105
140
|
|
106
141
|
def gsub_file(path, flag, *args, &block)
|
@@ -2,12 +2,16 @@
|
|
2
2
|
<table>
|
3
3
|
<tr>
|
4
4
|
<td>
|
5
|
-
<span class="column_name_text"><%= column[:name] %></span>
|
6
|
-
|
5
|
+
<span class="column_name_text<%= "#{' edit' if edit_mode}" %>"><%= column[:name] %></span>
|
6
|
+
<% if edit_mode %>
|
7
|
+
<form class="rename_column_form"><span><input name="model" type="hidden" value="<%= model[:model] %>" /><input name="column" type="hidden" value="<%= column[:name] %>" /><input name="to" type="text" /><input type="submit" value="Change" /></span><a href="#!" class="cancel">Cancel</a></form>
|
8
|
+
<% end %>
|
7
9
|
</td>
|
8
10
|
<td>
|
9
|
-
<span class="column_type_text <%= column[:type]
|
10
|
-
|
11
|
+
<span class="column_type_text <%= column[:type] %><%= "#{' edit' if edit_mode}" %>"><%= column[:type] %></span>
|
12
|
+
<% if edit_mode %>
|
13
|
+
<form class="alter_column_form"><span><input name="model" type="hidden" value="<%= model[:model] %>" /><input name="column" type="hidden" value="<%= column[:name] %>" /><input name="type" type="hidden" value="<%= column[:type] %>" /><input name="to" type="text" /><input type="submit" value="Change" /></span><a href="#!" class="cancel">Cancel</a></form>
|
14
|
+
<% end %>
|
11
15
|
</td>
|
12
16
|
</tr>
|
13
17
|
</table>
|
@@ -1,28 +1,34 @@
|
|
1
1
|
<div id="erd-<%= model[:model] %>" class="model" style="top: <%= model[:y] %>px; left: <%= model[:x] %>px;" data-model_name="<%= model[:model] %>">
|
2
|
-
|
3
|
-
|
2
|
+
<% if edit_mode %>
|
3
|
+
<a href="#!" class="close"><%= image_tag '/erd/close.png' %></a>
|
4
|
+
<% end %>
|
5
|
+
<div class="model_name<%= "#{' edit' if edit_mode}" %>">
|
4
6
|
<div class="model_name_text"><%= model[:model] %></div>
|
5
|
-
|
6
|
-
<
|
7
|
-
<
|
8
|
-
<
|
9
|
-
<
|
10
|
-
|
11
|
-
|
12
|
-
<
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
7
|
+
<% if edit_mode %>
|
8
|
+
<form class="rename_model_form">
|
9
|
+
<table>
|
10
|
+
<tr>
|
11
|
+
<td>
|
12
|
+
<input name="model" type="hidden" value="<%= model[:model] %>"/>
|
13
|
+
</td>
|
14
|
+
<td>
|
15
|
+
<input name="to" type="text" /><input type="submit" value="Change"/>
|
16
|
+
</td>
|
17
|
+
</tr>
|
18
|
+
</table>
|
19
|
+
<a href="#!" class="cancel">Cancel</a>
|
20
|
+
</form>
|
21
|
+
<% end %>
|
18
22
|
</div>
|
19
23
|
<div class="columns">
|
20
24
|
<ul>
|
21
|
-
<%= render :partial => 'erd/erd/column', :collection => model[:columns], :locals => {:model => model} -%>
|
25
|
+
<%= render :partial => 'erd/erd/column', :collection => model[:columns], :locals => {:model => model, :edit_mode => edit_mode} -%>
|
22
26
|
</ul>
|
23
27
|
</div>
|
24
28
|
<div class="add_column_box">
|
25
|
-
|
29
|
+
<% if edit_mode %>
|
30
|
+
<a href="#!" class="add_column">add column</a>
|
31
|
+
<% end %>
|
26
32
|
<form class="add_column_form">
|
27
33
|
<input name="model" type="hidden" value="<%= model[:model] %>" />
|
28
34
|
<table>
|
@@ -0,0 +1,87 @@
|
|
1
|
+
<div id="erd_box">
|
2
|
+
<div id="erd_container">
|
3
|
+
<%=raw @erd %>
|
4
|
+
</div>
|
5
|
+
<div id="open_migration"><%= image_tag '/erd/angle-left.png' %></div>
|
6
|
+
<div id="migration">
|
7
|
+
<div id="close_migration"><%= image_tag '/erd/angle-right.png' %></div>
|
8
|
+
<%- if flash[:executed_migrations].present? -%>
|
9
|
+
<div id="executed">
|
10
|
+
<h2>Successfully executed following <%= flash[:executed_migrations].values.flatten.count %> migrations!</h2>
|
11
|
+
<%- [:up, :down].each do |direction| -%>
|
12
|
+
<%- if flash[:executed_migrations][direction].present? -%>
|
13
|
+
<h3><%= direction %></h3>
|
14
|
+
<ul>
|
15
|
+
<%- flash[:executed_migrations][direction].each do |m| -%>
|
16
|
+
<li><%= File.basename m.to_s %></li>
|
17
|
+
<%- end -%>
|
18
|
+
</ul>
|
19
|
+
<%- end -%>
|
20
|
+
<%- end -%>
|
21
|
+
</div>
|
22
|
+
<%- end -%>
|
23
|
+
<%- if flash[:failed_migrations].present? -%>
|
24
|
+
<div id="failed">
|
25
|
+
<h2>failed migrations</h2>
|
26
|
+
<ul>
|
27
|
+
<%- flash[:failed_migrations].each do |m| -%>
|
28
|
+
<li><%= m %></li>
|
29
|
+
<%- end -%>
|
30
|
+
</ul>
|
31
|
+
</div>
|
32
|
+
<%- end -%>
|
33
|
+
<table id="changes">
|
34
|
+
<caption>schema changes</caption>
|
35
|
+
<thead><tr><th>action</th><th>model</th><th>column</th><th>from</th><th>to</th></tr></thead>
|
36
|
+
<tbody></tbody>
|
37
|
+
</table>
|
38
|
+
<%= form_tag '/erd', :method => :put, :id => 'changes_form' do %>
|
39
|
+
<%= hidden_field_tag 'changes' %>
|
40
|
+
<%= hidden_field_tag 'position_changes' %>
|
41
|
+
<%= submit_tag 'save changes' %>
|
42
|
+
<% end %>
|
43
|
+
<%= form_tag '/erd/migrate', :method => :put, :id => 'migrate_form' do %>
|
44
|
+
<ul id="open_buttons">
|
45
|
+
<li><button id="open_up" type="button">up</button></li>
|
46
|
+
<li><button id="open_down" type="button">down</button></li>
|
47
|
+
<li><button id="close_all" type="button">close</button></li>
|
48
|
+
</ul>
|
49
|
+
<table id="migration_status">
|
50
|
+
<caption>migration status</caption>
|
51
|
+
<thead>
|
52
|
+
<tr><th class="status">status</th><th class="version">version</th><th class="name">name</th></tr>
|
53
|
+
<tr><td colspan="3" class="migrations">
|
54
|
+
<button>UNFOLD ALL</button>
|
55
|
+
<%= @migrations.count %> migrations in total (up: <%= @migrations.count {|m| m[:status] == 'up'} %>, down: <%= @migrations.count {|m| m[:status] == 'down'} %>)
|
56
|
+
</td></tr>
|
57
|
+
</thead>
|
58
|
+
<tbody>
|
59
|
+
<%- @migrations.each do |m| -%>
|
60
|
+
<tr class="<%= m[:status] %>">
|
61
|
+
<td><label><%= check_box_tag (m[:status] == 'up' ? 'down[]' : 'up[]'), m[:filename], false, :id => "check_#{m[:filename]}" %><%= m[:status] %></label></td>
|
62
|
+
<td><%= m[:version] %></td>
|
63
|
+
<td class="migration_file_name"><%= m[:name] %></td>
|
64
|
+
</tr>
|
65
|
+
<%- end -%>
|
66
|
+
</tbody>
|
67
|
+
</table>
|
68
|
+
<%= submit_tag 'run migrations' %>
|
69
|
+
<% end %>
|
70
|
+
</div>
|
71
|
+
<a href="#" id='open_create_model_dialog'%>Create Model</a>
|
72
|
+
<div id="create_model_form">
|
73
|
+
<form>
|
74
|
+
Model Name: <input id="new_model_name" name="new_model_name" type="text" /><br>
|
75
|
+
<table id="create_model_table">
|
76
|
+
<tbody>
|
77
|
+
<tr>
|
78
|
+
<td><input name="new_model_column_name_1" type="text" /></td>
|
79
|
+
<td class="separator">:</td>
|
80
|
+
<td><input name="new_model_column_type_1" type="text" value="string" /></td>
|
81
|
+
</tr>
|
82
|
+
</tbody>
|
83
|
+
</table>
|
84
|
+
<div><a href="#" id="new_model_add_column" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"><span class="ui-button-text">Add More Column</span></a></div>
|
85
|
+
</form>
|
86
|
+
</div>
|
87
|
+
</div>
|
@@ -1,4 +1,4 @@
|
|
1
1
|
<div id="erd" data-svg_width="<%= width %>" data-svg_height="<%= height %>">
|
2
|
-
<%= render :partial => 'erd/erd/model', :collection => models -%>
|
2
|
+
<%= render :partial => 'erd/erd/model', :collection => models, :locals => {:edit_mode => edit_mode} -%>
|
3
3
|
<script>window.raw_edges = <%= edges.to_json.html_safe %>;</script>
|
4
4
|
</div>
|
@@ -2,85 +2,16 @@
|
|
2
2
|
<div id="erd_container">
|
3
3
|
<%=raw @erd %>
|
4
4
|
</div>
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
<%- end -%>
|
18
|
-
</ul>
|
19
|
-
<%- end -%>
|
20
|
-
<%- end -%>
|
21
|
-
</div>
|
22
|
-
<%- end -%>
|
23
|
-
<%- if flash[:failed_migrations].present? -%>
|
24
|
-
<div id="failed">
|
25
|
-
<h2>failed migrations</h2>
|
26
|
-
<ul>
|
27
|
-
<%- flash[:failed_migrations].each do |m| -%>
|
28
|
-
<li><%= m %></li>
|
29
|
-
<%- end -%>
|
30
|
-
</ul>
|
31
|
-
</div>
|
32
|
-
<%- end -%>
|
33
|
-
<table id="changes">
|
34
|
-
<caption>schema changes</caption>
|
35
|
-
<thead><tr><th>action</th><th>model</th><th>column</th><th>from</th><th>to</th></tr></thead>
|
36
|
-
<tbody></tbody>
|
37
|
-
</table>
|
38
|
-
<%= form_tag '/erd', :method => :put, :id => 'changes_form' do %>
|
39
|
-
<%= hidden_field_tag 'changes' %>
|
40
|
-
<%= submit_tag 'save changes' %>
|
41
|
-
<% end %>
|
42
|
-
<%= form_tag '/erd/migrate', :method => :put, :id => 'migrate_form' do %>
|
43
|
-
<ul id="open_buttons">
|
44
|
-
<li><button id="open_up" type="button">up</button></li>
|
45
|
-
<li><button id="open_down" type="button">down</button></li>
|
46
|
-
<li><button id="close_all" type="button">close</button></li>
|
47
|
-
</ul>
|
48
|
-
<table id="migration_status">
|
49
|
-
<caption>migration status</caption>
|
50
|
-
<thead>
|
51
|
-
<tr><th class="status">status</th><th class="version">version</th><th class="name">name</th></tr>
|
52
|
-
<tr><td colspan="3" class="migrations">
|
53
|
-
<button>UNFOLD ALL</button>
|
54
|
-
<%= @migrations.count %> migrations in total (up: <%= @migrations.count {|m| m[:status] == 'up'} %>, down: <%= @migrations.count {|m| m[:status] == 'down'} %>)
|
55
|
-
</td></tr>
|
56
|
-
</thead>
|
57
|
-
<tbody>
|
58
|
-
<%- @migrations.each do |m| -%>
|
59
|
-
<tr class="<%= m[:status] %>">
|
60
|
-
<td><label><%= check_box_tag (m[:status] == 'up' ? 'down[]' : 'up[]'), m[:filename] %><%= m[:status] %></label></td>
|
61
|
-
<td><%= m[:version] %></td>
|
62
|
-
<td class="migration_file_name"><%= m[:name] %></td>
|
63
|
-
</tr>
|
64
|
-
<%- end -%>
|
65
|
-
</tbody>
|
66
|
-
</table>
|
67
|
-
<%= submit_tag 'run migrations' %>
|
68
|
-
<% end %>
|
69
|
-
</div>
|
70
|
-
<a href="#" id='open_create_model_dialog'%>Create Model</a>
|
71
|
-
<div id="create_model_form">
|
72
|
-
<form>
|
73
|
-
Model Name: <input id="new_model_name" name="new_model_name" type="text" /><br>
|
74
|
-
<table id="create_model_table">
|
75
|
-
<tbody>
|
76
|
-
<tr>
|
77
|
-
<td><input name="new_model_column_name_1" type="text" /></td>
|
78
|
-
<td class="separator">:</td>
|
79
|
-
<td><input name="new_model_column_type_1" type="text" value="string" /></td>
|
80
|
-
</tr>
|
81
|
-
</tbody>
|
82
|
-
</table>
|
83
|
-
<div><a href="#" id="new_model_add_column" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"><span class="ui-button-text">Add More Column</span></a></div>
|
84
|
-
</form>
|
85
|
-
</div>
|
5
|
+
<%= form_tag '/erd', :method => :put, :id => 'changes_form' do %>
|
6
|
+
<%= hidden_field_tag 'position_changes' %>
|
7
|
+
<% end %>
|
8
|
+
<input id="drawer_switch" type="checkbox">
|
9
|
+
<label id="drawer_hide_label" class="drawer_switch_label" for="drawer_switch">> Hide Buttons</label>
|
10
|
+
<label id="drawer_show_label" class="drawer_switch_label" for="drawer_switch"><</label>
|
11
|
+
<nav id="buttons">
|
12
|
+
<ul>
|
13
|
+
<li><a href="#!" id="save_position_changes" class="menu_button">Save Position Changes</a></li>
|
14
|
+
<li><%= link_to 'Edit the Database', :edit, :id => 'link_to_edit', :class => 'menu_button' %></li>
|
15
|
+
</ul>
|
16
|
+
</nav>
|
86
17
|
</div>
|