Module: MeshChat::Database

Defined in:
lib/meshchat/database.rb

Class Method Summary collapse

Class Method Details

.setup_storageObject

Upon initial startup, instantiated the database this is used for storing the information of every node on the network



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/meshchat/database.rb', line 8

def setup_storage
  ActiveRecord::Base.establish_connection(
      adapter: "sqlite3",
      database: "meshchat.sqlite3",
      pool: 128
  )

  ActiveRecord::Migration.suppress_messages do
    ActiveRecord::Schema.define do
      unless table_exists? :entries
        create_table :entries do |table|
          table.column :alias_name, :string
          table.column :location, :string
          table.column :uid, :string
          table.column :public_key, :string
          table.column :online, :boolean, default: true, null: false
        end
      end
    end
  end
end