module ZBootstrap
Public Class Methods
fix_serial(db=nil)
click to toggle source
# File lib/jungle_path/app/ztools/zbootstrapdata.rb, line 58 def self.fix_serial db=nil db = Server::API::DB.instance unless db db.reset_sequence_for_table("user") db.reset_sequence_for_table("contact") end
root_data(db_config=nil, schema_initial_version=nil)
click to toggle source
# File lib/jungle_path/app/ztools/zbootstrapdata.rb, line 15 def self.root_data db_config=nil, schema_initial_version=nil db = JunglePath::DBAccess::IO::DB.new(db_config) if db_config db = Server::DB.instance unless db # set starting version numnber if schema_initial_version schema_info = Schema::SchemaInfo.new({version: schema_initial_version}) db.insert._model(schema_info) end hash = 'sha1:1000:/CloeFSPBOT7Ac/Jf/qQLk59iQbflhxf:H4eHZ0w51f3UdQpM+tp2DdhofDPkTf2P\n' # "test" hash_zoo = 'sha1:1000:wNGOiLtzLt7U9t7g+AoQVYZBeZn4NDIl:WZ7ADLonzVbnMP+d0g4K94Rk06ai4Ezk\n' # "zoo" users = [ Schema::User.new({id: 0, name: 'root', user_name: 'root', role: 'root', hash: hash, email: nil, active: true, created_by_user_id: 0, updated_by_user_id: 0}), Schema::User.new({id: 1, name: 'admin', user_name: 'admin', role: 'admin', hash: hash, email: nil, active: true, created_by_user_id: 0, updated_by_user_id: 0}), Schema::User.new({id: 2, name: 'user', user_name: 'user', role: 'user', hash: hash_zoo, email: nil, active: true, created_by_user_id: 0, updated_by_user_id: 0}) ] users.each {|user| db.insert._model(user)} contacts = [ Schema::Contact.new({id: 0, name: 'root', email: 'root@junglepath.com', user_id: 0, created_by_user_id: 0, updated_by_user_id: 0}), Schema::Contact.new({id: 1, name: 'admin', email: 'admin@junglepath.com', user_id: 1, created_by_user_id: 0, updated_by_user_id: 0}), Schema::Contact.new({id: 2, name: 'user', email: 'user@junglepath.com', user_id: 2, created_by_user_id: 0, updated_by_user_id: 0}) ] contacts.each {|contact| db.insert._model(contact)} #roles = [ # Schema::Role.new({id: 0, name: 'root', description: 'do anything', created_by_user_id: 0, updated_by_user_id: 0}), # Schema::Role.new({id: 1, name: 'admin', description: 'general admin -- filtered by organization', created_by_user_id: 0, updated_by_user_id: 0}), # Schema::Role.new({id: 2, name: 'user', description: 'basic user of system', created_by_user_id: 0, updated_by_user_id: 0}) #] #roles.each {|role| db.insert._model(role)} #user_roles = [ # Schema::UserRole.new({user_id: 0, role_id: 0, created_by_user_id: 0, updated_by_user_id: 0}), # Schema::UserRole.new({user_id: 1, role_id: 1, created_by_user_id: 0, updated_by_user_id: 0}), # Schema::UserRole.new({user_id: 2, role_id: 2, created_by_user_id: 0, updated_by_user_id: 0}) #] #user_roles.each {|user_role| db.insert._model(user_role)} fix_serial db end