Sha256: a0e3535a15c509b9d5d170ca1c8832000dd2ca89caa3a2dd2779d80f4a839f17
Contents?: true
Size: 943 Bytes
Versions: 1
Compression:
Stored size: 943 Bytes
Contents
require "parse/db/import/utils" module Parse module Db class Import def create_schema(options) Dir["#{options.path}/#{options.entity}/data.json"].each do |file| missing_columns = {} klass = klass_from_file(file) puts "Scanning....#{klass.name}" process_parse_file(file) do |record| columns = get_missing_columns(klass, record.keys) unless columns.empty? columns.each { |k| missing_columns[k] = 0} end missing_columns.each do |k, v| len = record[k].to_s.length missing_columns[k] = len if v < len end end if (missing_columns.length) puts "Creating....#{klass.name} columns #{missing_columns.map{|k,v| "#{k} varchar(#{v})"}.join(", ")}" create_missing_columns(klass, missing_columns) end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
parse-db-import-0.0.1 | lib/parse/db/import/create_schema.rb |