Class: MsgpackMigrationHelper
- Inherits:
-
Object
- Object
- MsgpackMigrationHelper
- Defined in:
- lib/dynflow/persistence_adapters/sequel_migrations/msgpack_migration_helper.rb
Instance Method Summary collapse
- #down(migration) ⇒ Object
-
#initialize(tables) ⇒ MsgpackMigrationHelper
constructor
A new instance of MsgpackMigrationHelper.
- #up(migration) ⇒ Object
Constructor Details
#initialize(tables) ⇒ MsgpackMigrationHelper
Returns a new instance of MsgpackMigrationHelper.
7 8 9 |
# File 'lib/dynflow/persistence_adapters/sequel_migrations/msgpack_migration_helper.rb', line 7 def initialize(tables) @tables = tables end |
Instance Method Details
#down(migration) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/dynflow/persistence_adapters/sequel_migrations/msgpack_migration_helper.rb', line 21 def down(migration) @tables.each do |table, columns| new_columns = columns.map { |c| c + '_text' } migrate_table migration, table, columns, new_columns, String do |data| JSON.dump(MessagePack.unpack(data)) end end end |
#up(migration) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/dynflow/persistence_adapters/sequel_migrations/msgpack_migration_helper.rb', line 11 def up(migration) @tables.each do |table, columns| new_columns = columns.map { |c| "#{c}_blob" } migrate_table migration, table, columns, new_columns, File do |data| ::Sequel.blob(MessagePack.pack(JSON.parse(data))) end end end |