Module: Slosilo::Adapters::SequelAdapter::Migration

Defined in:
lib/slosilo/adapters/sequel_adapter/migration.rb

Constant Summary collapse

DEFAULT_KEYSTORE_TABLE =

The default name of the table to hold the keys

:slosilo_keystore

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#keystore_tableObject

Keystore table name. If changing this do it immediately after loading the extension.



14
15
16
# File 'lib/slosilo/adapters/sequel_adapter/migration.rb', line 14

def keystore_table
  @keystore_table
end

Class Method Details

.extended(db) ⇒ Object

Sets up default keystore table name



9
10
11
# File 'lib/slosilo/adapters/sequel_adapter/migration.rb', line 9

def self.extended(db)
  db.keystore_table ||= DEFAULT_KEYSTORE_TABLE
end

Instance Method Details

#create_keystore_tableObject

Create the table for holding keys



17
18
19
20
21
22
23
24
25
26
# File 'lib/slosilo/adapters/sequel_adapter/migration.rb', line 17

def create_keystore_table
  # docs say to not use create_table? in migration;
  # but we really want this to be robust in case there are any previous installs
  # and we can't use table_exists? because it rolls back
  create_table? keystore_table do
    String :id, primary_key: true
    bytea :key, null: false
    String :fingerprint, unique: true, null: false
  end
end

#drop_keystore_tableObject

Drop the table



29
30
31
# File 'lib/slosilo/adapters/sequel_adapter/migration.rb', line 29

def drop_keystore_table
  drop_table keystore_table
end