entity_storage 2.1.1 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,7 +9,7 @@ require 'active_record'
9
9
 
10
10
 
11
11
  module EntityStorage
12
- VERSION = '2.1.1'
12
+ VERSION = '2.1.2'
13
13
 
14
14
  class Storage
15
15
  attr_accessor :defaults
@@ -20,16 +20,17 @@ module EntityStorage
20
20
  if !ActiveRecord::Base.connection.table_exists?('entity_storage')
21
21
  puts "Creating entity table..."
22
22
  AddEntitiesTable.create
23
- elsif self['ENTITY_STORAGE_MASTER_VERSION'].nil? || (self['ENTITY_STORAGE_MASTER_VERSION']!='2.1.0' && self['ENTITY_STORAGE_MASTER_VERSION']!='2.1.1')
24
- # this will need to be updated for future version changes
25
- self['ENTITY_STORAGE_MASTER_VERSION']='2.1.1'
26
- puts "Migrating to new 2.1.x binary format..."
27
- ActiveRecord::Base.connection.execute("alter table entity_storage modify value blob")
23
+ self['ENTITY_STORAGE_MASTER_VERSION']='2.1.2'
24
+ elsif self['ENTITY_STORAGE_MASTER_VERSION'].nil? || self['ENTITY_STORAGE_MASTER_VERSION']!='2.1.2'
25
+ self['ENTITY_STORAGE_MASTER_VERSION']='2.1.2'
26
+ ActiveRecord::Base.connection.execute("show columns from entity_storage").each {|p|
27
+ if p[0] == "value" && p[1] != "blob"
28
+ puts "Migrating to new 2.1.x binary format..."
29
+ ActiveRecord::Base.connection.execute("alter table entity_storage modify value blob")
30
+ end
31
+ }
28
32
  end
29
33
 
30
-
31
-
32
-
33
34
  end
34
35
 
35
36
  # Read a value.
@@ -21,6 +21,28 @@ class TestEntityStorage < Test::Unit::TestCase
21
21
  entityStore2 = EntityStorage::Storage.new(DEFAULT_KEYS)
22
22
  assert_equal entityStore2.email_test_address, 'joshuas@bnj.com'
23
23
  end
24
+
25
+ # tests migration from old type of table
26
+ def test_migration
27
+ ActiveRecord::Base.connection.execute("drop table entity_storage")
28
+ AddOldEntitiesTable.create
29
+ ActiveRecord::Base.connection.execute("show columns from entity_storage").each {|p|
30
+ assert(p[1] == "text") if p[0] == "value" }
31
+ entityStore = EntityStorage::Storage.new(DEFAULT_KEYS)
32
+ ActiveRecord::Base.connection.execute("show columns from entity_storage").each {|p|
33
+ assert(p[1] == "blob") if p[0] == "value" }
34
+ assert entityStore['ENTITY_STORAGE_MASTER_VERSION']=='2.1.2'
35
+
36
+ ActiveRecord::Base.connection.execute("delete from entity_storage")
37
+ entityStore = EntityStorage::Storage.new(DEFAULT_KEYS)
38
+ assert entityStore['ENTITY_STORAGE_MASTER_VERSION']=='2.1.2'
39
+
40
+ ActiveRecord::Base.connection.execute("drop table entity_storage")
41
+ entityStore = EntityStorage::Storage.new(DEFAULT_KEYS)
42
+ ActiveRecord::Base.connection.execute("show columns from entity_storage").each {|p|
43
+ assert(p[1] == "blob") if p[0] == "value" }
44
+ assert entityStore['ENTITY_STORAGE_MASTER_VERSION']=='2.1.2'
45
+ end
24
46
 
25
47
  # tests value setting and getting functionality, along with default creation
26
48
  def test_defaultkeys
@@ -106,3 +128,24 @@ class TestEntityStorage < Test::Unit::TestCase
106
128
  end
107
129
 
108
130
  end
131
+
132
+ # old Version
133
+ # This migration is required for EntityStorage to work correctly
134
+ class AddOldEntitiesTable < ActiveRecord::Migration
135
+ # up and down functions call broken code in Rail3 migrations gem, called it 'create'
136
+
137
+ def self.create
138
+ create_table "entity_storage", :force => true do |t|
139
+ t.string "key", :limit => 512, :null => false
140
+ t.text "value"
141
+ #t.binary "value"
142
+ t.datetime "created_at"
143
+ t.datetime "updated_at"
144
+ end
145
+
146
+ add_index "entity_storage", ["created_at"], :name => "created_at"
147
+ add_index "entity_storage", ["key"], :name => "key"
148
+ add_index "entity_storage", ["updated_at"], :name => "updated_at"
149
+ end
150
+
151
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: entity_storage
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 15
5
5
  prerelease:
6
6
  segments:
7
7
  - 2
8
8
  - 1
9
- - 1
10
- version: 2.1.1
9
+ - 2
10
+ version: 2.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Joshua Siler