app/models/draw_erd/diagram.rb in draw_erd-0.1.0 vs app/models/draw_erd/diagram.rb in draw_erd-0.1.1
- old
+ new
@@ -7,21 +7,34 @@
schemas = ActiveRecord::Base.connection.tables
schemas.delete('schema_migrations')
schemas.map! {|schema| schema.singularize.camelize}
schemas.sort
end
+
+ def reset_migrations
+ paths = ActiveRecord::Migrator.migrations_paths
+ paths.each do |path|
+ Dir.foreach(path) do |file|
+ if match_data = /^(\d{3,})_(.+)\.rb$/.match(file)
+ version = match_data[1].to_i
+ ActiveRecord::Migrator.run(:down, paths, version)
+ ActiveRecord::Migrator.run(:up, paths, version)
+ end
+ end
+ end
+ end
end
def initialize(path)
@path = File.expand_path(path, Rails.root)
FileUtils.mkdir_p(@path)
end
- def create(title, domains=[])
+ def create(title, domains=[], attributes=[:foreign_keys, :content])
only = domains.map {|domain| domain.to_sym}
options = {
filetype: :png,
- attributes: [:foreign_keys, :primary_keys, :content],
+ attributes: attributes,
title: title.to_s,
only: only,
filename: File.join(@path, title.to_s)
}